mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
restore original name
This commit is contained in:
parent
02252a7756
commit
87becdfd94
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public sealed class NetworkIdentity : MonoBehaviour
|
||||
|
||||
// interest management
|
||||
internal HashSet<NetworkConnectionToClient> rebuild = new HashSet<NetworkConnectionToClient>();
|
||||
public HashSet<NetworkConnectionToClient> observersx = new HashSet<NetworkConnectionToClient>();
|
||||
public HashSet<NetworkConnectionToClient> observers = new HashSet<NetworkConnectionToClient>();
|
||||
|
||||
// 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()
|
||||
/// </summary>
|
||||
internal void ServerUpdate()
|
||||
{
|
||||
if (observersx.Count > 0)
|
||||
if (observers.Count > 0)
|
||||
{
|
||||
SendUpdateVarsMessage();
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ static void SendToObservers<T>(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<T>(NetworkIdentity identity, T msg, int channelId =
|
||||
MessagePacker.Pack(msg, writer);
|
||||
ArraySegment<byte> 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<T>(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<T>(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<T>(NetworkIdentity identity, T msg, bool includeO
|
||||
ArraySegment<byte> 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)
|
||||
|
@ -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);
|
||||
|
@ -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<UpdateVarsMessage>(), ((conn, reader, channelId) => ++observerCalled) }
|
||||
});
|
||||
identity.observersx.Add(observer);
|
||||
identity.observers.Add(observer);
|
||||
|
||||
// set components dirty again
|
||||
compA.SetDirtyBit(ulong.MaxValue);
|
||||
|
@ -29,7 +29,7 @@ public void SetUp()
|
||||
gameObject = new GameObject();
|
||||
identity = gameObject.AddComponent<NetworkIdentity>();
|
||||
identity.connectionToClient = new FakeNetworkConnection(1);
|
||||
identity.observersx.Add(identity.connectionToClient);
|
||||
identity.observers.Add(identity.connectionToClient);
|
||||
health = gameObject.AddComponent<Health>();
|
||||
health.syncMode = SyncMode.Owner;
|
||||
health.syncInterval = 0f;
|
||||
|
@ -21,7 +21,7 @@ public void SetUp()
|
||||
gameObject = new GameObject();
|
||||
identity = gameObject.AddComponent<NetworkIdentity>();
|
||||
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++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user