!BROKEN!!!

This commit is contained in:
Aaro Varis
2025-03-23 19:59:59 +02:00
parent 143505f762
commit 3d879a605d
4 changed files with 21 additions and 12 deletions

View File

@@ -39,7 +39,7 @@ namespace BoneSync.Data
}
}
internal static class SyncDebugUI
/*internal static class SyncDebugUI
{
public static Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
public static Text debugText;
@@ -93,5 +93,5 @@ namespace BoneSync.Data
}
debugText.text = sb.ToString();
}
}
}*/
}

View File

@@ -55,15 +55,21 @@ namespace BoneSync.Patching
// SceneZone and PlayerTrigger patches are based on the ones from entanglement mod
[HarmonyPatch(typeof(SceneZone))]
public static class SceneZonePatch
{
public static bool IsChildOfLocalRigRoot(Transform transform)
{
if (PlayerRig.localRigRoot == null) return false;
return transform.IsChildOf(PlayerRig.localRigRoot);
}
/*[HarmonyPatch(nameof(SceneZone.OnTriggerEnter)), HarmonyPrefix]
public static bool EnterPrefix(SceneZone __instance, Collider other)
{
if (other.CompareTag("Player"))
{
return other.transform.IsChildOf(PlayerRig.localRigRoot);
return IsChildOfLocalRigRoot(other.transform);
}
return true;
@@ -74,7 +80,7 @@ namespace BoneSync.Patching
{
if (other.CompareTag("Player"))
{
return other.transform.IsChildOf(PlayerRig.localRigRoot);
return IsChildOfLocalRigRoot(other.transform);
}
return true;
@@ -104,8 +110,7 @@ namespace BoneSync.Patching
{
if (other.CompareTag("Player"))
{
return other.transform.IsChildOf(PlayerRig.localRigRoot);
return SceneZonePatch.IsChildOfLocalRigRoot(other.transform);
}
return true;

View File

@@ -83,6 +83,8 @@ namespace BoneSync.Sync.Components
public bool isStale => Time.realtimeSinceStartup - _lastSyncTime > 5f;
public bool isOwner => _ownerId == BoneSync.lobby.GetLocalId();
public bool isValid => this != null && gameObject != null;
public void SetInHolster(bool val)
{
SyncLogger.Msg(transform.GetPath() + " hosterState:" + val);
@@ -171,6 +173,7 @@ namespace BoneSync.Sync.Components
public string GetSyncableWorldPath()
{
if (!isValid) return "";
if (transform == null) return "";
if (poolee && poolee.pool)
{
@@ -187,6 +190,7 @@ namespace BoneSync.Sync.Components
public void FindAndUpdateComponents()
{
if (!isValid) return;
ObjectSyncCache.RemoveSyncable(this);
pullDevice = GetComponent<PullDevice>();
@@ -266,17 +270,17 @@ namespace BoneSync.Sync.Components
private void _DiscardSyncable(bool force, bool despawn)
{
if (!this) return; // if object is destroyed, don't do anything
if (!isValid) return; // if object is destroyed, don't do anything
bool isRegistered = Registered;
SyncLogger.Debug("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + IsPlugged());
//SyncLogger.Debug("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + IsPlugged());
if (isRegistered)
{
bool isPlugged = IsPlugged();
bool canDiscard = isOwner && (!isPlugged || force); // only owner can discard
//SyncLogger.Msg("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + isPlugged + " canDiscard:" + canDiscard);
SyncLogger.Debug("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + isPlugged + " canDiscard:" + canDiscard);
//SyncLogger.Warning("Discarding registered syncable: " + transform.GetPath() + " force: " + force);
if (canDiscard)

View File

@@ -125,7 +125,7 @@ namespace BoneSync.Sync.Components
}
private void SetKinematic(bool kinematic)
{
if (!this) return;
if (!isValid) return;
try
{
_SetKinematic(kinematic);