Levels are mirrored when traveling backwards through a connection in the campaign mode. Closes #519

This commit is contained in:
Joonas Rikkonen
2018-08-08 15:30:32 +03:00
parent 99c76d0099
commit 5100956bae
5 changed files with 18 additions and 10 deletions
@@ -761,7 +761,10 @@ namespace Barotrauma.Networking
else else
{ {
if (GameMain.GameSession?.CrewManager != null) GameMain.GameSession.CrewManager.Reset(); 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); if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.UsingShuttle ? GameMain.NetLobbyScreen.SelectedShuttle : null);
@@ -190,7 +190,10 @@ namespace Barotrauma
private IEnumerable<object> LoadRound() private IEnumerable<object> 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(); GameMain.GameScreen.Select();
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
@@ -182,7 +182,7 @@ namespace Barotrauma
StartRound(randomLevel, true, loadSecondSub); 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 #if CLIENT
GameMain.LightManager.LosEnabled = GameMain.NetworkMember == null || GameMain.NetworkMember.CharacterInfo != null; GameMain.LightManager.LosEnabled = GameMain.NetworkMember == null || GameMain.NetworkMember.CharacterInfo != null;
@@ -213,8 +213,7 @@ namespace Barotrauma
if (level != null) if (level != null)
{ {
level.Generate(); level.Generate(mirrorLevel);
submarine.SetPosition(submarine.FindSpawnPos(level.StartPosition - new Vector2(0.0f, 2000.0f))); submarine.SetPosition(submarine.FindSpawnPos(level.StartPosition - new Vector2(0.0f, 2000.0f)));
} }
@@ -229,9 +228,9 @@ namespace Barotrauma
if (GameMode != null) if (GameMode != null)
{ {
GameMode.MsgBox(); GameMode.MsgBox();
if (GameMode is MultiPlayerCampaign campaign && GameMain.Server != null) if (GameMode is MultiPlayerCampaign mpCampaign && GameMain.Server != null)
{ {
campaign.CargoManager.CreateItems(); mpCampaign.CargoManager.CreateItems();
} }
} }
@@ -199,7 +199,7 @@ namespace Barotrauma
return new Level(seed, Rand.Range(30.0f, 80.0f, Rand.RandSync.Server), LevelGenerationParams.GetRandom(seed)); 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; Mirrored = mirror;
@@ -1243,7 +1243,10 @@ namespace Barotrauma.Networking
#if CLIENT #if CLIENT
if (GameMain.GameSession?.CrewManager != null) GameMain.GameSession.CrewManager.Reset(); if (GameMain.GameSession?.CrewManager != null) GameMain.GameSession.CrewManager.Reset();
#endif #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 else
{ {