From 87becdfd94218ef931b72ad7013477b6796aef47 Mon Sep 17 00:00:00 2001 From: vis2k Date: Sat, 12 Dec 2020 10:52:48 +0800 Subject: [PATCH] restore original name --- Assets/Mirror/Editor/NetworkInformationPreview.cs | 4 ++-- .../AdditiveScenes/Scripts/ShootingTankBehaviour.cs | 4 ++-- .../Runtime/InterestManagement/InterestManagement.cs | 8 ++++---- Assets/Mirror/Runtime/NetworkIdentity.cs | 6 +++--- Assets/Mirror/Runtime/NetworkServer.cs | 10 +++++----- Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs | 2 +- Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs | 6 +++--- .../Performance/Editor/NetworkIdentityPerformance.cs | 2 +- .../NetworkIdentityPerformanceWithMultipleBehaviour.cs | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Assets/Mirror/Editor/NetworkInformationPreview.cs b/Assets/Mirror/Editor/NetworkInformationPreview.cs index d552fce16..0bd3b63c3 100644 --- a/Assets/Mirror/Editor/NetworkInformationPreview.cs +++ b/Assets/Mirror/Editor/NetworkInformationPreview.cs @@ -171,7 +171,7 @@ float DrawNetworkBehaviors(NetworkIdentity identity, float initialX, float Y) float DrawObservers(NetworkIdentity identity, float initialX, float Y) { - if (identity.observersx.Count > 0) + if (identity.observers.Count > 0) { Rect observerRect = new Rect(initialX, Y + 10, 200, 20); @@ -180,7 +180,7 @@ float DrawObservers(NetworkIdentity identity, float initialX, float Y) observerRect.x += 20; observerRect.y += observerRect.height; - foreach (NetworkConnectionToClient conn in identity.observersx) + foreach (NetworkConnectionToClient conn in identity.observers) { GUI.Label(observerRect, conn.address + ":" + conn, styles.componentName); observerRect.y += observerRect.height; diff --git a/Assets/Mirror/Examples/AdditiveScenes/Scripts/ShootingTankBehaviour.cs b/Assets/Mirror/Examples/AdditiveScenes/Scripts/ShootingTankBehaviour.cs index b99856841..b97cc0510 100644 --- a/Assets/Mirror/Examples/AdditiveScenes/Scripts/ShootingTankBehaviour.cs +++ b/Assets/Mirror/Examples/AdditiveScenes/Scripts/ShootingTankBehaviour.cs @@ -23,7 +23,7 @@ void Start() void Update() { - if (isServer && netIdentity.observersx.Count > 0) + if (isServer && netIdentity.observers.Count > 0) ShootNearestPlayer(); if (isClient) @@ -36,7 +36,7 @@ void ShootNearestPlayer() GameObject target = null; float distance = 100f; - foreach (NetworkConnection networkConnection in netIdentity.observersx) + foreach (NetworkConnection networkConnection in netIdentity.observers) { GameObject tempTarget = networkConnection.identity.gameObject; float tempDistance = Vector3.Distance(tempTarget.transform.position, transform.position); diff --git a/Assets/Mirror/Runtime/InterestManagement/InterestManagement.cs b/Assets/Mirror/Runtime/InterestManagement/InterestManagement.cs index 166b10a0f..fe43c81ab 100644 --- a/Assets/Mirror/Runtime/InterestManagement/InterestManagement.cs +++ b/Assets/Mirror/Runtime/InterestManagement/InterestManagement.cs @@ -24,7 +24,7 @@ void RemoveOldObservers() foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values) { // unspawn all observers that are NOT in rebuild anymore - foreach (NetworkConnectionToClient observer in identity.observersx) + foreach (NetworkConnectionToClient observer in identity.observers) { //Debug.Log($"{identity.name} had {identity.observars.Count} observers and rebuild has {identity.rebuild.Count}"); if (!identity.rebuild.Contains(observer)) @@ -41,7 +41,7 @@ void RemoveOldObservers() // // note: IntersectWith version that returns removed values would // be even faster. - identity.observersx.IntersectWith(identity.rebuild); + identity.observers.IntersectWith(identity.rebuild); } } @@ -66,14 +66,14 @@ void AddNewObservers() foreach (NetworkConnectionToClient conn in identity.rebuild) { // was it not in old observers? - if (!identity.observersx.Contains(conn)) + if (!identity.observers.Contains(conn)) { // spawn identity for this connection //Debug.LogWarning($"Spawning {identity.name} for connectionId {conn.connectionId}"); NetworkServer.ShowForConnection(identity, conn); // add it to observers - identity.observersx.Add(conn); + identity.observers.Add(conn); } } } diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index 0a89259c3..f6de4d174 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -167,7 +167,7 @@ public sealed class NetworkIdentity : MonoBehaviour // interest management internal HashSet rebuild = new HashSet(); - public HashSet observersx = new HashSet(); + public HashSet observers = new HashSet(); // Enable to temporarily hide from players. For example, to hide a // monster while it's respawning. This way the monster still exists, @@ -1178,7 +1178,7 @@ internal void Reset() connectionToClient = null; networkBehavioursCache = null; - observersx.Clear(); + observers.Clear(); if (isLocalPlayer) { @@ -1191,7 +1191,7 @@ internal void Reset() /// internal void ServerUpdate() { - if (observersx.Count > 0) + if (observers.Count > 0) { SendUpdateVarsMessage(); } diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index 6ef2824ba..38171f94d 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -255,7 +255,7 @@ static void SendToObservers(NetworkIdentity identity, T msg, int channelId = { if (logger.LogEnabled()) logger.Log("Server.SendToObservers id:" + typeof(T)); - if (identity == null || identity.observersx.Count == 0) + if (identity == null || identity.observers.Count == 0) return; using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter()) @@ -264,7 +264,7 @@ static void SendToObservers(NetworkIdentity identity, T msg, int channelId = MessagePacker.Pack(msg, writer); ArraySegment segment = writer.ToArraySegment(); - foreach (NetworkConnectionToClient conn in identity.observersx) + foreach (NetworkConnectionToClient conn in identity.observers) { // use local connection directly because it doesn't send via transport if (conn is ULocalConnectionToClient) @@ -274,7 +274,7 @@ static void SendToObservers(NetworkIdentity identity, T msg, int channelId = conn.Send(segment, channelId); } - NetworkDiagnostics.OnSend(msg, channelId, segment.Count, identity.observersx.Count); + NetworkDiagnostics.OnSend(msg, channelId, segment.Count, identity.observers.Count); } } @@ -359,7 +359,7 @@ public static void SendToReady(NetworkIdentity identity, T msg, bool includeO { if (logger.LogEnabled()) logger.Log("Server.SendToReady msgType:" + typeof(T)); - if (identity == null || identity.observersx.Count == 0) + if (identity == null || identity.observers.Count == 0) return; using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter()) @@ -369,7 +369,7 @@ public static void SendToReady(NetworkIdentity identity, T msg, bool includeO ArraySegment segment = writer.ToArraySegment(); int count = 0; - foreach (NetworkConnectionToClient conn in identity.observersx) + foreach (NetworkConnectionToClient conn in identity.observers) { bool isOwner = conn == identity.connectionToClient; if ((!isOwner || includeOwner) && conn.isReady) diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs index 7bb8b69b2..3e8241384 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs @@ -437,7 +437,7 @@ public void SendRPCInternal() // we need an observer because sendrpc sends to ready observers // creates observers identity.OnStartServer(); - identity.observersx.Add(connectionToServer.connectionToClient); + identity.observers.Add(connectionToServer.connectionToClient); // isServer needs to be true, otherwise we can't call rpcs Assert.That(comp.isServer, Is.True); diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs index 095a1f657..620e03f6f 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs @@ -1030,7 +1030,7 @@ public void Reset() identity.OnStartServer(); identity.connectionToClient = new NetworkConnectionToClient(1); identity.connectionToServer = new NetworkConnectionToServer(); - identity.observersx.Add(new NetworkConnectionToClient(2)); + identity.observers.Add(new NetworkConnectionToClient(2)); // mark for reset and reset identity.Reset(); @@ -1038,7 +1038,7 @@ public void Reset() Assert.That(identity.netId, Is.EqualTo(0)); Assert.That(identity.connectionToClient, Is.Null); Assert.That(identity.connectionToServer, Is.Null); - Assert.That(identity.observersx.Count, Is.EqualTo(0)); + Assert.That(identity.observers.Count, Is.EqualTo(0)); } [Test] @@ -1189,7 +1189,7 @@ public void ServerUpdate() { { MessagePacker.GetId(), ((conn, reader, channelId) => ++observerCalled) } }); - identity.observersx.Add(observer); + identity.observers.Add(observer); // set components dirty again compA.SetDirtyBit(ulong.MaxValue); diff --git a/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformance.cs b/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformance.cs index 8f891d11a..8593c54de 100644 --- a/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformance.cs +++ b/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformance.cs @@ -29,7 +29,7 @@ public void SetUp() gameObject = new GameObject(); identity = gameObject.AddComponent(); identity.connectionToClient = new FakeNetworkConnection(1); - identity.observersx.Add(identity.connectionToClient); + identity.observers.Add(identity.connectionToClient); health = gameObject.AddComponent(); health.syncMode = SyncMode.Owner; health.syncInterval = 0f; diff --git a/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformanceWithMultipleBehaviour.cs b/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformanceWithMultipleBehaviour.cs index 40f73b197..ed3db8df1 100644 --- a/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformanceWithMultipleBehaviour.cs +++ b/Assets/Mirror/Tests/Performance/Editor/NetworkIdentityPerformanceWithMultipleBehaviour.cs @@ -21,7 +21,7 @@ public void SetUp() gameObject = new GameObject(); identity = gameObject.AddComponent(); identity.connectionToClient = new FakeNetworkConnection(1); - identity.observersx.Add(identity.connectionToClient); + identity.observers.Add(identity.connectionToClient); health = new Health[healthCount]; for (int i = 0; i < healthCount; i++) {