!BROKEN!!!
This commit is contained in:
@@ -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 Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
||||||
public static Text debugText;
|
public static Text debugText;
|
||||||
@@ -93,5 +93,5 @@ namespace BoneSync.Data
|
|||||||
}
|
}
|
||||||
debugText.text = sb.ToString();
|
debugText.text = sb.ToString();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,15 +55,21 @@ namespace BoneSync.Patching
|
|||||||
|
|
||||||
// SceneZone and PlayerTrigger patches are based on the ones from entanglement mod
|
// SceneZone and PlayerTrigger patches are based on the ones from entanglement mod
|
||||||
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(SceneZone))]
|
[HarmonyPatch(typeof(SceneZone))]
|
||||||
public static class SceneZonePatch
|
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]
|
/*[HarmonyPatch(nameof(SceneZone.OnTriggerEnter)), HarmonyPrefix]
|
||||||
public static bool EnterPrefix(SceneZone __instance, Collider other)
|
public static bool EnterPrefix(SceneZone __instance, Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Player"))
|
if (other.CompareTag("Player"))
|
||||||
{
|
{
|
||||||
return other.transform.IsChildOf(PlayerRig.localRigRoot);
|
return IsChildOfLocalRigRoot(other.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -74,7 +80,7 @@ namespace BoneSync.Patching
|
|||||||
{
|
{
|
||||||
if (other.CompareTag("Player"))
|
if (other.CompareTag("Player"))
|
||||||
{
|
{
|
||||||
return other.transform.IsChildOf(PlayerRig.localRigRoot);
|
return IsChildOfLocalRigRoot(other.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -104,8 +110,7 @@ namespace BoneSync.Patching
|
|||||||
{
|
{
|
||||||
if (other.CompareTag("Player"))
|
if (other.CompareTag("Player"))
|
||||||
{
|
{
|
||||||
|
return SceneZonePatch.IsChildOfLocalRigRoot(other.transform);
|
||||||
return other.transform.IsChildOf(PlayerRig.localRigRoot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ namespace BoneSync.Sync.Components
|
|||||||
public bool isStale => Time.realtimeSinceStartup - _lastSyncTime > 5f;
|
public bool isStale => Time.realtimeSinceStartup - _lastSyncTime > 5f;
|
||||||
public bool isOwner => _ownerId == BoneSync.lobby.GetLocalId();
|
public bool isOwner => _ownerId == BoneSync.lobby.GetLocalId();
|
||||||
|
|
||||||
|
public bool isValid => this != null && gameObject != null;
|
||||||
|
|
||||||
public void SetInHolster(bool val)
|
public void SetInHolster(bool val)
|
||||||
{
|
{
|
||||||
SyncLogger.Msg(transform.GetPath() + " hosterState:" + val);
|
SyncLogger.Msg(transform.GetPath() + " hosterState:" + val);
|
||||||
@@ -171,6 +173,7 @@ namespace BoneSync.Sync.Components
|
|||||||
|
|
||||||
public string GetSyncableWorldPath()
|
public string GetSyncableWorldPath()
|
||||||
{
|
{
|
||||||
|
if (!isValid) return "";
|
||||||
if (transform == null) return "";
|
if (transform == null) return "";
|
||||||
if (poolee && poolee.pool)
|
if (poolee && poolee.pool)
|
||||||
{
|
{
|
||||||
@@ -187,6 +190,7 @@ namespace BoneSync.Sync.Components
|
|||||||
|
|
||||||
public void FindAndUpdateComponents()
|
public void FindAndUpdateComponents()
|
||||||
{
|
{
|
||||||
|
if (!isValid) return;
|
||||||
ObjectSyncCache.RemoveSyncable(this);
|
ObjectSyncCache.RemoveSyncable(this);
|
||||||
|
|
||||||
pullDevice = GetComponent<PullDevice>();
|
pullDevice = GetComponent<PullDevice>();
|
||||||
@@ -266,17 +270,17 @@ 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
|
if (!isValid) return; // if object is destroyed, don't do anything
|
||||||
bool isRegistered = Registered;
|
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)
|
if (isRegistered)
|
||||||
{
|
{
|
||||||
bool isPlugged = IsPlugged();
|
bool isPlugged = IsPlugged();
|
||||||
|
|
||||||
bool canDiscard = isOwner && (!isPlugged || force); // only owner can discard
|
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);
|
//SyncLogger.Warning("Discarding registered syncable: " + transform.GetPath() + " force: " + force);
|
||||||
|
|
||||||
if (canDiscard)
|
if (canDiscard)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace BoneSync.Sync.Components
|
|||||||
}
|
}
|
||||||
private void SetKinematic(bool kinematic)
|
private void SetKinematic(bool kinematic)
|
||||||
{
|
{
|
||||||
if (!this) return;
|
if (!isValid) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_SetKinematic(kinematic);
|
_SetKinematic(kinematic);
|
||||||
|
|||||||
Reference in New Issue
Block a user