- rename WorldObjectsToUnityObjects

- remove unneeded checks in GetWorldObject
This commit is contained in:
JohnCorby 2022-01-25 18:13:34 -08:00
parent a10c850a67
commit 733eb0088c

View File

@ -98,7 +98,7 @@ namespace QSB.WorldSync
}
WorldObjects.Clear();
WorldObjectsToUnityObjects.Clear();
UnityObjectsToWorldObjects.Clear();
foreach (var manager in Managers)
{
@ -114,7 +114,7 @@ namespace QSB.WorldSync
public static List<FactReveal> ShipLogFacts { get; } = new();
private static readonly List<IWorldObject> WorldObjects = new();
private static readonly Dictionary<MonoBehaviour, IWorldObject> WorldObjectsToUnityObjects = new();
private static readonly Dictionary<MonoBehaviour, IWorldObject> UnityObjectsToWorldObjects = new();
private static void GameInit()
{
@ -188,24 +188,12 @@ namespace QSB.WorldSync
return default;
}
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Trying to run GetWorldFromUnity while not in multiplayer! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Warning);
return default;
}
if (!WorldObjectsToUnityObjects.TryGetValue(unityObject, out var worldObject))
if (!UnityObjectsToWorldObjects.TryGetValue(unityObject, out var worldObject))
{
DebugLog.ToConsole($"Error - WorldObjectsToUnityObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
return default;
}
if (worldObject == null)
{
DebugLog.ToConsole($"Error - World object for unity object {unityObject.name} is null! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
return default;
}
return (TWorldObject)worldObject;
}
@ -253,7 +241,7 @@ namespace QSB.WorldSync
obj.Init();
WorldObjects.Add(obj);
WorldObjectsToUnityObjects.Add(item, obj);
UnityObjectsToWorldObjects.Add(item, obj);
}
}
@ -279,7 +267,7 @@ namespace QSB.WorldSync
obj.Init();
WorldObjects.Add(obj);
WorldObjectsToUnityObjects.Add(item, obj);
UnityObjectsToWorldObjects.Add(item, obj);
}
}