public GridGroup( MyCubeGrid grid, GridLinkTypeEnum linkType = GridLinkTypeEnum.Logical )
{
_linkType = linkType;
if ( grid.InScene )
{
List<MyCubeGrid> tmpList = new List<MyCubeGrid>( );
//find the group containing this grid with the given link type
Wrapper.GameAction( ( ) => tmpList = MyCubeGridGroups.Static.GetGroups( linkType ).GetGroupNodes( grid ) );
_grids.UnionWith( tmpList );
}
//manually create a group for out of scene grids because they have a null group (yay Dusan fixed the crash)
else
{
//use the old method to filter out grids with pistons or rotors, for safety
HashSet<IMyEntity> thisEntity = new HashSet<IMyEntity>();
HashSet<IMyEntity> returnSet = new HashSet<IMyEntity>();
thisEntity.Add( (IMyEntity)grid );
CubeGrids.GetGridsUnconnected( returnSet, thisEntity );
if ( returnSet.Count > 0 )
_grids.Add( grid );
else
return;
}
//populate our internal lists
ComputeParent( );
ComputeCubeBlocks( );
ComputeFatBlocks( );
ComputeSmallOwners( );
ComputeBigOwners( );
}