Bunch of changes
This commit is contained in:
@@ -31,23 +31,6 @@ namespace BoneSync.Sync.Components
|
||||
return "/" + current.name;
|
||||
return current.parent.GetPath() + "/" + current.name;
|
||||
}
|
||||
|
||||
public static Transform FromPath(string path)
|
||||
{
|
||||
Transform current = null;
|
||||
foreach (string name in path.Split('/'))
|
||||
{
|
||||
if (current == null)
|
||||
{
|
||||
current = GameObject.Find(name).transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
current = current.Find(name);
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
|
||||
[RegisterTypeInIl2Cpp]
|
||||
@@ -76,13 +59,26 @@ namespace BoneSync.Sync.Components
|
||||
public bool isStale => Time.time - _lastSyncTime > 5f;
|
||||
public bool isOwner => _ownerId == BoneSync.lobby.GetLocalId();
|
||||
|
||||
public bool IsHolding()
|
||||
{
|
||||
if (interactableManager)
|
||||
{
|
||||
return interactableManager.grabbedHosts.Count > 0;
|
||||
}
|
||||
if (interactableHost)
|
||||
{
|
||||
return interactableHost.isAttached;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ShouldSendSync()
|
||||
{
|
||||
if (!Registered) return false;
|
||||
if (!isOwner) return false;
|
||||
if (isStale) return true;
|
||||
|
||||
return false;
|
||||
if (AllRigidbodiesSleeping()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public ushort GetSyncId() => _syncId;
|
||||
@@ -111,13 +107,17 @@ namespace BoneSync.Sync.Components
|
||||
private AIBrain aiBrain;
|
||||
private PuppetMaster puppetMaster;
|
||||
|
||||
private SpawnFragment spawnFragment;
|
||||
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
syncablesCache[gameObject] = this;
|
||||
|
||||
FindComponents();
|
||||
|
||||
bool shouldAutoSync = CheckIfShouldAutoSync();
|
||||
if (shouldAutoSync)
|
||||
if (shouldAutoSync && BoneSync.lobby.IsHost)
|
||||
{
|
||||
MelonLogger.Msg("AutoSyncing: " + transform.GetPath());
|
||||
RegisterSyncable();
|
||||
@@ -140,7 +140,7 @@ namespace BoneSync.Sync.Components
|
||||
}
|
||||
if (interactableHost || interactableManager)
|
||||
{
|
||||
return transform.GetPath();
|
||||
return transform.GetPath().Replace(" ", "[]");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -157,6 +157,7 @@ namespace BoneSync.Sync.Components
|
||||
gun = GetComponent<Gun>();
|
||||
magazine = GetComponent<Magazine>();
|
||||
plugs = GetComponentsInChildren<Plug>();
|
||||
spawnFragment = GetComponent<SpawnFragment>();
|
||||
//rigidbodies = GetComponentsInChildren<Rigidbody>();
|
||||
UpdateTransformList();
|
||||
|
||||
@@ -165,7 +166,8 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
public bool CanBeSynced()
|
||||
{
|
||||
FindComponents();
|
||||
if (spawnFragment) return false; // if has spawn fragment, don't sync
|
||||
FindComponents();
|
||||
if (rigidbodies.Length > 0) return true;
|
||||
|
||||
return false;
|
||||
@@ -174,7 +176,7 @@ namespace BoneSync.Sync.Components
|
||||
public void OnDestroy()
|
||||
{
|
||||
DiscardSyncable();
|
||||
MelonLogger.Msg("Syncable destroyed: " + transform.GetPath());
|
||||
//MelonLogger.Msg("Syncable destroyed: " + transform.GetPath());
|
||||
}
|
||||
|
||||
public void DiscardSyncable()
|
||||
|
||||
Reference in New Issue
Block a user