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.
This commit is contained in:
rodolphito 2019-03-27 02:26:45 -07:00 committed by vis2k
parent f4cdfbf952
commit c289ffb440
5 changed files with 9 additions and 20 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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<uint> 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<T> instead")]
public virtual bool Send(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
{

View File

@ -579,7 +579,7 @@ internal void OnServerRemovePlayerMessageInternal(NetworkConnection conn, Remove
if (conn.playerController != null)
{
OnServerRemovePlayer(conn, conn.playerController);
conn.RemovePlayerController();
conn.playerController = null;
}
}

View File

@ -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)