mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkProximityChecker: syntax improved to simplify code
This commit is contained in:
parent
6504349fd9
commit
049a73b5a8
@ -48,21 +48,15 @@ public override bool OnCheckObserver(NetworkConnection newObserver)
|
||||
return false;
|
||||
|
||||
// this cant use newObserver.playerControllers[0]. must iterate to find a valid player.
|
||||
GameObject player = null;
|
||||
for (int i = 0; i < newObserver.playerControllers.Count; i++)
|
||||
PlayerController controller = newObserver.playerControllers.Find(
|
||||
pc => pc != null && pc.gameObject != null
|
||||
);
|
||||
if (controller != null)
|
||||
{
|
||||
var p = newObserver.playerControllers[i];
|
||||
if (p != null && p.gameObject != null)
|
||||
{
|
||||
player = p.gameObject;
|
||||
break;
|
||||
}
|
||||
GameObject player = controller.gameObject;
|
||||
return Vector3.Distance(player.transform.position, transform.position) < visRange;
|
||||
}
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
var pos = player.transform.position;
|
||||
return (pos - transform.position).magnitude < visRange;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bool initial)
|
||||
|
Loading…
Reference in New Issue
Block a user