2021-02-23 14:42:18 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.ItemSync.WorldObjects;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
|
|
|
|
namespace QSB.ItemSync
|
|
|
|
|
{
|
2021-03-23 13:18:29 +00:00
|
|
|
|
internal class ItemManager : WorldObjectManager
|
2021-02-23 14:42:18 +00:00
|
|
|
|
{
|
2021-03-23 13:18:29 +00:00
|
|
|
|
protected override void RebuildWorldObjects(OWScene scene)
|
2021-02-23 14:42:18 +00:00
|
|
|
|
{
|
2021-08-12 13:18:35 +00:00
|
|
|
|
DebugLog.DebugWrite("Rebuilding OWItems...", MessageType.Info);
|
2021-02-23 14:42:18 +00:00
|
|
|
|
QSBWorldSync.Init<QSBScrollSocket, ScrollSocket>();
|
2021-03-23 13:18:29 +00:00
|
|
|
|
QSBWorldSync.Init<QSBScrollItem, ScrollItem>();
|
2021-02-26 22:24:49 +00:00
|
|
|
|
QSBWorldSync.Init<QSBSharedStoneSocket, SharedStoneSocket>();
|
2021-03-23 13:18:29 +00:00
|
|
|
|
QSBWorldSync.Init<QSBSharedStone, SharedStone>();
|
2021-02-27 17:44:34 +00:00
|
|
|
|
QSBWorldSync.Init<QSBWarpCoreSocket, WarpCoreSocket>();
|
2021-03-23 13:18:29 +00:00
|
|
|
|
QSBWorldSync.Init<QSBWarpCoreItem, WarpCoreItem>();
|
2021-02-27 17:44:34 +00:00
|
|
|
|
QSBWorldSync.Init<QSBNomaiConversationStoneSocket, NomaiConversationStoneSocket>();
|
2021-03-23 13:18:29 +00:00
|
|
|
|
QSBWorldSync.Init<QSBNomaiConversationStone, NomaiConversationStone>();
|
2021-02-23 14:42:18 +00:00
|
|
|
|
}
|
2021-02-25 13:52:49 +00:00
|
|
|
|
|
|
|
|
|
public static IQSBOWItem GetObject(OWItem unityObject)
|
|
|
|
|
{
|
2021-02-25 22:45:32 +00:00
|
|
|
|
if (unityObject == null)
|
|
|
|
|
{
|
2021-03-25 20:56:26 +00:00
|
|
|
|
DebugLog.ToConsole($"Error - Trying to run GetObject (Item) with null unity object!", MessageType.Error);
|
2021-02-25 22:45:32 +00:00
|
|
|
|
return default;
|
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-02-25 13:52:49 +00:00
|
|
|
|
IQSBOWItem worldObj = null;
|
|
|
|
|
if (unityObject.GetType() == typeof(ScrollItem))
|
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBScrollItem, ScrollItem>((ScrollItem)unityObject);
|
|
|
|
|
}
|
2021-02-26 22:51:21 +00:00
|
|
|
|
else if (unityObject.GetType() == typeof(SharedStone))
|
2021-02-26 22:24:49 +00:00
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBSharedStone, SharedStone>((SharedStone)unityObject);
|
|
|
|
|
}
|
2021-02-27 17:44:34 +00:00
|
|
|
|
else if (unityObject.GetType() == typeof(WarpCoreItem))
|
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBWarpCoreItem, WarpCoreItem>((WarpCoreItem)unityObject);
|
|
|
|
|
}
|
|
|
|
|
else if (unityObject.GetType() == typeof(NomaiConversationStone))
|
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBNomaiConversationStone, NomaiConversationStone>((NomaiConversationStone)unityObject);
|
|
|
|
|
}
|
2021-02-25 13:52:49 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-02-25 22:45:32 +00:00
|
|
|
|
DebugLog.ToConsole($"Warning - couldn't work out type of OWItem {unityObject.name}.", MessageType.Warning);
|
2021-02-25 13:52:49 +00:00
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-02-25 13:52:49 +00:00
|
|
|
|
return worldObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IQSBOWItemSocket GetObject(OWItemSocket unityObject)
|
|
|
|
|
{
|
2021-02-25 22:45:32 +00:00
|
|
|
|
if (unityObject == null)
|
|
|
|
|
{
|
2021-03-25 20:56:26 +00:00
|
|
|
|
DebugLog.ToConsole($"Error - Trying to run GetObject (Socket) with null unity object!", MessageType.Error);
|
2021-02-25 22:45:32 +00:00
|
|
|
|
return default;
|
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-02-25 13:52:49 +00:00
|
|
|
|
IQSBOWItemSocket worldObj = null;
|
2021-02-25 22:45:32 +00:00
|
|
|
|
if (unityObject.GetType() == typeof(ScrollSocket))
|
2021-02-25 13:52:49 +00:00
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBScrollSocket, ScrollSocket>((ScrollSocket)unityObject);
|
|
|
|
|
}
|
2021-02-26 22:51:21 +00:00
|
|
|
|
else if (unityObject.GetType() == typeof(SharedStoneSocket))
|
2021-02-26 22:24:49 +00:00
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBSharedStoneSocket, SharedStoneSocket>((SharedStoneSocket)unityObject);
|
|
|
|
|
}
|
2021-02-27 17:44:34 +00:00
|
|
|
|
else if (unityObject.GetType() == typeof(WarpCoreSocket))
|
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBWarpCoreSocket, WarpCoreSocket>((WarpCoreSocket)unityObject);
|
|
|
|
|
}
|
2021-10-27 11:50:49 +00:00
|
|
|
|
else if (unityObject.GetType() == typeof(NomaiConversationStoneSocket))
|
2021-02-27 17:44:34 +00:00
|
|
|
|
{
|
|
|
|
|
worldObj = QSBWorldSync.GetWorldFromUnity<QSBNomaiConversationStoneSocket, NomaiConversationStoneSocket>((NomaiConversationStoneSocket)unityObject);
|
|
|
|
|
}
|
2021-02-25 13:52:49 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-02-25 22:45:32 +00:00
|
|
|
|
DebugLog.ToConsole($"Warning - couldn't work out type of OWItemSocket {unityObject.name}.", MessageType.Warning);
|
2021-02-25 13:52:49 +00:00
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-02-25 13:52:49 +00:00
|
|
|
|
return worldObj;
|
|
|
|
|
}
|
2021-02-23 14:42:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|