From 5100956baed640d48f4b0a277af226826ab927ef Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 8 Aug 2018 15:30:32 +0300 Subject: [PATCH] Levels are mirrored when traveling backwards through a connection in the campaign mode. Closes #519 --- .../BarotraumaClient/Source/Networking/GameClient.cs | 5 ++++- .../BarotraumaClient/Source/Screens/LobbyScreen.cs | 5 ++++- .../Source/GameSession/GameSession.cs | 11 +++++------ .../BarotraumaShared/Source/Map/Levels/Level.cs | 2 +- .../BarotraumaShared/Source/Networking/GameServer.cs | 5 ++++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index c794bd446..47bc41491 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -761,7 +761,10 @@ namespace Barotrauma.Networking else { if (GameMain.GameSession?.CrewManager != null) GameMain.GameSession.CrewManager.Reset(); - GameMain.GameSession.StartRound(campaign.Map.SelectedConnection.Level, true, false); + GameMain.GameSession.StartRound(campaign.Map.SelectedConnection.Level, + reloadSub: true, + loadSecondSub: false, + mirrorLevel: campaign.Map.CurrentLocation != campaign.Map.SelectedConnection.Locations[0]); } if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.UsingShuttle ? GameMain.NetLobbyScreen.SelectedShuttle : null); diff --git a/Barotrauma/BarotraumaClient/Source/Screens/LobbyScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/LobbyScreen.cs index a8df21efa..8bd432931 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/LobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/LobbyScreen.cs @@ -190,7 +190,10 @@ namespace Barotrauma private IEnumerable LoadRound() { - GameMain.GameSession.StartRound(campaignUI.SelectedLevel, true); + GameMain.GameSession.StartRound(campaignUI.SelectedLevel, + reloadSub: true, + loadSecondSub: false, + mirrorLevel: GameMain.GameSession.Map.CurrentLocation != GameMain.GameSession.Map.SelectedConnection.Locations[0]); GameMain.GameScreen.Select(); yield return CoroutineStatus.Success; diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs index 91ded070f..2c8b94a96 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs @@ -182,7 +182,7 @@ namespace Barotrauma StartRound(randomLevel, true, loadSecondSub); } - public void StartRound(Level level, bool reloadSub = true, bool loadSecondSub = false) + public void StartRound(Level level, bool reloadSub = true, bool loadSecondSub = false, bool mirrorLevel = false) { #if CLIENT GameMain.LightManager.LosEnabled = GameMain.NetworkMember == null || GameMain.NetworkMember.CharacterInfo != null; @@ -210,11 +210,10 @@ namespace Barotrauma Submarine.MainSubs[1].Load(false); } } - + if (level != null) { - level.Generate(); - + level.Generate(mirrorLevel); submarine.SetPosition(submarine.FindSpawnPos(level.StartPosition - new Vector2(0.0f, 2000.0f))); } @@ -229,9 +228,9 @@ namespace Barotrauma if (GameMode != null) { GameMode.MsgBox(); - if (GameMode is MultiPlayerCampaign campaign && GameMain.Server != null) + if (GameMode is MultiPlayerCampaign mpCampaign && GameMain.Server != null) { - campaign.CargoManager.CreateItems(); + mpCampaign.CargoManager.CreateItems(); } } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs index 8c243c52e..3137b9385 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs @@ -199,7 +199,7 @@ namespace Barotrauma return new Level(seed, Rand.Range(30.0f, 80.0f, Rand.RandSync.Server), LevelGenerationParams.GetRandom(seed)); } - public void Generate(bool mirror = true) + public void Generate(bool mirror) { Mirrored = mirror; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index 6cd095e1a..30e6cc5be 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1243,7 +1243,10 @@ namespace Barotrauma.Networking #if CLIENT if (GameMain.GameSession?.CrewManager != null) GameMain.GameSession.CrewManager.Reset(); #endif - GameMain.GameSession.StartRound(campaign.Map.SelectedConnection.Level, true, teamCount > 1); + GameMain.GameSession.StartRound(campaign.Map.SelectedConnection.Level, + reloadSub: true, + loadSecondSub: teamCount > 1, + mirrorLevel: campaign.Map.CurrentLocation != campaign.Map.SelectedConnection.Locations[0]); } else {