mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
breaking: InterestManagement.OnRebuildObservers: HashSet changed to ISet to also support passing a SortedSet
This commit is contained in:
parent
8d98a42ab6
commit
50c2eab81a
@ -32,7 +32,7 @@ public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection
|
||||
return Vector3.Distance(identity.transform.position, newObserver.identity.transform.position) < range;
|
||||
}
|
||||
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnectionToClient> newObservers)
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, ISet<NetworkConnectionToClient> newObservers)
|
||||
{
|
||||
// cache range and .transform because both call GetComponent.
|
||||
int range = GetVisRange(identity);
|
||||
|
@ -137,7 +137,7 @@ public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection
|
||||
return identityNetworkMatch.matchId == newObserverNetworkMatch.matchId;
|
||||
}
|
||||
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnectionToClient> newObservers)
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, ISet<NetworkConnectionToClient> newObservers)
|
||||
{
|
||||
if (!identity.TryGetComponent<NetworkMatch>(out NetworkMatch networkMatch))
|
||||
return;
|
||||
|
@ -94,7 +94,7 @@ public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection
|
||||
return identity.gameObject.scene == newObserver.identity.gameObject.scene;
|
||||
}
|
||||
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnectionToClient> newObservers)
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, ISet<NetworkConnectionToClient> newObservers)
|
||||
{
|
||||
if (!sceneObjects.TryGetValue(identity.gameObject.scene, out HashSet<NetworkIdentity> objects))
|
||||
return;
|
||||
|
@ -52,7 +52,7 @@ public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection
|
||||
return (projected - observerProjected).sqrMagnitude <= 2;
|
||||
}
|
||||
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnectionToClient> newObservers)
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, ISet<NetworkConnectionToClient> newObservers)
|
||||
{
|
||||
// add everyone in 9 neighbour grid
|
||||
// -> pass observers to GetWithNeighbours directly to avoid allocations
|
||||
|
@ -148,7 +148,7 @@ public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection
|
||||
return identityNetworkTeam.teamId == newObserverNetworkTeam.teamId;
|
||||
}
|
||||
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnectionToClient> newObservers)
|
||||
public override void OnRebuildObservers(NetworkIdentity identity, ISet<NetworkConnectionToClient> newObservers)
|
||||
{
|
||||
// If this object doesn't have a NetworkTeam then it's visible to all clients
|
||||
if (!identity.TryGetComponent<NetworkTeam>(out NetworkTeam networkTeam))
|
||||
@ -178,7 +178,7 @@ public override void OnRebuildObservers(NetworkIdentity identity, HashSet<Networ
|
||||
newObservers.Add(networkIdentity.connectionToClient);
|
||||
}
|
||||
|
||||
void AddAllConnections(HashSet<NetworkConnectionToClient> newObservers)
|
||||
void AddAllConnections(ISet<NetworkConnectionToClient> newObservers)
|
||||
{
|
||||
foreach (NetworkConnectionToClient conn in NetworkServer.connections.Values)
|
||||
{
|
||||
|
@ -54,7 +54,9 @@ public virtual void Reset() {}
|
||||
//
|
||||
// Mirror maintains .observing automatically in the background. best of
|
||||
// both worlds without any worrying now!
|
||||
public abstract void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnectionToClient> newObservers);
|
||||
//
|
||||
// ISet<T> to support both HashSet and SortedSet.
|
||||
public abstract void OnRebuildObservers(NetworkIdentity identity, ISet<NetworkConnectionToClient> newObservers);
|
||||
|
||||
// helper function to trigger a full rebuild.
|
||||
// most implementations should call this in a certain interval.
|
||||
|
Loading…
Reference in New Issue
Block a user