diff --git a/Assets/Mirror/Editor/Weaver/WeaverTypes.cs b/Assets/Mirror/Editor/Weaver/WeaverTypes.cs index 4e538a187..1224012ec 100644 --- a/Assets/Mirror/Editor/Weaver/WeaverTypes.cs +++ b/Assets/Mirror/Editor/Weaver/WeaverTypes.cs @@ -102,8 +102,8 @@ public WeaverTypes(AssemblyDefinition assembly, Logger Log, ref bool WeavingFail syncVarNetworkIdentityEqualReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SyncVarNetworkIdentityEqual", ref WeavingFailed); syncVarGameObjectEqualReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SyncVarGameObjectEqual", ref WeavingFailed); setSyncVarReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SetSyncVar", ref WeavingFailed); - setSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "setSyncVarHookGuard", ref WeavingFailed); - getSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "getSyncVarHookGuard", ref WeavingFailed); + setSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SetSyncVarHookGuard", ref WeavingFailed); + getSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "GetSyncVarHookGuard", ref WeavingFailed); setSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SetSyncVarGameObject", ref WeavingFailed); getSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "GetSyncVarGameObject", ref WeavingFailed); diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index 0f631282d..f48dd0dbb 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -74,13 +74,14 @@ public abstract class NetworkBehaviour : MonoBehaviour ulong syncVarHookGuard; // USED BY WEAVER to set syncvars in host mode without deadlocking - protected bool getSyncVarHookGuard(ulong dirtyBit) - { - return (syncVarHookGuard & dirtyBit) != 0UL; - } + protected bool GetSyncVarHookGuard(ulong dirtyBit) => + (syncVarHookGuard & dirtyBit) != 0UL; + + [Obsolete("Renamed to GetSyncVarHookGuard (uppercase)")] + protected bool getSyncVarHookGuard(ulong dirtyBit) => GetSyncVarHookGuard(dirtyBit); // USED BY WEAVER to set syncvars in host mode without deadlocking - protected void setSyncVarHookGuard(ulong dirtyBit, bool value) + protected void SetSyncVarHookGuard(ulong dirtyBit, bool value) { if (value) syncVarHookGuard |= dirtyBit; @@ -88,6 +89,9 @@ protected void setSyncVarHookGuard(ulong dirtyBit, bool value) syncVarHookGuard &= ~dirtyBit; } + [Obsolete("Renamed to SetSyncVarHookGuard (uppercase)")] + protected void setSyncVarHookGuard(ulong dirtyBit, bool value) => SetSyncVarHookGuard(dirtyBit, value); + // SyncLists, SyncSets, etc. protected readonly List syncObjects = new List(); @@ -271,7 +275,7 @@ protected bool SyncVarGameObjectEqual(GameObject newGameObject, uint netIdField) // helper function for [SyncVar] GameObjects. protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, ulong dirtyBit, ref uint netIdField) { - if (getSyncVarHookGuard(dirtyBit)) + if (GetSyncVarHookGuard(dirtyBit)) return; uint newNetId = 0; @@ -334,7 +338,7 @@ protected bool SyncVarNetworkIdentityEqual(NetworkIdentity newIdentity, uint net // helper function for [SyncVar] NetworkIdentities. protected void SetSyncVarNetworkIdentity(NetworkIdentity newIdentity, ref NetworkIdentity identityField, ulong dirtyBit, ref uint netIdField) { - if (getSyncVarHookGuard(dirtyBit)) + if (GetSyncVarHookGuard(dirtyBit)) return; uint newNetId = 0; @@ -391,7 +395,7 @@ protected bool SyncVarNetworkBehaviourEqual(T newBehaviour, NetworkBehaviourS // helper function for [SyncVar] NetworkIdentities. protected void SetSyncVarNetworkBehaviour(T newBehaviour, ref T behaviourField, ulong dirtyBit, ref NetworkBehaviourSyncVar syncField) where T : NetworkBehaviour { - if (getSyncVarHookGuard(dirtyBit)) + if (GetSyncVarHookGuard(dirtyBit)) return; uint newNetId = 0; diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs index 50db1895d..6b35c0094 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs @@ -974,15 +974,15 @@ public void HookGuard() ulong bit = 1ul << i; // should be false by default - Assert.That(getSyncVarHookGuard(bit), Is.False); + Assert.That(GetSyncVarHookGuard(bit), Is.False); // set true - setSyncVarHookGuard(bit, true); - Assert.That(getSyncVarHookGuard(bit), Is.True); + SetSyncVarHookGuard(bit, true); + Assert.That(GetSyncVarHookGuard(bit), Is.True); // set false again - setSyncVarHookGuard(bit, false); - Assert.That(getSyncVarHookGuard(bit), Is.False); + SetSyncVarHookGuard(bit, false); + Assert.That(GetSyncVarHookGuard(bit), Is.False); } } }