public void AddResponse(MyMwcStartSessionResponseTypeEnum startSessionResponse, MyMwcSectorIdentifier?sectorIdentifier, MyGameplayDifficultyEnum difficulty) { MyGuiScreenGamePlayType screenType; if (startSessionResponse == MyMwcStartSessionResponseTypeEnum.OK) { MyMwcSectorTypeEnum sessionType; MyMwcSessionStateEnum sessionStartType; int? userId = null; MyMwcVector3Int?position = null; if ((m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT)) { MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.GAME_STORY; sessionType = MyMwcSectorTypeEnum.STORY; sessionStartType = m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY ? MyMwcSessionStateEnum.NEW_GAME : MyMwcSessionStateEnum.LOAD_CHECKPOINT; userId = MyClientServer.LoggedPlayer.GetUserId(); } else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX) { MySession.Static = new MySandboxSession(); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.EDITOR_SANDBOX; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor"); Debug.Assert(m_sectorIdentifier.Value.UserId == null || m_sectorIdentifier.Value.UserId == MyClientServer.LoggedPlayer.GetUserId(), "Sandbox sector user identifier must be null or same as current user"); sessionType = MyMwcSectorTypeEnum.SANDBOX; sessionStartType = MyMwcSessionStateEnum.EDITOR; userId = m_sectorIdentifier.Value.UserId; position = m_sectorIdentifier.Value.Position; } else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY) { MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.EDITOR_STORY; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor"); sessionType = MyMwcSectorTypeEnum.STORY; sessionStartType = MyMwcSessionStateEnum.EDITOR; userId = null; position = m_sectorIdentifier.Value.Position; } else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO) { MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.EDITOR_MMO; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor"); sessionType = MyMwcSectorTypeEnum.MMO; sessionStartType = MyMwcSessionStateEnum.EDITOR; userId = null; position = m_sectorIdentifier.Value.Position; } else if ( (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM)) { MySession.Static = new MySandboxSession(); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.GAME_SANDBOX; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for sandbox"); sessionType = MyMwcSectorTypeEnum.SANDBOX; sessionStartType = MyMwcSessionStateEnum.LOAD_CHECKPOINT; userId = m_sectorIdentifier.Value.UserId; position = m_sectorIdentifier.Value.Position; //if (m_sessionType != MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM) //{ // position = m_sectorIdentifier.Value.Position; //} } else { throw new NotImplementedException(); } Action <MyMwcObjectBuilder_Checkpoint> enterSuccessAction = new Action <MyMwcObjectBuilder_Checkpoint>((checkpoint) => { OnSuccessEnter(screenType, m_sessionType, checkpoint); }); MyGuiManager.AddScreen(new MyGuiScreenLoadCheckpointProgress(sessionType, sessionStartType, userId, position, m_checkpointName, enterSuccessAction)); if (m_closeAfter != null) { m_closeAfter.CloseScreenNow(); } } else { MyMwcLog.WriteLine("Error starting the session: " + startSessionResponse.ToString()); MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.StartGameFailed, MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null)); } CloseScreen(); }
public void AddResponse(MyMwcStartSessionResponseTypeEnum startSessionResponse, MyMwcSectorIdentifier? sectorIdentifier, MyGameplayDifficultyEnum difficulty) { MyGuiScreenGamePlayType screenType; if (startSessionResponse == MyMwcStartSessionResponseTypeEnum.OK) { MyMwcSectorTypeEnum sessionType; MyMwcSessionStateEnum sessionStartType; int? userId = null; MyMwcVector3Int? position = null; if ((m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT)) { MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.GAME_STORY; sessionType = MyMwcSectorTypeEnum.STORY; sessionStartType = m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY ? MyMwcSessionStateEnum.NEW_GAME : MyMwcSessionStateEnum.LOAD_CHECKPOINT; userId = MyClientServer.LoggedPlayer.GetUserId(); } else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX) { MySession.Static = new MySandboxSession(); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.EDITOR_SANDBOX; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor"); Debug.Assert(m_sectorIdentifier.Value.UserId == null || m_sectorIdentifier.Value.UserId == MyClientServer.LoggedPlayer.GetUserId(), "Sandbox sector user identifier must be null or same as current user"); sessionType = MyMwcSectorTypeEnum.SANDBOX; sessionStartType = MyMwcSessionStateEnum.EDITOR; userId = m_sectorIdentifier.Value.UserId; position = m_sectorIdentifier.Value.Position; } else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY) { MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.EDITOR_STORY; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor"); sessionType = MyMwcSectorTypeEnum.STORY; sessionStartType = MyMwcSessionStateEnum.EDITOR; userId = null; position = m_sectorIdentifier.Value.Position; } else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO) { MySession.Static = new MySinglePlayerSession(difficulty); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.EDITOR_MMO; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor"); sessionType = MyMwcSectorTypeEnum.MMO; sessionStartType = MyMwcSessionStateEnum.EDITOR; userId = null; position = m_sectorIdentifier.Value.Position; } else if ( (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM)) { MySession.Static = new MySandboxSession(); MySession.Static.Init(); screenType = MyGuiScreenGamePlayType.GAME_SANDBOX; Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for sandbox"); sessionType = MyMwcSectorTypeEnum.SANDBOX; sessionStartType = MyMwcSessionStateEnum.LOAD_CHECKPOINT; userId = m_sectorIdentifier.Value.UserId; position = m_sectorIdentifier.Value.Position; //if (m_sessionType != MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM) //{ // position = m_sectorIdentifier.Value.Position; //} } else { throw new NotImplementedException(); } Action<MyMwcObjectBuilder_Checkpoint> enterSuccessAction = new Action<MyMwcObjectBuilder_Checkpoint>((checkpoint) => { OnSuccessEnter(screenType, m_sessionType, checkpoint); }); MyGuiManager.AddScreen(new MyGuiScreenLoadCheckpointProgress(sessionType, sessionStartType, userId, position, m_checkpointName, enterSuccessAction)); if (m_closeAfter != null) m_closeAfter.CloseScreenNow(); } else { MyMwcLog.WriteLine("Error starting the session: " + startSessionResponse.ToString()); MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.StartGameFailed, MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null)); } CloseScreen(); }