public MyMwcObjectBuilder_Checkpoint GetCheckpointBuilder(bool includeSector) { MyMwcObjectBuilder_Checkpoint checkpoint = new MyMwcObjectBuilder_Checkpoint(); if (includeSector) { checkpoint.SectorObjectBuilder = new MyMwcObjectBuilder_Sector(); List <MyMwcObjectBuilder_Base> sectorObjectBuilders = GetSectorObjectBuilders(); foreach (MyMwcObjectBuilder_Base objectBuilder in sectorObjectBuilders) { System.Diagnostics.Debug.Assert(objectBuilder != null, "If object is not to be saved, unset his EntityFlags::Save!"); } checkpoint.SectorObjectBuilder.SectorObjects = sectorObjectBuilders; checkpoint.SectorObjectBuilder.ObjectGroups = MyEditor.Static.ObjectGroups.ConvertAll(a => a.GetObjectBuilder()); checkpoint.SectorObjectBuilder.SnapPointLinks = MyEditor.Static.GetSnapPointLinkBuilders(); if (MyGuiScreenGamePlay.Static.Checkpoint.SectorObjectBuilder != null) { checkpoint.SectorObjectBuilder.Name = MyGuiScreenGamePlay.Static.Checkpoint.SectorObjectBuilder.Name; checkpoint.SectorObjectBuilder.Position = MyGuiScreenGamePlay.Static.Checkpoint.SectorObjectBuilder.Position; } } checkpoint.CurrentSector = MyGuiScreenGamePlay.Static.GetSectorIdentifier(); checkpoint.CheckpointName = null; checkpoint.PlayerObjectBuilder = MySession.Static.Player.GetObjectBuilder(true); checkpoint.SessionObjectBuilder = GetObjectBuilder(); checkpoint.EventLogObjectBuilder = EventLog.GetObjectBuilder(); checkpoint.FactionRelationChangesBuilder = FactionRelationChanges.GetObjectBuilders(); checkpoint.GameTime = GameDateTime; checkpoint.ActiveMissionID = MyMissions.ActiveMission == null ? -1 : (int)MyMissions.ActiveMission.ID; if (CanSaveAndLoadSessionInventory) { checkpoint.InventoryObjectBuilder = Inventory.GetObjectBuilder(true); } else { checkpoint.InventoryObjectBuilder = new MyMwcObjectBuilder_Inventory(new List <MyMwcObjectBuilder_InventoryItem>(), MyInventory.DEFAULT_MAX_ITEMS); } MotherShipPosition.Save(checkpoint.Dictionary); if (MyMultiplayerGameplay.GameType == MyGameTypes.Story) { MyGuiScreenGamePlay.Static.Checkpoint.CopyCoopPlayers(checkpoint); } CheckEntityIds(checkpoint); return(checkpoint); }
/// <summary> /// This method is called when sector and all entities are loaded (created from object builder - or generated other way). /// It raises LinkEntities event, and calls method MyEntities.Link. /// </summary> public void AfterLoad(MyMwcObjectBuilder_Checkpoint checkpoint) { CheckpointName = checkpoint.CheckpointName; MyEntityIdentifier.AllocationSuspended = false; var handler = LinkEntities; if (handler != null) { handler(); } MyEntities.Link(); MyWayPointGraph.DeleteNullVerticesFromPaths(); MyWayPointGraph.RemoveWaypointsAroundLargeStaticObjects(); FactionRelationChanges.Init(checkpoint.FactionRelationChangesBuilder); // GPS waypoints must be created after the first physics pass: see end of MyGuiScreenGamePlay.Update() }