breaking: NetworkConnectionToServer.clientOwnedObjects renamed to .owned (simplify API)

This commit is contained in:
vis2k 2022-10-13 11:03:42 +02:00
parent 8cb64383fc
commit 6bb42e9e81
3 changed files with 11 additions and 8 deletions

View File

@ -271,7 +271,7 @@ public override void OnServerDisconnect(NetworkConnectionToClient conn)
if (roomPlayer != null)
roomSlots.Remove(roomPlayer);
foreach (NetworkIdentity clientOwnedObject in conn.clientOwnedObjects)
foreach (NetworkIdentity clientOwnedObject in conn.owned)
{
roomPlayer = clientOwnedObject.GetComponent<NetworkRoomPlayer>();
if (roomPlayer != null)

View File

@ -47,8 +47,8 @@ public abstract class NetworkConnection
// netId anymore: https://github.com/vis2k/Mirror/issues/1380
// Works fine with NetworkIdentity pointers though.
// DEPRECATED 2022-02-05
[Obsolete("Cast to NetworkConnectionToClient to access .clientOwnedObjects")]
public HashSet<NetworkIdentity> clientOwnedObjects => ((NetworkConnectionToClient)this).clientOwnedObjects;
[Obsolete("Cast to NetworkConnectionToClient to access .owned")]
public HashSet<NetworkIdentity> clientOwnedObjects => ((NetworkConnectionToClient)this).owned;
// batching from server to client & client to server.
// fewer transport calls give us significantly better performance/scale.

View File

@ -18,7 +18,10 @@ public class NetworkConnectionToClient : NetworkConnection
// fixes a bug where DestroyOwnedObjects wouldn't find the
// netId anymore: https://github.com/vis2k/Mirror/issues/1380
// Works fine with NetworkIdentity pointers though.
public new readonly HashSet<NetworkIdentity> clientOwnedObjects = new HashSet<NetworkIdentity>();
public readonly HashSet<NetworkIdentity> owned = new HashSet<NetworkIdentity>();
[Obsolete(".clientOwnedObjects was renamed to .owned :)")] // 2022-10-13
public new HashSet<NetworkIdentity> clientOwnedObjects => owned;
// unbatcher
public Unbatcher unbatcher = new Unbatcher();
@ -76,18 +79,18 @@ internal void RemoveFromObservingsObservers()
internal void AddOwnedObject(NetworkIdentity obj)
{
clientOwnedObjects.Add(obj);
owned.Add(obj);
}
internal void RemoveOwnedObject(NetworkIdentity obj)
{
clientOwnedObjects.Remove(obj);
owned.Remove(obj);
}
internal void DestroyOwnedObjects()
{
// create a copy because the list might be modified when destroying
HashSet<NetworkIdentity> tmp = new HashSet<NetworkIdentity>(clientOwnedObjects);
HashSet<NetworkIdentity> tmp = new HashSet<NetworkIdentity>(owned);
foreach (NetworkIdentity netIdentity in tmp)
{
if (netIdentity != null)
@ -97,7 +100,7 @@ internal void DestroyOwnedObjects()
}
// clear the hashset because we destroyed them all
clientOwnedObjects.Clear();
owned.Clear();
}
}
}