aaaaaaaa
This commit is contained in:
@@ -16,7 +16,7 @@ namespace BoneSync.Data
|
|||||||
{
|
{
|
||||||
private static Dictionary<string, SpawnableObject> _spawnableCache = new Dictionary<string, SpawnableObject>();
|
private static Dictionary<string, SpawnableObject> _spawnableCache = new Dictionary<string, SpawnableObject>();
|
||||||
|
|
||||||
private static void _UpdateSpawnableCache()
|
public static void AddUnregisteredSpawnables()
|
||||||
{
|
{
|
||||||
Il2CppReferenceArray<UnityObject> foundSpawnables = UnityObject.FindObjectsOfTypeIncludingAssets(Il2CppType.Of<SpawnableObject>());
|
Il2CppReferenceArray<UnityObject> foundSpawnables = UnityObject.FindObjectsOfTypeIncludingAssets(Il2CppType.Of<SpawnableObject>());
|
||||||
foreach (UnityObject obj in foundSpawnables)
|
foreach (UnityObject obj in foundSpawnables)
|
||||||
@@ -50,7 +50,7 @@ namespace BoneSync.Data
|
|||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
_ClearCache();
|
_ClearCache();
|
||||||
_UpdateSpawnableCache();
|
AddUnregisteredSpawnables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ namespace BoneSync.Patching
|
|||||||
MelonLogger.Msg("Plug entered: " + __instance.name + " Plug: " + plug.name);
|
MelonLogger.Msg("Plug entered: " + __instance.name + " Plug: " + plug.name);
|
||||||
Syncable syncable = ObjectSyncCache.GetSyncable(plug);
|
Syncable syncable = ObjectSyncCache.GetSyncable(plug);
|
||||||
if (!syncable) return;
|
if (!syncable) return;
|
||||||
byte id = syncable.GetPlugId(plug);
|
byte plugId = syncable.GetPlugId(plug);
|
||||||
MelonLogger.Msg("Plug entered: " + __instance.name + " Plug: " + plug.name + " ID: " + id);
|
byte socketId = syncable.GetSocketId(__instance);
|
||||||
|
MelonLogger.Msg("Plug entered: " + __instance.transform.GetPath() + " Plug: " + plug.transform.GetPath() + " ID: " + plugId + " Socket ID: " + socketId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +34,9 @@ namespace BoneSync.Patching
|
|||||||
MelonLogger.Msg("Plug exited: " + __instance.name + " Plug: " + plug.name);
|
MelonLogger.Msg("Plug exited: " + __instance.name + " Plug: " + plug.name);
|
||||||
Syncable syncable = ObjectSyncCache.GetSyncable(plug);
|
Syncable syncable = ObjectSyncCache.GetSyncable(plug);
|
||||||
if (!syncable) return;
|
if (!syncable) return;
|
||||||
byte id = syncable.GetPlugId(plug);
|
byte plugId = syncable.GetPlugId(plug);
|
||||||
MelonLogger.Msg("Plug exited: " + __instance.name + " Plug: " + plug.name + " ID: " + id);
|
byte socketId = syncable.GetSocketId(__instance);
|
||||||
|
MelonLogger.Msg("Plug exited: " + __instance.transform.GetPath() + " Plug: " + plug.transform.GetPath() + " ID: " + plugId + " Socket ID: " + socketId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ namespace BoneSync.Sync.Components
|
|||||||
|
|
||||||
private void _DiscardSyncable(bool force, bool despawn)
|
private void _DiscardSyncable(bool force, bool despawn)
|
||||||
{
|
{
|
||||||
|
if (!this) return; // if object is destroyed, don't do anything
|
||||||
bool isRegistered = Registered;
|
bool isRegistered = Registered;
|
||||||
MelonLogger.Msg("Discarding syncable: " + transform.GetPath() + " force: " + force + " isRegistered: " + isRegistered + " despawn: " + despawn);
|
MelonLogger.Msg("Discarding syncable: " + transform.GetPath() + " force: " + force + " isRegistered: " + isRegistered + " despawn: " + despawn);
|
||||||
if (isRegistered)
|
if (isRegistered)
|
||||||
@@ -236,7 +237,7 @@ namespace BoneSync.Sync.Components
|
|||||||
|
|
||||||
ResetSyncStatus();
|
ResetSyncStatus();
|
||||||
|
|
||||||
DestroyImmediate(this); // delete the component
|
Destroy(this); // delete the component
|
||||||
|
|
||||||
if (despawn) MelonCoroutines.Start(DespawnSyncable());
|
if (despawn) MelonCoroutines.Start(DespawnSyncable());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ namespace BoneSync.Sync
|
|||||||
private static Dictionary<string, Syncable> _pathToSyncable = new Dictionary<string, Syncable>();
|
private static Dictionary<string, Syncable> _pathToSyncable = new Dictionary<string, Syncable>();
|
||||||
private static Dictionary<ushort, Syncable> _idToSyncable = new Dictionary<ushort, Syncable>();
|
private static Dictionary<ushort, Syncable> _idToSyncable = new Dictionary<ushort, Syncable>();
|
||||||
|
|
||||||
private static Dictionary<Component, Syncable> _componentToSyncable = new Dictionary<Component, Syncable>();
|
private static Dictionary<MonoBehaviour, Syncable> _componentToSyncable = new Dictionary<MonoBehaviour, Syncable>();
|
||||||
private static Dictionary<Syncable, Component[]> _syncableToComponent = new Dictionary<Syncable, Component[]>();
|
private static Dictionary<Syncable, MonoBehaviour[]> _syncableToComponent = new Dictionary<Syncable, MonoBehaviour[]>();
|
||||||
|
|
||||||
public static Dictionary<ushort, Syncable> CallbackIdToSyncable = new Dictionary<ushort, Syncable>();
|
public static Dictionary<ushort, Syncable> CallbackIdToSyncable = new Dictionary<ushort, Syncable>();
|
||||||
|
|
||||||
@@ -30,10 +30,10 @@ namespace BoneSync.Sync
|
|||||||
string ns = GetComponentNamespace(component);
|
string ns = GetComponentNamespace(component);
|
||||||
return ns.StartsWith("StressLevelZero") || ns.StartsWith("BoneSync");
|
return ns.StartsWith("StressLevelZero") || ns.StartsWith("BoneSync");
|
||||||
}
|
}
|
||||||
private static Component[] GetSLZComponents(Syncable syncable)
|
private static MonoBehaviour[] GetSLZComponents(Syncable syncable)
|
||||||
{
|
{
|
||||||
Component[] components = syncable.GetComponentsInChildren<Component>(true);
|
MonoBehaviour[] components = syncable.GetComponentsInChildren<MonoBehaviour>(true);
|
||||||
List<Component> slzComponents = new List<Component>();
|
List<MonoBehaviour> slzComponents = new List<MonoBehaviour>();
|
||||||
for (int i = 0; i < components.Length; i++)
|
for (int i = 0; i < components.Length; i++)
|
||||||
{
|
{
|
||||||
if (IsSlzComponent(components[i]))
|
if (IsSlzComponent(components[i]))
|
||||||
@@ -45,9 +45,9 @@ namespace BoneSync.Sync
|
|||||||
}
|
}
|
||||||
private static void _AddSyncableComponents(Syncable syncable)
|
private static void _AddSyncableComponents(Syncable syncable)
|
||||||
{
|
{
|
||||||
Component[] components = GetSLZComponents(syncable);
|
MonoBehaviour[] components = GetSLZComponents(syncable);
|
||||||
_syncableToComponent[syncable] = components;
|
_syncableToComponent[syncable] = components;
|
||||||
foreach (Component component in components)
|
foreach (MonoBehaviour component in components)
|
||||||
{
|
{
|
||||||
_componentToSyncable[component] = syncable;
|
_componentToSyncable[component] = syncable;
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ namespace BoneSync.Sync
|
|||||||
{
|
{
|
||||||
if (_syncableToComponent.ContainsKey(syncable))
|
if (_syncableToComponent.ContainsKey(syncable))
|
||||||
{
|
{
|
||||||
Component[] components = _syncableToComponent[syncable];
|
MonoBehaviour[] components = _syncableToComponent[syncable];
|
||||||
foreach (Component component in components)
|
foreach (MonoBehaviour component in components)
|
||||||
{
|
{
|
||||||
_componentToSyncable.Remove(component);
|
_componentToSyncable.Remove(component);
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ namespace BoneSync.Sync
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Syncable GetSyncable(Component component)
|
public static Syncable GetSyncable(MonoBehaviour component)
|
||||||
{
|
{
|
||||||
if (_componentToSyncable.ContainsKey(component))
|
if (_componentToSyncable.ContainsKey(component))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using BoneSync.Sync.Components;
|
using BoneSync.Data;
|
||||||
|
using BoneSync.Sync.Components;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using StressLevelZero.Interaction;
|
using StressLevelZero.Interaction;
|
||||||
using System;
|
using System;
|
||||||
@@ -69,6 +70,7 @@ namespace BoneSync.Sync
|
|||||||
_currentSceneName = SceneName;
|
_currentSceneName = SceneName;
|
||||||
MelonLogger.Msg("Scene initialized: " + SceneName);
|
MelonLogger.Msg("Scene initialized: " + SceneName);
|
||||||
RenameDuplicateSceneTransforms(scene);
|
RenameDuplicateSceneTransforms(scene);
|
||||||
|
SpawnableManager.AddUnregisteredSpawnables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
|
|||||||
Reference in New Issue
Block a user