From 6f3a7d7c649295df342ebaf894e6af8defb1e8af Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 9 Oct 2018 10:56:31 +0200 Subject: [PATCH] Added comments for OnRebuildObservers return value and adjusted NetworkProximityChecker to make this less weird. --- Mirror/Runtime/NetworkBehaviour.cs | 2 ++ Mirror/Runtime/NetworkProximityChecker.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Mirror/Runtime/NetworkBehaviour.cs b/Mirror/Runtime/NetworkBehaviour.cs index ee9fc6a94..e58b7067c 100644 --- a/Mirror/Runtime/NetworkBehaviour.cs +++ b/Mirror/Runtime/NetworkBehaviour.cs @@ -571,6 +571,8 @@ public virtual void OnStopAuthority() { } + // return true when overwriting so that Mirror knows that we wanted to + // rebuild observers ourselves. otherwise it uses built in rebuild. public virtual bool OnRebuildObservers(HashSet observers, bool initialize) { return false; diff --git a/Mirror/Runtime/NetworkProximityChecker.cs b/Mirror/Runtime/NetworkProximityChecker.cs index 6cc3c2546..8e7d2c495 100644 --- a/Mirror/Runtime/NetworkProximityChecker.cs +++ b/Mirror/Runtime/NetworkProximityChecker.cs @@ -56,6 +56,8 @@ public override bool OnCheckObserver(NetworkConnection newObserver) return false; } + // return true when overwriting so that Mirror knows that we wanted to + // rebuild observers ourselves. otherwise it uses built in rebuild. public override bool OnRebuildObservers(HashSet observers, bool initial) { if (forceHidden) @@ -87,7 +89,7 @@ public override bool OnRebuildObservers(HashSet observers, bo observers.Add(uv.connectionToClient); } } - return true; + break; } case CheckMethod.Physics2D: @@ -105,10 +107,11 @@ public override bool OnRebuildObservers(HashSet observers, bo observers.Add(uv.connectionToClient); } } - return true; + break; } } - return false; + + return true; } // called hiding and showing objects on the host