/// <summary> /// Remember, this is only for server-side. /// </summary> public static void ChangeOwnershipSmart(this IMyCubeGrid Grid, long NewOwnerID, MyOwnershipShareModeEnum ShareMode) { if (!MyAPIGateway.Session.IsServer) { return; } try { var Subgrids = Grid.GetAllSubgrids(); Grid.ChangeGridOwnership(NewOwnerID, ShareMode); foreach (IMyCubeGrid Subgrid in Subgrids) { try { Subgrid.ChangeGridOwnership(NewOwnerID, ShareMode); } catch (Exception Scrap) { Grid.LogError("ChangeOwnershipSmart.ChangeSubgridOwnership", Scrap); } } } catch (Exception Scrap) { Grid.LogError("ChangeOwnershipSmart", Scrap); } }
public static void DeleteSmart(this IMyCubeGrid Grid) { if (!MyAPIGateway.Session.IsServer) { return; } List <IMyCubeGrid> Subgrids = Grid.GetAllSubgrids(); foreach (IMyCubeGrid Subgrid in Subgrids) { Subgrid.Close(); } Grid.Close(); }