From 92c95223887cb55f9921a0c1ffb0454c4f6c428d Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 7 Mar 2021 19:57:46 +0800 Subject: [PATCH] move all the things --- Assets/Mirror/Components/NetworkAnimator.cs | 10 +++--- .../Mirror/Components/NetworkRoomManager.cs | 2 +- .../Examples/Basic/Scripts/BasicNetManager.cs | 2 +- .../Scripts/MultiSceneNetManager.cs | 2 +- Assets/Mirror/Runtime/Messages.cs | 2 +- Assets/Mirror/Runtime/NetworkBehaviour.cs | 4 +-- Assets/Mirror/Runtime/NetworkClient.cs | 32 ++++++++--------- Assets/Mirror/Runtime/NetworkConnection.cs | 4 +-- Assets/Mirror/Runtime/NetworkIdentity.cs | 10 +++--- Assets/Mirror/Runtime/NetworkManager.cs | 18 +++++----- Assets/Mirror/Runtime/NetworkManagerHUD.cs | 8 ++--- Assets/Mirror/Runtime/NetworkServer.cs | 2 +- .../ClientSceneTests_RegisterPrefabBase.cs | 34 +++++++++---------- ...lientSceneTests_DestroyAllClientObjects.cs | 10 +++--- .../Runtime/ClientSceneTests_LocalPlayer.cs | 18 +++++----- 15 files changed, 79 insertions(+), 79 deletions(-) diff --git a/Assets/Mirror/Components/NetworkAnimator.cs b/Assets/Mirror/Components/NetworkAnimator.cs index d430db95c..a41e7f32c 100644 --- a/Assets/Mirror/Components/NetworkAnimator.cs +++ b/Assets/Mirror/Components/NetworkAnimator.cs @@ -127,7 +127,7 @@ void CheckSpeed() { animatorSpeed = newSpeed; } - else if (ClientScene.readyConnection != null) + else if (NetworkClient.readyConnection != null) { CmdSetAnimatorSpeed(newSpeed); } @@ -215,7 +215,7 @@ void SendAnimationMessage(int stateHash, float normalizedTime, int layerId, floa { RpcOnAnimationClientMessage(stateHash, normalizedTime, layerId, weight, parameters); } - else if (ClientScene.readyConnection != null) + else if (NetworkClient.readyConnection != null) { CmdOnAnimationServerMessage(stateHash, normalizedTime, layerId, weight, parameters); } @@ -227,7 +227,7 @@ void SendAnimationParametersMessage(byte[] parameters) { RpcOnAnimationParametersClientMessage(parameters); } - else if (ClientScene.readyConnection != null) + else if (NetworkClient.readyConnection != null) { CmdOnAnimationParametersServerMessage(parameters); } @@ -455,7 +455,7 @@ public void SetTrigger(int hash) return; } - if (ClientScene.readyConnection != null) + if (NetworkClient.readyConnection != null) CmdOnAnimationTriggerServerMessage(hash); // call on client right away @@ -504,7 +504,7 @@ public void ResetTrigger(int hash) return; } - if (ClientScene.readyConnection != null) + if (NetworkClient.readyConnection != null) CmdOnAnimationResetTriggerServerMessage(hash); // call on client right away diff --git a/Assets/Mirror/Components/NetworkRoomManager.cs b/Assets/Mirror/Components/NetworkRoomManager.cs index 722153bac..3941ae8b9 100644 --- a/Assets/Mirror/Components/NetworkRoomManager.cs +++ b/Assets/Mirror/Components/NetworkRoomManager.cs @@ -303,7 +303,7 @@ public override void OnServerDisconnect(NetworkConnection conn) public int clientIndex; /// - /// Called on the server when a client adds a new player with ClientScene.AddPlayer. + /// Called on the server when a client adds a new player with NetworkClient.AddPlayer. /// The default implementation for this function creates a new player object from the playerPrefab. /// /// Connection from client. diff --git a/Assets/Mirror/Examples/Basic/Scripts/BasicNetManager.cs b/Assets/Mirror/Examples/Basic/Scripts/BasicNetManager.cs index 60b61de60..0735fe6b2 100644 --- a/Assets/Mirror/Examples/Basic/Scripts/BasicNetManager.cs +++ b/Assets/Mirror/Examples/Basic/Scripts/BasicNetManager.cs @@ -23,7 +23,7 @@ public class BasicNetManager : NetworkManager public RectTransform playersPanel; /// - /// Called on the server when a client adds a new player with ClientScene.AddPlayer. + /// Called on the server when a client adds a new player with NetworkClient.AddPlayer. /// The default implementation for this function creates a new player object from the playerPrefab. /// /// Connection from client. diff --git a/Assets/Mirror/Examples/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs b/Assets/Mirror/Examples/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs index 7278483ad..a0b7ef886 100644 --- a/Assets/Mirror/Examples/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs +++ b/Assets/Mirror/Examples/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs @@ -27,7 +27,7 @@ public class MultiSceneNetManager : NetworkManager int clientIndex; /// - /// Called on the server when a client adds a new player with ClientScene.AddPlayer. + /// Called on the server when a client adds a new player with NetworkClient.AddPlayer. /// The default implementation for this function creates a new player object from the playerPrefab. /// /// Connection from client. diff --git a/Assets/Mirror/Runtime/Messages.cs b/Assets/Mirror/Runtime/Messages.cs index 970731235..b987eb328 100644 --- a/Assets/Mirror/Runtime/Messages.cs +++ b/Assets/Mirror/Runtime/Messages.cs @@ -65,7 +65,7 @@ public struct SpawnMessage : NetworkMessage /// public uint netId; /// - /// Is the spawning object the local player. Sets ClientScene.localPlayer + /// Is the spawning object the local player. Sets NetworkClient.localPlayer /// public bool isLocalPlayer; /// diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index 9505deddd..8c84ac357 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -186,7 +186,7 @@ protected void SendCommandInternal(Type invokeClass, string cmdName, NetworkWrit return; } - if (ClientScene.readyConnection == null) + if (NetworkClient.readyConnection == null) { Debug.LogError("Send command attempted with no client running [client=" + connectionToServer + "]."); return; @@ -203,7 +203,7 @@ protected void SendCommandInternal(Type invokeClass, string cmdName, NetworkWrit payload = writer.ToArraySegment() }; - ClientScene.readyConnection.Send(message, channelId); + NetworkClient.readyConnection.Send(message, channelId); } #endregion diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs index eb4af1a30..bfad3bb54 100644 --- a/Assets/Mirror/Runtime/NetworkClient.cs +++ b/Assets/Mirror/Runtime/NetworkClient.cs @@ -643,7 +643,7 @@ public static void RegisterPrefab(GameObject prefab, SpawnHandlerDelegate spawnH unspawnHandlers[assetId] = unspawnHandler; } - /// Removes a registered spawn prefab that was setup with ClientScene.RegisterPrefab. + /// Removes a registered spawn prefab that was setup with NetworkClient.RegisterPrefab. public static void UnregisterPrefab(GameObject prefab) { if (prefab == null) @@ -728,7 +728,7 @@ public static void RegisterSpawnHandler(Guid assetId, SpawnHandlerDelegate spawn unspawnHandlers[assetId] = unspawnHandler; } - /// Removes a registered spawn handler function that was registered with ClientScene.RegisterHandler(). + /// Removes a registered spawn handler function that was registered with NetworkClient.RegisterHandler(). public static void UnregisterSpawnHandler(Guid assetId) { spawnHandlers.Remove(assetId); @@ -767,7 +767,7 @@ public static bool Ready(NetworkConnection conn) return false; } - // Debug.Log("ClientScene.Ready() called with connection [" + conn + "]"); + // Debug.Log("NetworkClient.Ready() called with connection [" + conn + "]"); if (conn != null) { @@ -798,7 +798,7 @@ internal static void HandleClientDisconnect(NetworkConnection conn) // called from message handler for Owner message internal static void InternalAddPlayer(NetworkIdentity identity) { - //Debug.Log("ClientScene.InternalAddPlayer"); + //Debug.Log("NetworkClient.InternalAddPlayer"); // NOTE: It can be "normal" when changing scenes for the player to be destroyed and recreated. // But, the player structures are not cleaned up, we'll just replace the old player @@ -819,7 +819,7 @@ internal static void InternalAddPlayer(NetworkIdentity identity) // object is destroyed. internal static void ClearLocalPlayer() { - //Debug.Log("ClientScene.ClearLocalPlayer"); + //Debug.Log("NetworkClient.ClearLocalPlayer"); localPlayer = null; } @@ -841,11 +841,11 @@ public static bool AddPlayer(NetworkConnection readyConn) if (readyConnection.identity != null) { - Debug.LogError("ClientScene.AddPlayer: a PlayerController was already added. Did you call AddPlayer twice?"); + Debug.LogError("NetworkClient.AddPlayer: a PlayerController was already added. Did you call AddPlayer twice?"); return false; } - // Debug.Log("ClientScene.AddPlayer() called with connection [" + readyConnection + "]"); + // Debug.Log("NetworkClient.AddPlayer() called with connection [" + readyConnection + "]"); readyConnection.Send(new AddPlayerMessage()); return true; } @@ -1059,7 +1059,7 @@ static void ClearNullFromSpawned() // host mode callbacks ///////////////////////////////////////////////// static void OnHostClientObjectDestroy(ObjectDestroyMessage msg) { - // Debug.Log("ClientScene.OnLocalObjectObjDestroy netId:" + msg.netId); + // Debug.Log("NetworkClient.OnLocalObjectObjDestroy netId:" + msg.netId); NetworkIdentity.spawned.Remove(msg.netId); } @@ -1092,7 +1092,7 @@ internal static void OnHostClientSpawn(SpawnMessage msg) // client-only mode callbacks ////////////////////////////////////////// static void OnUpdateVarsMessage(UpdateVarsMessage msg) { - // Debug.Log("ClientScene.OnUpdateVarsMessage " + msg.netId); + // Debug.Log("NetworkClient.OnUpdateVarsMessage " + msg.netId); if (NetworkIdentity.spawned.TryGetValue(msg.netId, out NetworkIdentity localObject) && localObject != null) { using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(msg.payload)) @@ -1103,7 +1103,7 @@ static void OnUpdateVarsMessage(UpdateVarsMessage msg) static void OnRPCMessage(RpcMessage msg) { - // Debug.Log("ClientScene.OnRPCMessage hash:" + msg.functionHash + " netId:" + msg.netId); + // Debug.Log("NetworkClient.OnRPCMessage hash:" + msg.functionHash + " netId:" + msg.netId); if (NetworkIdentity.spawned.TryGetValue(msg.netId, out NetworkIdentity identity)) { using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(msg.payload)) @@ -1126,20 +1126,20 @@ internal static void OnSpawn(SpawnMessage msg) internal static void CheckForLocalPlayer(NetworkIdentity identity) { - if (identity == ClientScene.localPlayer) + if (identity == localPlayer) { // Set isLocalPlayer to true on this NetworkIdentity and trigger // OnStartLocalPlayer in all scripts on the same GO - identity.connectionToServer = ClientScene.readyConnection; + identity.connectionToServer = readyConnection; identity.OnStartLocalPlayer(); - // Debug.Log("ClientScene.OnOwnerMessage - player=" + identity.name); + // Debug.Log("NetworkClient.OnOwnerMessage - player=" + identity.name); } } // destroy ///////////////////////////////////////////////////////////// static void DestroyObject(uint netId) { - // Debug.Log("ClientScene.OnObjDestroy netId:" + netId); + // Debug.Log("NetworkClient.OnObjDestroy netId:" + netId); if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity localObject) && localObject != null) { localObject.OnStopClient(); @@ -1257,8 +1257,8 @@ public static void Shutdown() Debug.Log("Shutting down client."); ClearSpawners(); spawnableObjects.Clear(); - ClientScene.readyConnection = null; - ClientScene.ready = false; + readyConnection = null; + ready = false; isSpawnFinished = false; DestroyAllClientObjects(); connectState = ConnectState.None; diff --git a/Assets/Mirror/Runtime/NetworkConnection.cs b/Assets/Mirror/Runtime/NetworkConnection.cs index 6bdeb8846..854003810 100644 --- a/Assets/Mirror/Runtime/NetworkConnection.cs +++ b/Assets/Mirror/Runtime/NetworkConnection.cs @@ -45,8 +45,8 @@ public abstract class NetworkConnection public object authenticationData; /// - /// Flag that tells if the connection has been marked as "ready" by a client calling ClientScene.Ready(). - /// This property is read-only. It is set by the system on the client when ClientScene.Ready() is called, and set by the system on the server when a ready message is received from a client. + /// Flag that tells if the connection has been marked as "ready" by a client calling NetworkClient.Ready(). + /// This property is read-only. It is set by the system on the client when NetworkClient.Ready() is called, and set by the system on the server when a ready message is received from a client. /// A client that is ready is sent spawned objects by the server and updates to the state of spawned objects. A client that is not ready is not sent spawned objects. /// public bool isReady; diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index f755feaa8..fc98f6b9e 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -151,7 +151,7 @@ public sealed class NetworkIdentity : MonoBehaviour // for saving, etc. since isLocalPlayer may have been reset before // OnDestroy was called. // - // we also DO NOT make it dependent on ClientScene.localPlayer or similar. + // we also DO NOT make it dependent on NetworkClient.localPlayer or similar. // we set it, then never change it. that's the user's expectation too. // // => fixes https://github.com/vis2k/Mirror/issues/2615 @@ -706,8 +706,8 @@ internal void OnStartServer() // set isLocalPlayer earlier, in case OnStartLocalplayer is called // AFTER OnStartClient, in which case it would still be falsse here. // many projects will check isLocalPlayer in OnStartClient though. - // TODO ideally set isLocalPlayer when ClientScene.localPlayer is set? - if (ClientScene.localPlayer == this) + // TODO ideally set isLocalPlayer when NetworkClient.localPlayer is set? + if (NetworkClient.localPlayer == this) { isLocalPlayer = true; } @@ -791,8 +791,8 @@ internal void OnStartClient() // set isLocalPlayer earlier, in case OnStartLocalplayer is called // AFTER OnStartClient, in which case it would still be falsse here. // many projects will check isLocalPlayer in OnStartClient though. - // TODO ideally set isLocalPlayer when ClientScene.localPlayer is set? - if (ClientScene.localPlayer == this) + // TODO ideally set isLocalPlayer when NetworkClient.localPlayer is set? + if (NetworkClient.localPlayer == this) { isLocalPlayer = true; } diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 04ed6b822..351c9496f 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -169,7 +169,7 @@ public class NetworkManager : MonoBehaviour /// /// List of prefabs that will be registered with the spawning system. - /// For each of these prefabs, ClientScene.RegisterPrefab() will be automatically invoked. + /// For each of these prefabs, NetworkClient.RegisterPrefab() will be automatically invoked. /// [FormerlySerializedAs("m_SpawnPrefabs"), HideInInspector] public List spawnPrefabs = new List(); @@ -967,7 +967,7 @@ internal void ClientChangeScene(string newSceneName, SceneOperation sceneOperati // NetworkScenePostProcess disables all scene objects on load, and // * NetworkServer.SpawnObjects enables them again on the server when // calling OnStartServer - // * ClientScene.PrepareToSpawnSceneObjects enables them again on the + // * NetworkClient.PrepareToSpawnSceneObjects enables them again on the // client after the server sends ObjectSpawnStartedMessage to client // in SpawnObserversForConnection. this is only called when the // client joins, so we need to rebuild scene objects manually again @@ -984,7 +984,7 @@ void OnSceneLoaded(Scene scene, LoadSceneMode mode) } if (NetworkClient.active) { - ClientScene.PrepareToSpawnSceneObjects(); + NetworkClient.PrepareToSpawnSceneObjects(); // Debug.Log("Rebuild Client spawnableObjects after additive scene load: " + scene.name); } } @@ -1351,7 +1351,7 @@ public virtual void OnServerReady(NetworkConnection conn) } /// - /// Called on the server when a client adds a new player with ClientScene.AddPlayer. + /// Called on the server when a client adds a new player with NetworkClient.AddPlayer. /// The default implementation for this function creates a new player object from the playerPrefab. /// /// Connection from client. @@ -1403,10 +1403,10 @@ public virtual void OnClientConnect(NetworkConnection conn) if (!clientLoadedScene) { // Ready/AddPlayer is usually triggered by a scene load completing. if no scene was loaded, then Ready/AddPlayer it here instead. - if (!ClientScene.ready) ClientScene.Ready(conn); + if (!NetworkClient.ready) NetworkClient.Ready(conn); if (autoCreatePlayer) { - ClientScene.AddPlayer(conn); + NetworkClient.AddPlayer(conn); } } } @@ -1453,13 +1453,13 @@ public virtual void OnClientChangeScene(string newSceneName, SceneOperation scen public virtual void OnClientSceneChanged(NetworkConnection conn) { // always become ready. - if (!ClientScene.ready) ClientScene.Ready(conn); + if (!NetworkClient.ready) NetworkClient.Ready(conn); // Only call AddPlayer for normal scene changes, not additive load/unload - if (clientSceneOperation == SceneOperation.Normal && autoCreatePlayer && ClientScene.localPlayer == null) + if (clientSceneOperation == SceneOperation.Normal && autoCreatePlayer && NetworkClient.localPlayer == null) { // add player if existing one is null - ClientScene.AddPlayer(conn); + NetworkClient.AddPlayer(conn); } } diff --git a/Assets/Mirror/Runtime/NetworkManagerHUD.cs b/Assets/Mirror/Runtime/NetworkManagerHUD.cs index ea58d9f61..082aab65f 100644 --- a/Assets/Mirror/Runtime/NetworkManagerHUD.cs +++ b/Assets/Mirror/Runtime/NetworkManagerHUD.cs @@ -56,15 +56,15 @@ void OnGUI() } // client ready - if (NetworkClient.isConnected && !ClientScene.ready) + if (NetworkClient.isConnected && !NetworkClient.ready) { if (GUILayout.Button("Client Ready")) { - ClientScene.Ready(NetworkClient.connection); + NetworkClient.Ready(NetworkClient.connection); - if (ClientScene.localPlayer == null) + if (NetworkClient.localPlayer == null) { - ClientScene.AddPlayer(NetworkClient.connection); + NetworkClient.AddPlayer(NetworkClient.connection); } } } diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index 40ae5bf6e..65fc5cb20 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -125,7 +125,7 @@ public static void Listen(int maxConns) RegisterMessageHandlers(); } - // Note: ClientScene.DestroyAllClientObjects does the same on client. + // Note: NetworkClient.DestroyAllClientObjects does the same on client. static void CleanupNetworkIdentities() { foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values) diff --git a/Assets/Mirror/Tests/Common/ClientSceneTests_RegisterPrefabBase.cs b/Assets/Mirror/Tests/Common/ClientSceneTests_RegisterPrefabBase.cs index 6e1f4ef8b..cd7131049 100644 --- a/Assets/Mirror/Tests/Common/ClientSceneTests_RegisterPrefabBase.cs +++ b/Assets/Mirror/Tests/Common/ClientSceneTests_RegisterPrefabBase.cs @@ -73,22 +73,22 @@ protected void CallRegisterPrefab(GameObject prefab, RegisterPrefabOverload over switch (overload) { case RegisterPrefabOverload.Prefab: - ClientScene.RegisterPrefab(prefab); + NetworkClient.RegisterPrefab(prefab); break; case RegisterPrefabOverload.Prefab_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid); + NetworkClient.RegisterPrefab(prefab, anotherGuid); break; case RegisterPrefabOverload.Prefab_SpawnDelegate: - ClientScene.RegisterPrefab(prefab, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, anotherGuid, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate: - ClientScene.RegisterPrefab(prefab, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, spawnHandlerDelegate, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, anotherGuid, spawnHandlerDelegate, unspawnHandler); break; default: @@ -106,13 +106,13 @@ protected void CallRegisterPrefab(GameObject prefab, RegisterPrefabOverload over switch (overload) { case RegisterPrefabOverload.Prefab_NewAssetId: - ClientScene.RegisterPrefab(prefab, guid); + NetworkClient.RegisterPrefab(prefab, guid); break; case RegisterPrefabOverload.Prefab_SpawnDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, guid, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, guid, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, guid, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, guid, spawnHandlerDelegate, unspawnHandler); break; case RegisterPrefabOverload.Prefab: @@ -133,10 +133,10 @@ protected void CallRegisterPrefab(GameObject prefab, RegisterPrefabOverload over switch (overload) { case RegisterPrefabOverload.Prefab_SpawnDelegate: - ClientScene.RegisterPrefab(prefab, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, anotherGuid, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab: @@ -158,10 +158,10 @@ protected void CallRegisterPrefab(GameObject prefab, RegisterPrefabOverload over switch (overload) { case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate: - ClientScene.RegisterPrefab(prefab, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, spawnHandlerDelegate, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, anotherGuid, spawnHandlerDelegate, unspawnHandler); break; case RegisterPrefabOverload.Prefab: @@ -185,16 +185,16 @@ protected void CallRegisterPrefab(GameObject prefab, RegisterPrefabOverload over { case RegisterPrefabOverload.Prefab_SpawnDelegate: - ClientScene.RegisterPrefab(prefab, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid, spawnHandler, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, anotherGuid, spawnHandler, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate: - ClientScene.RegisterPrefab(prefab, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, spawnHandlerDelegate, unspawnHandler); break; case RegisterPrefabOverload.Prefab_SpawnHandlerDelegate_NewAssetId: - ClientScene.RegisterPrefab(prefab, anotherGuid, spawnHandlerDelegate, unspawnHandler); + NetworkClient.RegisterPrefab(prefab, anotherGuid, spawnHandlerDelegate, unspawnHandler); break; case RegisterPrefabOverload.Prefab: diff --git a/Assets/Mirror/Tests/Runtime/ClientSceneTests_DestroyAllClientObjects.cs b/Assets/Mirror/Tests/Runtime/ClientSceneTests_DestroyAllClientObjects.cs index 1417296eb..7af6d9b2f 100644 --- a/Assets/Mirror/Tests/Runtime/ClientSceneTests_DestroyAllClientObjects.cs +++ b/Assets/Mirror/Tests/Runtime/ClientSceneTests_DestroyAllClientObjects.cs @@ -93,7 +93,7 @@ public IEnumerator DestroysAllNetworkPrefabsInScene() listener2.onDestroyCalled += () => destroyCalled2++; listener3.onDestroyCalled += () => destroyCalled3++; - ClientScene.DestroyAllClientObjects(); + NetworkClient.DestroyAllClientObjects(); // wait for frame to make sure unity events are called yield return null; @@ -127,7 +127,7 @@ public IEnumerator DisablesAllNetworkSceneObjectsInScene() listener2.onDestroyCalled += () => destroyCalled2++; listener3.onDestroyCalled += () => destroyCalled3++; - ClientScene.DestroyAllClientObjects(); + NetworkClient.DestroyAllClientObjects(); // wait for frame to make sure unity events are called yield return null; @@ -172,7 +172,7 @@ public void CallsUnspawnHandlerInsteadOfDestroy() listener2.onDisableCalled += () => disableCalled2++; listener3.onDisableCalled += () => disableCalled3++; - ClientScene.DestroyAllClientObjects(); + NetworkClient.DestroyAllClientObjects(); Assert.That(unspawnCalled1, Is.EqualTo(1)); Assert.That(unspawnCalled2, Is.EqualTo(1)); @@ -191,7 +191,7 @@ public void ClearsSpawnedList() TestListenerBehaviour listener2 = CreateAndAddObject(30002, 0); TestListenerBehaviour listener3 = CreateAndAddObject(30003, 0); - ClientScene.DestroyAllClientObjects(); + NetworkClient.DestroyAllClientObjects(); Assert.That(spawned, Is.Empty); } @@ -207,7 +207,7 @@ public void CatchesAndLogsExeptionWhenSpawnedListIsChanged() LogAssert.Expect(LogType.Exception, new Regex("InvalidOperationException")); LogAssert.Expect(LogType.Error, "Could not DestroyAllClientObjects because spawned list was modified during loop, make sure you are not modifying NetworkIdentity.spawned by calling NetworkServer.Destroy or NetworkServer.Spawn in OnDestroy or OnDisable."); - ClientScene.DestroyAllClientObjects(); + NetworkClient.DestroyAllClientObjects(); } } } diff --git a/Assets/Mirror/Tests/Runtime/ClientSceneTests_LocalPlayer.cs b/Assets/Mirror/Tests/Runtime/ClientSceneTests_LocalPlayer.cs index 154e017f4..183fbca7b 100644 --- a/Assets/Mirror/Tests/Runtime/ClientSceneTests_LocalPlayer.cs +++ b/Assets/Mirror/Tests/Runtime/ClientSceneTests_LocalPlayer.cs @@ -11,9 +11,9 @@ public class ClientSceneTests_LocalPlayer : ClientSceneTestsBase [SetUp] public void Setup() { - Debug.Assert(ClientScene.localPlayer == null, "LocalPlayer should be null before this test"); + Debug.Assert(NetworkClient.localPlayer == null, "LocalPlayer should be null before this test"); - PropertyInfo readyConnProperty = typeof(ClientScene).GetProperty(nameof(ClientScene.readyConnection)); + PropertyInfo readyConnProperty = typeof(ClientScene).GetProperty(nameof(NetworkClient.readyConnection)); readyConnProperty.SetValue(null, new FakeNetworkConnection()); } @@ -37,7 +37,7 @@ NetworkIdentity SpawnObject(bool localPlayer) if (localPlayer) { - Assert.That(ClientScene.localPlayer, Is.EqualTo(identity)); + Assert.That(NetworkClient.localPlayer, Is.EqualTo(identity)); } return identity; @@ -54,7 +54,7 @@ public IEnumerator LocalPlayerIsSetToNullAfterDestroy() yield return null; // use "is null" here to avoid unity == check - Assert.IsTrue(ClientScene.localPlayer is null, "local player should be set to c# null"); + Assert.IsTrue(NetworkClient.localPlayer is null, "local player should be set to c# null"); } [UnityTest] @@ -68,8 +68,8 @@ public IEnumerator DestroyingOtherObjectDoesntEffectLocalPlayer() // wait a frame for destroy to happen yield return null; - Assert.IsTrue(ClientScene.localPlayer != null, "local player should not be cleared"); - Assert.IsTrue(ClientScene.localPlayer == player, "local player should still be equal to player"); + Assert.IsTrue(NetworkClient.localPlayer != null, "local player should not be cleared"); + Assert.IsTrue(NetworkClient.localPlayer == player, "local player should still be equal to player"); } [UnityTest] @@ -86,7 +86,7 @@ public IEnumerator LocalPlayerIsSetToNullAfterDestroyMessage() yield return null; // use "is null" here to avoid unity == check - Assert.IsTrue(ClientScene.localPlayer is null, "local player should be set to c# null"); + Assert.IsTrue(NetworkClient.localPlayer is null, "local player should be set to c# null"); } } public class ClientSceneTest_LocalPlayer_asHost : HostSetup @@ -117,7 +117,7 @@ public IEnumerator LocalPlayerIsSetToNullAfterNetworkDestroy() yield return null; // use "is null" here to avoid unity == check - Assert.IsTrue(ClientScene.localPlayer is null, "local player should be set to c# null"); + Assert.IsTrue(NetworkClient.localPlayer is null, "local player should be set to c# null"); } [UnityTest] @@ -146,7 +146,7 @@ public IEnumerator LocalPlayerIsSetToNullAfterNetworkUnspawn() yield return null; // use "is null" here to avoid unity == check - Assert.IsTrue(ClientScene.localPlayer is null, "local player should be set to c# null"); + Assert.IsTrue(NetworkClient.localPlayer is null, "local player should be set to c# null"); } } }