private static void TryPause() { if (!MyMinerGame.IsPaused() && MyGuiScreenGamePlay.Static != null) { MyMinerGame.SwitchPause(); } }
void ValidateAllMissionsStartingFrom(int index) { var allMissions = MyMissions.Missions.Values.OfType <MyMission>().ToList(); if (index >= allMissions.Count) { return; } var mission = allMissions[index]; MyMissionID missionId = mission.ID; // each mission is automatically validated after start MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static); var startSessionScreen = new MyGuiScreenStartSessionProgress(MyMwcStartSessionRequestTypeEnum.NEW_STORY, MyTextsWrapperEnum.StartGameInProgressPleaseWait, null, MyGameplayDifficultyEnum.EASY, null, null); startSessionScreen.OnSuccessEnter = new Action <MyGuiScreenGamePlayType, MyMwcStartSessionRequestTypeEnum, MyMwcObjectBuilder_Checkpoint>((screenType, sessionType, checkpoint) => { Action <MyMwcObjectBuilder_Sector, Vector3> enterSuccessAction = new Action <MyMwcObjectBuilder_Sector, Vector3>((sector, newPosition) => { MyMwcVector3Int sectorPosition; sectorPosition = sector.Position; MyMwcSectorIdentifier newSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, MyClientServer.LoggedPlayer.GetUserId(), sectorPosition, null); var newScreen = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.GAME_STORY, null, newSectorIdentifier, sector.Version, MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT); var loadScreen = new MyGuiScreenLoading(newScreen, MyGuiScreenGamePlay.Static); newScreen.OnGameReady += new ScreenHandler((screen) => { ((MyMission)MyMissions.GetMissionByID(missionId)).Accept(); ValidateAllMissionsStartingFrom(index + 1); // validate the next mission }); loadScreen.AnnounceLeaveToServer = true; loadScreen.LeaveSectorReason = MyMwcLeaveSectorReasonEnum.TRAVEL; // Current sector and sector object builder has changed checkpoint.ActiveMissionID = -1; // Manually deactivate mission checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position = newPosition; checkpoint.EventLogObjectBuilder.Clear(); // Or just clear mission start/finish // Make prereq missions completed foreach (var prereq in mission.RequiredMissions) { var start = new MyEventLogEntry() { EventType = EventTypeEnum.MissionStarted, EventTypeID = (int)prereq }.GetObjectBuilder(); var end = new MyEventLogEntry() { EventType = EventTypeEnum.MissionFinished, EventTypeID = (int)prereq }.GetObjectBuilder(); checkpoint.EventLogObjectBuilder.Add(start); checkpoint.EventLogObjectBuilder.Add(end); } checkpoint.SectorObjectBuilder = sector; checkpoint.CurrentSector.Position = sector.Position; loadScreen.AddEnterSectorResponse(checkpoint, missionId); MyGuiManager.AddScreen(loadScreen); if (MyMinerGame.IsPaused()) { MyMinerGame.SwitchPause(); } }); // Load neighbouring sector MyGuiManager.AddScreen(new MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum.SOLAR, mission.Location.Sector, Vector3.Zero, enterSuccessAction)); //var newGameplayScreen = new MyGuiScreenGamePlay(screenType, null, checkpoint.CurrentSector, sessionType); //var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static); //loadScreen.AddEnterSectorResponse(checkpoint); //MyGuiManager.AddScreen(loadScreen); }); MyGuiManager.AddScreen(startSessionScreen); }