protected override void OnActionCompleted(IAsyncResult asyncResult, MySectorServiceClient client) { try { byte[] result = client.EndLoadCheckpoint(asyncResult); m_checkpoint = MyMwcObjectBuilder_Base.FromBytes<MyMwcObjectBuilder_Checkpoint>(result); //if (m_checkpoint.SectorObjectBuilder == null) // Server told us to use cache //{ // LoadSector(); // return; //} MyGuiScreenGamePlay.StoreLastLoadedCheckpoint(m_checkpoint); m_loadCheckpointSuccessfulAction(m_checkpoint); CloseScreen(); } catch (FaultException<MyCustomFault> faultException) { if (faultException.Detail.ErrorCode == MyCustomFaultCode.CheckpointTemplateNotExists) { HandleNonexistentCheckpoint(); } else { // Handled by base class throw faultException; } } }
public MyGuiScreenEditorSaveProgress(MyMwcSectorIdentifier sectorIdentifier, MyMwcObjectBuilder_Checkpoint checkpoint, bool savePlayer, bool visibleSave = true, bool pause = false) : base(MyTextsWrapperEnum.SaveSectorInProgressPleaseWait, false, TimeSpan.FromSeconds(120)) // Enought time to save sector - full of asteroids, etc { m_checkpoint = checkpoint; m_sectorIdentifier = sectorIdentifier; m_savePlayer = savePlayer; m_forceHide = !visibleSave; m_pause = pause; }
public static void CopyCoopPlayers(this MyMwcObjectBuilder_Checkpoint loadFrom, MyMwcObjectBuilder_Checkpoint copyTo) { if (loadFrom != null && loadFrom.InventoryObjectBuilder != null && loadFrom.InventoryObjectBuilder.InventoryItems != null) { var result = loadFrom.InventoryObjectBuilder.InventoryItems.Select(s => s.ItemObjectBuilder).OfType<MyMwcObjectBuilder_Player>().Where(s => s.Name.StartsWith(CoopPlayerPrefix)); foreach(var pl in result.ToArray()) { copyTo.StoreCoopPlayer((MyMwcObjectBuilder_Player) pl.Clone()); } } }
public bool Read(MyMessageReader msg) { Checkpoint = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(msg.Reader, msg.EndPoint) as MyMwcObjectBuilder_Checkpoint; return Checkpoint != null && Checkpoint.Read(msg.Reader, msg.EndPoint, MyMwcFinalBuildConstants.SERVER_PROTOCOL_VERSION); }
public void OnEditorClick(MyGuiControlButton sender) { if (MyClientServer.LoggedPlayer == null || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory() || MyClientServer.LoggedPlayer.GetCanAccessEditorForMMO()) { AddLoginScreen(new MyGuiScreenSelectEditor(this)); } else if (!MySteam.IsActive && !MyClientServer.IsMwAccount) // Demo user...generate sector 0, 0, 0. User cant save. { MyGuiManager.CloseAllScreensNowExcept(MyGuiScreenGamePlay.Static); MySession.Static = new MySandboxSession(); MySession.Static.Init(); var sector = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, MyPlayerLocal.OFFLINE_MODE_USERID, new CommonLIB.AppCode.Utils.MyMwcVector3Int(0, 0, 0), String.Empty); var newGameplayScreen = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.EDITOR_SANDBOX, null, sector, 0, MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX); var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static); var checkpoint = new MyMwcObjectBuilder_Checkpoint(); checkpoint.CurrentSector = sector; checkpoint.SectorObjectBuilder = new MyMwcObjectBuilder_Sector(); checkpoint.SectorObjectBuilder.FromGenerator = true; checkpoint.SectorObjectBuilder.Position = sector.Position; checkpoint.SessionObjectBuilder = new MyMwcObjectBuilder_Session(MyGameplayDifficultyEnum.EASY); loadScreen.AddEnterSectorResponse(checkpoint, null); MyGuiManager.AddScreen(loadScreen); } else { MyMwcSectorTypeEnum sectorType = MyMwcClientServer.GetSectorTypeFromSessionType(MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX); AddLoginScreen( new MyGuiScreenLoadSectorIdentifiersProgress(sectorType, false, new MyGuiScreenEnterSectorMap(this, MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX, MyTextsWrapperEnum.StartEditorInProgressPleaseWait, MyConfig.LastSandboxSector))); } }
/// <summary> /// Stores last loaded checkpoint to check missing objects /// </summary> public static void StoreLastLoadedCheckpoint(MyMwcObjectBuilder_Checkpoint checkpoint) { m_lastLoadedCheckpoint = checkpoint; }
void DummyEnterAction(MyMwcObjectBuilder_Checkpoint checkpoint) { }
public override void UnloadData() { MyMwcLog.WriteLine("MyGuiScreenGamePlay.UnloadData - START"); MyMwcLog.IncreaseIndent(); // duplicated call (called in UnloadContent) //if (EditorControls != null) //{ // EditorControls.UnloadContent(); //} MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Cleanup missions"); // Session.Init is not called so cleanup on sector enter MyMissions.Unload(); //m_missionToStart = null; //we need it to load MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyRadar.UnloadData(); MyHud.UnloadData(); MyEditor.Static.UnloadData(); MyVoxelMaps.AutoRecalculateVoxelMaps = false; MyEntities.UnloadData(); MyVoxelMaps.AutoRecalculateVoxelMaps = true; MyExplosionDebrisVoxel.UnloadData(); MyExplosionDebrisModel.UnloadData(); MyUniversalLauncherShells.UnloadData(); MyCannonShots.UnloadData(); MyMissiles.UnloadData(); MyHologramShips.UnloadData(); MyHudNotification.ClearAllNotifications(); MyHudWarnings.UnloadData(); MyDebrisField.UnloadData(); MyNuclearExplosion.Unload(); MyEnemyTargeting.Unload(); MyPathfindingHelper.Unload(); MySmallShipBot.TotalAliveBots = 0; // HOTFIX: MyExplosions.UnloadData(); MyProjectiles.UnloadData(); //Lights needs to be after explosion, because explosion can keep them MyLights.UnloadData(); if ((IsFlyThroughActive() == false) && (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE == true)) { MyTrailerSave.Save(); } if (MyPhysics.physicsSystem != null) { MyPhysics.physicsSystem.DestroyPhysics(); } MyWayPointGraph.UnloadData(); MyVoxelMaps.UnloadData(); MyVoxelPrecalc.UnloadData(); MyVoxelCacheRender.UnloadData(); MyVoxelCacheCellRenderHelper.UnloadData(); MyVoxelCacheData.UnloadData(); MyVoxelContentCellContents.UnloadData(); MyVoxelGenerator.UnloadData(); //MyVoxelMaterials.UnloadData(); MyDistantImpostors.UnloadData(); MyPrefabContainerManager.GetInstance().UnloadData(); MyDistantImpostors.UnloadData(); //MyModels.UnloadData(); //MyRender.UnloadData(); MyDialogues.UnloadData(); MyFriendlyFire.Unload(); MyShouts.UnloadData(); Parallel.Clean(); Static = null; MyMwcLog.DecreaseIndent(); GC.Collect(2); GC.Collect(1); GC.Collect(0); int modelMeshes2 = MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount; int modelVertices2 = MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount; int modelTriangles2 = MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount; MyPerformanceCounter.MyPerAppLifetime app = MyPerformanceCounter.PerAppLifetime; // After data unload, render structures should be definitelly empty //MyRender.AssertStructuresEmpty(); m_entity = null; m_checkpoint = null; //MySession.PlayerShip = null; //var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects(); MyMwcLog.WriteLine("MyGuiScreenGamePlay.UnloadData - END"); }
private void SandboxSectorLoaded(MyMwcVector3Int targetSector, MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcObjectBuilder_Sector cachedSector, MyMwcStartSessionRequestTypeEnum startSessionType, MyMissionID? startMission) { if (checkpoint.SectorObjectBuilder == null) // Server said, use cache { checkpoint.SectorObjectBuilder = cachedSector; } else { MyLocalCache.SaveCheckpoint(checkpoint); } MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, startSessionType, MyGuiScreenGamePlayType.GAME_SANDBOX, startMission); }
private static void UpdatePlayerStartDummy(MyMwcObjectBuilder_Checkpoint checkpoint) { var dummyBuilder = checkpoint.SectorObjectBuilder.SectorObjects.OfType<MyMwcObjectBuilder_DummyPoint>().FirstOrDefault(s => (s.DummyFlags & MyDummyPointFlags.PLAYER_START) > 0); if (dummyBuilder == null) { dummyBuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.DummyPoint, null) as MyMwcObjectBuilder_DummyPoint; dummyBuilder.DummyFlags = MyDummyPointFlags.PLAYER_START; checkpoint.SectorObjectBuilder.SectorObjects.Add(dummyBuilder); var dummyEntity = new MyDummyPoint(); dummyEntity.Init(String.Empty, dummyBuilder, MySession.PlayerShip.WorldMatrix); MyEntities.Add(dummyEntity); } MyGuiScreenGamePlay.Static.ClampPlayerToBorderSafeArea(); dummyBuilder.PositionAndOrientation.Position = MySession.PlayerShip.WorldMatrix.Translation; dummyBuilder.PositionAndOrientation.Forward = MySession.PlayerShip.WorldMatrix.Forward; dummyBuilder.PositionAndOrientation.Up = MySession.PlayerShip.WorldMatrix.Up; }
/// <summary> /// Checks missing objects, returns true when save sector, false when abort saving /// </summary> StringBuilder CheckMissingObject(MyMwcObjectBuilder_Checkpoint checkpoint) { if (MyMwcFinalBuildConstants.IS_DEVELOP && (MyFakes.DUMP_MISSING_OBJECTS || MyFakes.SHOW_MISSING_OBJECTS)) { var missing = MyGuiScreenGamePlay.FindMissingObjectBuilders(checkpoint); if (MyFakes.DUMP_MISSING_OBJECTS) { DumpMissingObjects(missing); } if (MyFakes.SHOW_MISSING_OBJECTS) { return GetMissingObjects(missing); // false to abort saving } } return null; }
/// <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() }
public void BeforeLoad(MyMwcObjectBuilder_Checkpoint checkpoint) { MyEntityIdentifier.AllocationSuspended = true; //if (MyMultiplayerGameplay.IsRunning && !MyMultiplayerGameplay.IsHost) //{ // MyMwcPositionAndOrientation position = MyMultiplayerGameplay.Static.GetSafeRespawnPositionNearPlayer(checkpoint.PlayerObjectBuilder.ShipObjectBuilder.ShipType); // checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation = position; // return; //} // Try find player start location and set player location if (checkpoint.SectorObjectBuilder != null && checkpoint.SectorObjectBuilder.SectorObjects != null) { int playerStartsCount = 0; foreach (var builder in checkpoint.SectorObjectBuilder.SectorObjects) { MyMwcObjectBuilder_DummyPoint dummyBuilder = builder as MyMwcObjectBuilder_DummyPoint; if (dummyBuilder != null) { if ((dummyBuilder.DummyFlags & MyDummyPointFlags.PLAYER_START) > 0) { checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation = dummyBuilder.PositionAndOrientation; playerStartsCount++; } } } } MotherShipPosition.Load(checkpoint.Dictionary); }
void OnGameJoined(MyGameInfo game, MyResultCodeEnum resultCode, MyMwcObjectBuilder_Checkpoint checkpointBuilder) { Debug.Assert(m_waitingScreen != null); m_waitingScreen.CloseScreen(); if (resultCode == MyResultCodeEnum.OK) { var loadingScreen = MySession.StartJoinMultiplayerSession(game.GameType, game.Difficulty, checkpointBuilder); loadingScreen.Closed += new MyGuiScreenBase.ScreenHandler(OnLoadFinished); } else if (resultCode == MyResultCodeEnum.GAME_NOT_EXISTS) { MyGuiManager.AddModalScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.MP_GameHasEnded, MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null), null); GetDataFromServer(true); } else { MyGuiManager.AddModalScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.ErrorCreatingNetworkConnection, MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null), null); GetDataFromServer(true); } }
private MyServerAction CheckpointLoaded(MyMwcObjectBuilder_Checkpoint checkpoint) { MyGameplayConstants.SetGameplayDifficulty(checkpoint.SessionObjectBuilder.Difficulty); Debug.Assert((checkpoint.CheckpointName == null && checkpoint.CurrentSector.UserId != null) || (checkpoint.CheckpointName != null && checkpoint.CurrentSector.UserId == null)); var cacheSector = MyLocalCache.LoadSector(checkpoint.CurrentSector); if (cacheSector != null) { checkpoint.SectorObjectBuilder = cacheSector; MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT, MyGuiScreenGamePlayType.GAME_STORY); return null; } else { // Checkpoint and sector is stored on filesystem throw new MyDataCorruptedException("Last checkpoint sector corrupted"); //MyServerAction loadAction = new MyServerAction(MyTextsWrapperEnum.EnterSectorInProgressPleaseWait); //loadAction.BeginAction = c => c.BeginLoadSector(null, c); //loadAction.EndAction = (c, r) => LastCheckpointSectorLoaded(checkpoint, c.EndLoadSector(r)); //loadAction.Start(); //return loadAction; } }
private void LastCheckpointSectorLoaded(MyMwcObjectBuilder_Checkpoint checkpoint, byte[] sectorData) { checkpoint.SectorObjectBuilder = MyMwcObjectBuilder_Base.FromBytes<MyMwcObjectBuilder_Sector>(sectorData); MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT, MyGuiScreenGamePlayType.GAME_STORY); }
private void CheckEntityIds(MyMwcObjectBuilder_Checkpoint checkpoint) { if (checkpoint.SectorObjectBuilder == null) return; foreach (var builder in checkpoint.SectorObjectBuilder.SectorObjects) { if (builder.EntityId.HasValue) { if (builder.EntityId.Value == checkpoint.PlayerObjectBuilder.ShipObjectBuilder.EntityId || checkpoint.PlayerObjectBuilder.ShipObjectBuilder.Inventory.InventoryItems.Select(s => s.EntityId).Any(id => id == builder.EntityId)) { Debug.Fail("Entity ID of object is same as playership or something in playership inventory"); } } } }
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; }
private MyServerAction NewGameStarted(MyMwcObjectBuilder_Checkpoint checkpoint, MyMissionID missionId) { MyLocalCache.ClearCurrentSave(); MyClientServer.LoggedPlayer.HasAnyCheckpoints = false; Debug.Assert(checkpoint.CurrentSector.UserId == null, "New game checkpoint.CurrentSector must be story sector"); var cachedSector = MyLocalCache.LoadSector(checkpoint.CurrentSector); if (cachedSector != null) { checkpoint.SectorObjectBuilder = cachedSector; checkpoint.CurrentSector.UserId = MyClientServer.LoggedPlayer.GetUserId(); ReloadGameplayNewGame(checkpoint, missionId); return null; } throw new MyDataCorruptedException("New game story checkpoint does not contain first sector!"); }
public static MyGuiScreenLoading ReloadGameplayScreen(MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcStartSessionRequestTypeEnum? sessionType = null, MyGuiScreenGamePlayType? gameplayType = null, MyMissionID? startMission = null, MyMwcTravelTypeEnum? travelType = null) { if (MyMultiplayerGameplay.IsRunning) MyMultiplayerGameplay.Static.Suspend(); if (checkpoint.SectorObjectBuilder != null) { MySession.Static.Is2DSector = MyMwcSectorIdentifier.Is25DSector(checkpoint.SectorObjectBuilder.Name); } Debug.Assert((gameplayType != null && sessionType != null) || MyGuiScreenGamePlay.Static != null, "Set gameplay type and session type, there's no previous gameplay screen"); MyGuiScreenGamePlayType newGameplayType = gameplayType.HasValue ? gameplayType.Value : MyGuiScreenGamePlay.Static.GetGameType(); MyMwcStartSessionRequestTypeEnum? newSessionType = sessionType.HasValue ? sessionType.Value : MyGuiScreenGamePlay.Static.GetSessionType(); MyGuiScreenGamePlayType? previousGameplaytype = MyGuiScreenGamePlay.Static != null ? MyGuiScreenGamePlay.Static.GetPreviousGameType() : (MyGuiScreenGamePlayType?)null; MyMissionID? previousMissionToStart = MyGuiScreenGamePlay.Static != null ? MyGuiScreenGamePlay.Static.m_missionToStart : (MyMissionID?)null; var newGameplayScreen = new MyGuiScreenGamePlay(newGameplayType, previousGameplaytype, checkpoint.CurrentSector, checkpoint.SectorObjectBuilder.Version, newSessionType); newGameplayScreen.m_missionToStart = previousMissionToStart; if (travelType.HasValue) newGameplayScreen.m_travelReason = travelType.Value; var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static); loadScreen.AddEnterSectorResponse(checkpoint, startMission); /* if (MyConfig.NeedShowPerfWarning) { MyGuiScreenPerformanceWarning perfWarningScreen = new MyGuiScreenPerformanceWarning(loadScreen); perfWarningScreen.Closed += delegate { MyGuiManager.AddScreen(loadScreen); }; MyGuiManager.AddScreen(perfWarningScreen); } else*/ { MyGuiManager.AddScreen(loadScreen); } return loadScreen; }
private void NewGameSectorLoaded(MyMwcObjectBuilder_Checkpoint checkpoint, byte[] sectorData, MyMissionID missionId) { checkpoint.SectorObjectBuilder = MyMwcObjectBuilder_Base.FromBytes<MyMwcObjectBuilder_Sector>(sectorData); // Save sector to cache MyLocalCache.Save(null, checkpoint.SectorObjectBuilder, checkpoint.CurrentSector); checkpoint.CurrentSector.UserId = MyClientServer.LoggedPlayer.GetUserId(); //TODO: should this be send by server? ReloadGameplayNewGame(checkpoint, missionId); }
//public void SetControlsChange(bool Value) //{ // m_controlsChange = Value; //} //public bool GetControlsChange() //{ // return m_controlsChange; //} public void AddEnterSectorResponse(MyMwcObjectBuilder_Checkpoint checkpoint, MyMissionID? missionToStart) { m_checkpoint = checkpoint; if (missionToStart != null) { m_missionToStart = missionToStart; } }
private void ReloadGameplayNewGame(MyMwcObjectBuilder_Checkpoint checkpoint, MyMissionID missionId) { MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, MyMwcStartSessionRequestTypeEnum.NEW_STORY, MyGuiScreenGamePlayType.GAME_STORY, missionId, MyMwcTravelTypeEnum.SOLAR); }
public static List<MyMwcObjectBuilder_Base> FindMissingObjectBuilders(MyMwcObjectBuilder_Checkpoint checkpointToSave) { var result = new List<MyMwcObjectBuilder_Base>(); // Fill dictionary with loaded objects var loaded = new Dictionary<uint, MyMwcObjectBuilder_Base>(); GetObjects(m_lastLoadedCheckpoint, loaded); // Fill dictionary with saved objects var saved = new Dictionary<uint, MyMwcObjectBuilder_Base>(); GetObjects(checkpointToSave, saved); // Removed saved objects from loaded dict foreach (var savedObject in saved) { loaded.Remove(savedObject.Key); } // Loaded now contains objects which were not saved result.AddRange(loaded.Values); return result; }
public static MyGuiScreenLoading StartJoinMultiplayerSession(MyGameTypes gameType, MyGameplayDifficultyEnum difficulty, MyMwcObjectBuilder_Checkpoint checkpoint) { // Temporary MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); return MySession.Static.JoinMultiplayerSession(gameType, checkpoint); }
private static CommonLIB.AppCode.ObjectBuilders.SubObjects.MyMwcObjectBuilder_Event GetLastEvent(MyMwcObjectBuilder_Checkpoint chapter) { var lastEvent = chapter.EventLogObjectBuilder.Where(e => e.EventType == (int)EventTypeEnum.SubmissionFinished).OrderByDescending(e => e.Time).FirstOrDefault(); return lastEvent; }
private MyGuiScreenLoading JoinMultiplayerSession(MyGameTypes gameType, MyMwcObjectBuilder_Checkpoint checkpoint) { MyMultiplayerGameplay.Static.IsHost = false; //var checkpoint = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.Checkpoint, null) as MyMwcObjectBuilder_Checkpoint; // This is just dummy ship for load //var ship = MyMwcObjectBuilder_SmallShip_Player.CreateDefaultShip(MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG, MySession.Static.Player.Faction); MySession.Static.Player.Faction = checkpoint.PlayerObjectBuilder.ShipObjectBuilder.Faction; MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static); MyGuiScreenGamePlayType? gameplayType = null; MyMwcStartSessionRequestTypeEnum? sessionType = null; switch (gameType) { case MyGameTypes.Story: gameplayType = MyGuiScreenGamePlayType.GAME_STORY; sessionType = MyMwcStartSessionRequestTypeEnum.JOIN_FRIEND_STORY; break; case MyGameTypes.Deathmatch: gameplayType = MyGuiScreenGamePlayType.GAME_SANDBOX; sessionType = MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS; break; default: break; } return MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, sessionType, gameplayType); }
public void AddEnterSectorResponse(MyMwcObjectBuilder_Checkpoint checkpoint, MyMissionID? missionID) { m_screenToLoad.AddEnterSectorResponse(checkpoint, missionID); }
void UpdateSmallshipsOfferedByVendors(MyMwcObjectBuilder_Checkpoint checkpoint) { if (m_checkpoint.SectorObjectBuilder.SectorObjects == null) return; MyMwcLog.WriteLine("UpdateSmallshipsOfferedByVendors - START"); foreach (var ob in m_checkpoint.SectorObjectBuilder.SectorObjects) { MyMwcObjectBuilder_PrefabContainer prefabContainer = ob as MyMwcObjectBuilder_PrefabContainer; if (prefabContainer != null) { foreach (var prefab in prefabContainer.Prefabs) { MyMwcObjectBuilder_PrefabHangar hangar = prefab as MyMwcObjectBuilder_PrefabHangar; if (hangar != null) { //check smallships contained in this vendor if (prefabContainer.Inventory != null) { foreach (var inventoryItem in prefabContainer.Inventory.InventoryItems) { MyMwcObjectBuilder_SmallShip_Player playerShip = inventoryItem.ItemObjectBuilder as MyMwcObjectBuilder_SmallShip_Player; if (playerShip != null) { var shipType = playerShip.ShipType; inventoryItem.ItemObjectBuilder = MyMwcObjectBuilder_SmallShip_Player.CreateDefaultShip(shipType, playerShip.Faction, MyShipTypeConstants.GetShipTypeProperties(shipType).GamePlay.CargoCapacity); } } } } } } } MyMwcLog.WriteLine("UpdateSmallshipsOfferedByVendors - END"); }