Obsoletes OnServerAddPlayer (#1134)

* Obsoletes OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)

* Fixed NetworkManager

* Fixed Pong

* Fixed Room

* Wrapped call in warning suppressors

* Improved comments
This commit is contained in:
MrGadget 2019-10-02 04:26:19 -04:00 committed by vis2k
parent e73185932a
commit 5dfc85931f
3 changed files with 17 additions and 4 deletions

View File

@ -261,7 +261,7 @@ public override void OnServerDisconnect(NetworkConnection conn)
/// </summary>
/// <param name="conn">Connection of the client</param>
/// <param name="extraMessage"></param>
public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
public override void OnServerAddPlayer(NetworkConnection conn)
{
if (SceneManager.GetActiveScene().name != RoomScene) return;

View File

@ -10,7 +10,7 @@ public class NetworkManagerPong : NetworkManager
public Transform rightRacketSpawn;
GameObject ball;
public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
public override void OnServerAddPlayer(NetworkConnection conn)
{
// add player at correct spawn position
Transform start = numPlayers == 0 ? leftRacketSpawn : rightRacketSpawn;

View File

@ -872,7 +872,9 @@ void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage extraMes
return;
}
#pragma warning disable CS0618 // Type or member is obsolete
OnServerAddPlayer(conn, extraMessage);
#pragma warning restore CS0618 // Type or member is obsolete
}
void OnServerRemovePlayerMessageInternal(NetworkConnection conn, RemovePlayerMessage msg)
@ -1003,13 +1005,24 @@ public virtual void OnServerReady(NetworkConnection conn)
NetworkServer.SetClientReady(conn);
}
/// <summary>
/// Obsolete: Override <see cref="OnServerAddPlayer(NetworkConnection)"/> instead.
/// <para>See <a href="../Guides/GameObjects/SpawnPlayerCustom.md">Custom Players</a> for details.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
/// <param name="extraMessage">An extra message object passed for the new player.</param>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Override OnServerAddPlayer(NetworkConnection conn) instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html for details.")]
public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
{
OnServerAddPlayer(conn);
}
/// <summary>
/// Called on the server when a client adds a new player with ClientScene.AddPlayer.
/// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
/// <param name="extraMessage">An extra message object passed for the new player.</param>
public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
public virtual void OnServerAddPlayer(NetworkConnection conn)
{
Transform startPos = GetStartPosition();
GameObject player = startPos != null