using OWML.Common; using QSB.ItemSync.WorldObjects; using QSB.Utility; using QSB.WorldSync; using UnityEngine; namespace QSB.ItemSync { internal class ItemManager : WorldObjectManager { protected override void RebuildWorldObjects(OWScene scene) { DebugLog.DebugWrite("Rebuilding OWItems...", MessageType.Warning); QSBWorldSync.Init(); QSBWorldSync.Init(); QSBWorldSync.Init(); QSBWorldSync.Init(); QSBWorldSync.Init(); QSBWorldSync.Init(); QSBWorldSync.Init(); QSBWorldSync.Init(); foreach (var streaming in Resources.FindObjectsOfTypeAll()) { streaming.gameObject.AddComponent(); } foreach (var camera in Resources.FindObjectsOfTypeAll()) { camera.gameObject.AddComponent(); } foreach (var platform in Resources.FindObjectsOfTypeAll()) { platform.gameObject.AddComponent(); } } public static IQSBOWItem GetObject(OWItem unityObject) { if (unityObject == null) { DebugLog.ToConsole($"Error - Trying to run GetObject (Item) with null unity object!", MessageType.Error); return default; } IQSBOWItem worldObj = null; if (unityObject.GetType() == typeof(ScrollItem)) { worldObj = QSBWorldSync.GetWorldFromUnity((ScrollItem)unityObject); } else if (unityObject.GetType() == typeof(SharedStone)) { worldObj = QSBWorldSync.GetWorldFromUnity((SharedStone)unityObject); } else if (unityObject.GetType() == typeof(WarpCoreItem)) { worldObj = QSBWorldSync.GetWorldFromUnity((WarpCoreItem)unityObject); } else if (unityObject.GetType() == typeof(NomaiConversationStone)) { worldObj = QSBWorldSync.GetWorldFromUnity((NomaiConversationStone)unityObject); } else { DebugLog.ToConsole($"Warning - couldn't work out type of OWItem {unityObject.name}.", MessageType.Warning); } return worldObj; } public static IQSBOWItemSocket GetObject(OWItemSocket unityObject) { if (unityObject == null) { DebugLog.ToConsole($"Error - Trying to run GetObject (Socket) with null unity object!", MessageType.Error); return default; } IQSBOWItemSocket worldObj = null; if (unityObject.GetType() == typeof(ScrollSocket)) { worldObj = QSBWorldSync.GetWorldFromUnity((ScrollSocket)unityObject); } else if (unityObject.GetType() == typeof(SharedStoneSocket)) { worldObj = QSBWorldSync.GetWorldFromUnity((SharedStoneSocket)unityObject); } else if (unityObject.GetType() == typeof(WarpCoreSocket)) { worldObj = QSBWorldSync.GetWorldFromUnity((WarpCoreSocket)unityObject); } else if (unityObject.GetType() == typeof(NomaiConversationStone)) { worldObj = QSBWorldSync.GetWorldFromUnity((NomaiConversationStoneSocket)unityObject); } else { DebugLog.ToConsole($"Warning - couldn't work out type of OWItemSocket {unityObject.name}.", MessageType.Warning); } return worldObj; } } }