diff --git a/StateManagement/BuildingState/BuildingStateManager.cs b/StateManagement/BuildingState/BuildingStateManager.cs index 77d18a6..86247dd 100644 --- a/StateManagement/BuildingState/BuildingStateManager.cs +++ b/StateManagement/BuildingState/BuildingStateManager.cs @@ -27,6 +27,16 @@ namespace KCM.StateManagement.BuildingState { Observer observer = (Observer)sender; Building building = (Building)observer.state; + + if (building == null) + { + if(observer != null) + { + UnityEngine.Object.Destroy(observer.gameObject); + } + return; + } + Guid guid = building.guid; if (lastUpdateTime.ContainsKey(guid) && Time.time < lastUpdateTime[guid] + UpdateInterval) @@ -39,6 +49,8 @@ namespace KCM.StateManagement.BuildingState else lastUpdateTime[guid] = Time.time; + //Main.helper.Log("Should send building network update for: " + building.UniqueName); + new BuildingStatePacket() { customName = building.customName,