Added comments for OnRebuildObservers return value and adjusted NetworkProximityChecker to make this less weird.

This commit is contained in:
vis2k 2018-10-09 10:56:31 +02:00
parent 3f9a423258
commit 277f18280e
2 changed files with 37 additions and 29 deletions

View File

@ -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<NetworkConnection> observers, bool initialize)
{
return false;

View File

@ -58,6 +58,7 @@ public override bool OnCheckObserver(NetworkConnection newObserver)
public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bool initial)
{
// only add self as observer if force hidden
if (forceHidden)
{
// ensure player can still see themself
@ -66,9 +67,10 @@ public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bo
{
observers.Add(uv.connectionToClient);
}
return true;
}
// otherwise add everyone in proximity
else
{
// find players within range
switch (checkMethod)
{
@ -87,7 +89,7 @@ public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bo
observers.Add(uv.connectionToClient);
}
}
return true;
break;
}
case CheckMethod.Physics2D:
@ -105,11 +107,15 @@ public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bo
observers.Add(uv.connectionToClient);
}
}
break;
}
}
}
// always return true when overwriting OnRebuildObservers so that
// Mirror knows not to use the built in rebuild method.
return true;
}
}
return false;
}
// called hiding and showing objects on the host
public override void OnSetLocalVisibility(bool vis)