mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-07 13:05:41 +00:00
Merge branch 'dev' into model-ship-sync
This commit is contained in:
commit
393b52d1c8
@ -269,6 +269,26 @@ public static class QSBWorldSync
|
|||||||
return (TWorldObject)worldObject;
|
return (TWorldObject)worldObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryGetWorldObject<TWorldObject>(this MonoBehaviour unityObject, out TWorldObject worldObject)
|
||||||
|
where TWorldObject : IWorldObject
|
||||||
|
{
|
||||||
|
if (!unityObject)
|
||||||
|
{
|
||||||
|
DebugLog.ToConsole($"Error - Trying to run GetWorldFromUnity with a null unity object! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:NULL, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||||
|
worldObject = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UnityObjectsToWorldObjects.TryGetValue(unityObject, out var iWorldObject))
|
||||||
|
{
|
||||||
|
worldObject = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldObject = (TWorldObject)iWorldObject;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// not deterministic across platforms.
|
/// not deterministic across platforms.
|
||||||
/// iterates thru all objects and throws error if there isn't exactly 1.
|
/// iterates thru all objects and throws error if there isn't exactly 1.
|
||||||
|
Loading…
Reference in New Issue
Block a user