From c289ffb4409518c1d46d6f9cca242bb9d2f837d3 Mon Sep 17 00:00:00 2001 From: rodolphito Date: Wed, 27 Mar 2019 02:26:45 -0700 Subject: [PATCH] Remove proxy methods for setting playerController. (#665) * Deprecate proxy methods for setting playerController. * shortened obsoleted methods. * This isnt actually public facing, its internal. Obsoletion is unnecessary, plain removal is ok. --- Assets/Mirror/Runtime/ClientScene.cs | 4 ++-- Assets/Mirror/Runtime/NetworkClient.cs | 2 +- Assets/Mirror/Runtime/NetworkConnection.cs | 12 +----------- Assets/Mirror/Runtime/NetworkManager.cs | 2 +- Assets/Mirror/Runtime/NetworkServer.cs | 9 ++++----- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Assets/Mirror/Runtime/ClientScene.cs b/Assets/Mirror/Runtime/ClientScene.cs index cf8f17a6d..970a22843 100644 --- a/Assets/Mirror/Runtime/ClientScene.cs +++ b/Assets/Mirror/Runtime/ClientScene.cs @@ -50,7 +50,7 @@ internal static void InternalAddPlayer(NetworkIdentity identity) localPlayer = identity; if (readyConnection != null) { - readyConnection.SetPlayerController(identity); + readyConnection.playerController = identity; } else { @@ -108,7 +108,7 @@ public static bool RemovePlayer() Object.Destroy(readyConnection.playerController.gameObject); - readyConnection.RemovePlayerController(); + readyConnection.playerController = null; localPlayer = null; return true; diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs index 36f9dbfc3..b057baa52 100644 --- a/Assets/Mirror/Runtime/NetworkClient.cs +++ b/Assets/Mirror/Runtime/NetworkClient.cs @@ -93,7 +93,7 @@ internal static void AddLocalPlayer(NetworkIdentity localPlayer) { if (LogFilter.Debug) Debug.Log("Local client AddLocalPlayer " + localPlayer.gameObject.name + " conn=" + connection.connectionId); connection.isReady = true; - connection.SetPlayerController(localPlayer); + connection.playerController = localPlayer; if (localPlayer != null) { localPlayer.isClient = true; diff --git a/Assets/Mirror/Runtime/NetworkConnection.cs b/Assets/Mirror/Runtime/NetworkConnection.cs index 87c77d4ef..201cb233d 100644 --- a/Assets/Mirror/Runtime/NetworkConnection.cs +++ b/Assets/Mirror/Runtime/NetworkConnection.cs @@ -14,7 +14,7 @@ public class NetworkConnection : IDisposable public bool isReady; public string address; public float lastMessageTime; - public NetworkIdentity playerController { get; private set; } + public NetworkIdentity playerController { get; internal set; } public HashSet clientOwnedObjects; public bool logNetworkMessages; @@ -116,16 +116,6 @@ public void UnregisterHandler(short msgType) m_MessageHandlers.Remove(msgType); } - internal void SetPlayerController(NetworkIdentity player) - { - playerController = player; - } - - internal void RemovePlayerController() - { - playerController = null; - } - [Obsolete("use Send instead")] public virtual bool Send(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable) { diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 061db7510..17c71ddb2 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -579,7 +579,7 @@ internal void OnServerRemovePlayerMessageInternal(NetworkConnection conn, Remove if (conn.playerController != null) { OnServerRemovePlayer(conn, conn.playerController); - conn.RemovePlayerController(); + conn.playerController = null; } } diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index efd6dc509..c0081db3c 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -672,7 +672,7 @@ public static bool AddPlayerForConnection(NetworkConnection conn, GameObject pla return false; } - conn.SetPlayerController(identity); + conn.playerController = identity; // Set the connection on the NetworkIdentity on the server, NetworkIdentity.SetLocalPlayer is not called on the server (it is on clients) identity.connectionToClient = conn; @@ -769,7 +769,7 @@ internal static bool InternalReplacePlayerForConnection(NetworkConnection conn, conn.playerController.clientAuthorityOwner = null; } - conn.SetPlayerController(playerNetworkIdentity); + conn.playerController = playerNetworkIdentity; // Set the connection on the NetworkIdentity on the server, NetworkIdentity.SetLocalPlayer is not called on the server (it is on clients) playerNetworkIdentity.connectionToClient = conn; @@ -874,7 +874,7 @@ static void OnRemovePlayerMessage(NetworkConnection conn, RemovePlayerMessage ms if (conn.playerController != null) { Destroy(conn.playerController.gameObject); - conn.RemovePlayerController(); + conn.playerController = null; } else { @@ -1014,9 +1014,8 @@ public static void DestroyPlayerForConnection(NetworkConnection conn) if (conn.playerController != null) { DestroyObject(conn.playerController, true); + conn.playerController = null; } - - conn.RemovePlayerController(); } public static void Spawn(GameObject obj)