mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 12:32:55 +00:00
make UnityObjectsToWorldObjects back to 1 to 1 map instead of 1 to many
This commit is contained in:
parent
931d570a10
commit
044fdfae6d
@ -159,7 +159,7 @@ public static class QSBWorldSync
|
|||||||
public static readonly List<FactReveal> ShipLogFacts = new();
|
public static readonly List<FactReveal> ShipLogFacts = new();
|
||||||
|
|
||||||
private static readonly List<IWorldObject> WorldObjects = new();
|
private static readonly List<IWorldObject> WorldObjects = new();
|
||||||
private static readonly Dictionary<MonoBehaviour, List<IWorldObject>> UnityObjectsToWorldObjects = new();
|
private static readonly Dictionary<MonoBehaviour, IWorldObject> UnityObjectsToWorldObjects = new();
|
||||||
|
|
||||||
private static void GameInit()
|
private static void GameInit()
|
||||||
{
|
{
|
||||||
@ -223,19 +223,13 @@ public static class QSBWorldSync
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UnityObjectsToWorldObjects.TryGetValue(unityObject, out var worldObjects))
|
if (!UnityObjectsToWorldObjects.TryGetValue(unityObject, out var worldObject))
|
||||||
{
|
|
||||||
DebugLog.ToConsole($"Error - WorldObjectsToUnityObjects does not contain any WorldObjects for given TUnityObject! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!worldObjects.Any(x => x is TWorldObject))
|
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"Error - UnityObjectsToWorldObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
DebugLog.ToConsole($"Error - UnityObjectsToWorldObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TWorldObject)worldObjects.First(x => x is TWorldObject);
|
return (TWorldObject)worldObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -310,13 +304,10 @@ public static class QSBWorldSync
|
|||||||
where TUnityObject : MonoBehaviour
|
where TUnityObject : MonoBehaviour
|
||||||
{
|
{
|
||||||
WorldObjects.Add(worldObject);
|
WorldObjects.Add(worldObject);
|
||||||
if (!UnityObjectsToWorldObjects.ContainsKey(unityObject))
|
if (!UnityObjectsToWorldObjects.TryAdd(unityObject, worldObject))
|
||||||
{
|
{
|
||||||
UnityObjectsToWorldObjects.Add(unityObject, new() { worldObject });
|
DebugLog.ToConsole($"Error - UnityObjectsToWorldObjects already contains \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||||
}
|
return;
|
||||||
else
|
|
||||||
{
|
|
||||||
UnityObjectsToWorldObjects[unityObject].Add(worldObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var task = UniTask.Create(async () =>
|
var task = UniTask.Create(async () =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user