mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkIdentity.RebuildObservers: GetNewObservers code split into separate function
This commit is contained in:
parent
e00e8195bb
commit
01f5fb4a94
@ -971,6 +971,21 @@ internal void AddObserver(NetworkConnection conn)
|
||||
conn.AddToVisList(this);
|
||||
}
|
||||
|
||||
// helper function to call OnRebuildObservers in all components
|
||||
// -> HashSet is passed in so we can cache it!
|
||||
internal bool GetNewObservers(HashSet<NetworkConnection> observersSet, bool initialize)
|
||||
{
|
||||
bool result = false;
|
||||
observersSet.Clear();
|
||||
|
||||
foreach (NetworkBehaviour comp in NetworkBehaviours)
|
||||
{
|
||||
result |= comp.OnRebuildObservers(observersSet, initialize);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static readonly HashSet<NetworkConnection> newObservers = new HashSet<NetworkConnection>();
|
||||
|
||||
/// <summary>
|
||||
@ -983,15 +998,9 @@ public void RebuildObservers(bool initialize)
|
||||
return;
|
||||
|
||||
bool changed = false;
|
||||
bool result = false;
|
||||
|
||||
newObservers.Clear();
|
||||
|
||||
// call OnRebuildObservers function in components
|
||||
foreach (NetworkBehaviour comp in NetworkBehaviours)
|
||||
{
|
||||
result |= comp.OnRebuildObservers(newObservers, initialize);
|
||||
}
|
||||
// call OnRebuildObservers function in all components
|
||||
bool result = GetNewObservers(newObservers, initialize);
|
||||
|
||||
// if player connection: ensure player always see himself no matter what.
|
||||
// -> fixes https://github.com/vis2k/Mirror/issues/692 where a
|
||||
|
Loading…
Reference in New Issue
Block a user