From 43d5ebdd355cb096e3c4e5c0735a168caf6313c3 Mon Sep 17 00:00:00 2001 From: hyperion51 Date: Fri, 17 Apr 2020 01:38:48 +0100 Subject: [PATCH] Game Context Hotfix --- Assets/Scripts/ServerShared/GameContext.cs | 3 ++- Assets/Scripts/StrategyGameManager.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/ServerShared/GameContext.cs b/Assets/Scripts/ServerShared/GameContext.cs index ab1c761b5..bb72518e0 100644 --- a/Assets/Scripts/ServerShared/GameContext.cs +++ b/Assets/Scripts/ServerShared/GameContext.cs @@ -56,7 +56,7 @@ public class GameContext var planetsData = zoneData.Planets.Select(id => Cache.Get(id)).ToArray(); var planetEntities = planetsData.ToDictionary(p => p, - p => new OrbitalEntity(this, Enumerable.Empty(), Enumerable.Empty(), p.Orbit)); + p => new OrbitalEntity(this, Enumerable.Empty(), Enumerable.Empty(), p.Belt ? Cache.Get(p.Orbit).Parent : p.Orbit)); foreach(var kvp in planetEntities) contents.Add(kvp.Key, kvp.Value); @@ -73,6 +73,7 @@ public class GameContext public void Update() { + OrbitalEntity.ClearOrbits(); foreach (var kvp in ZoneContents) { var zone = kvp.Key; diff --git a/Assets/Scripts/StrategyGameManager.cs b/Assets/Scripts/StrategyGameManager.cs index 427ceb97e..200da36cc 100644 --- a/Assets/Scripts/StrategyGameManager.cs +++ b/Assets/Scripts/StrategyGameManager.cs @@ -107,7 +107,7 @@ public class StrategyGameManager : MonoBehaviour if (_currentTab == ZoneTabButton) { - if (_populatedZone != _selectedZone) + if (_populatedZone != _selectedZone && _cache.Get(_selectedZone) != null) PopulateZone(); Camera.transform.position = -Vector3.forward; } @@ -129,8 +129,11 @@ public class StrategyGameManager : MonoBehaviour private void Update() { - _context.Time = Time.time; - _context.Update(); + if (_context != null) + { + _context.Time = Time.time; + _context.Update(); + } if (_currentTab == GalaxyTabButton) { _galaxyCameraPos = Camera.transform.position;