Ownership transfer and shit, and some pool stuff
This commit is contained in:
@@ -72,23 +72,6 @@ namespace BoneSync.Sync.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ShouldSendSync()
|
||||
{
|
||||
if (!Registered) return false;
|
||||
if (!isOwner) return false;
|
||||
if (isStale) return true;
|
||||
if (AllRigidbodiesSleeping()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public ushort GetSyncId() => _syncId;
|
||||
public void SetSyncId(ushort id)
|
||||
{
|
||||
|
||||
_syncId = id;
|
||||
ObjectSyncCache.UpdateSyncId(this);
|
||||
}
|
||||
|
||||
public InteractableHost interactableHost { private set; get; }
|
||||
public InteractableHostManager interactableManager { private set; get; }
|
||||
public Poolee poolee { private set; get; }
|
||||
@@ -117,7 +100,7 @@ namespace BoneSync.Sync.Components
|
||||
FindComponents();
|
||||
|
||||
bool shouldAutoSync = CheckIfShouldAutoSync();
|
||||
if (shouldAutoSync && BoneSync.lobby.IsHost)
|
||||
if (shouldAutoSync && (BoneSync.lobby.IsHost || ClientSpawningAllowed()))
|
||||
{
|
||||
MelonLogger.Msg("AutoSyncing: " + transform.GetPath());
|
||||
RegisterSyncable();
|
||||
@@ -181,6 +164,10 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
public void DiscardSyncable()
|
||||
{
|
||||
if (Registered)
|
||||
{
|
||||
MelonLogger.Warning("Discarding registered syncable: " + transform.GetPath());
|
||||
}
|
||||
syncablesCache.Remove(gameObject);
|
||||
ObjectSyncCache.RemoveSyncable(this);
|
||||
Destroy(this);
|
||||
@@ -188,20 +175,18 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
if (!Registered)
|
||||
{
|
||||
DiscardSyncable();
|
||||
return;
|
||||
}
|
||||
|
||||
MelonLogger.Warning("Registered Syncable disabled: " + transform.GetPath());
|
||||
DiscardSyncable();
|
||||
}
|
||||
|
||||
public void RegisterSyncable()
|
||||
{
|
||||
if (!BoneSync.lobby.IsConnected()) return;
|
||||
if (Registered)
|
||||
{
|
||||
TryBecomeOwner();
|
||||
return;
|
||||
}
|
||||
if (_attemptedRegister) return;
|
||||
if (Registered) return;
|
||||
if (!CanBeSynced()) return;
|
||||
_attemptedRegister = true;
|
||||
_SendRegisterSync();
|
||||
|
||||
Reference in New Issue
Block a user