mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkLobbyPlayer
This commit is contained in:
parent
96f4e2cc28
commit
9ffc6f2e44
@ -3,16 +3,31 @@
|
||||
|
||||
namespace Mirror
|
||||
{
|
||||
/// <summary>
|
||||
/// This component works in conjunction with the NetworkLobbyManager to make up the multiplayer lobby system.
|
||||
/// <para>The LobbyPrefab object of the NetworkLobbyManager must have this component on it. This component holds basic lobby player data required for the lobby to function. Game specific data for lobby players can be put in other components on the LobbyPrefab or in scripts derived from NetworkLobbyPlayer.</para>
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Network/NetworkLobbyPlayer")]
|
||||
[HelpURL("https://vis2k.github.io/Mirror/Components/NetworkLobbyPlayer")]
|
||||
public class NetworkLobbyPlayer : NetworkBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// This flag controls whether the default UI is shown for the lobby player.
|
||||
/// <para>As this UI is rendered using the old GUI system, it is only recommended for testing purposes.</para>
|
||||
/// </summary>
|
||||
public bool showLobbyGUI = true;
|
||||
|
||||
[SyncVar(hook=nameof(ReadyStateChanged))]
|
||||
/// <summary>
|
||||
/// This is a flag that control whether this player is ready for the game to begin.
|
||||
/// <para>When all players are ready to begin, the game will start. This should not be set directly, the SendReadyToBeginMessage function should be called on the client to set it on the server.</para>
|
||||
/// </summary>
|
||||
[SyncVar(hook = nameof(ReadyStateChanged))]
|
||||
public bool readyToBegin;
|
||||
|
||||
/// <summary>
|
||||
/// Current index of the player, e.g. Player1, Player2, etc.
|
||||
/// </summary>
|
||||
[SyncVar]
|
||||
public int index;
|
||||
|
||||
@ -57,16 +72,31 @@ void ReadyStateChanged(bool newReadyState)
|
||||
|
||||
#region Lobby Client Virtuals
|
||||
|
||||
public virtual void OnClientEnterLobby() {}
|
||||
/// <summary>
|
||||
/// This is a hook that is invoked on all player objects when entering the lobby.
|
||||
/// <para>Note: isLocalPlayer is not guaranteed to be set until OnStartLocalPlayer is called.</para>
|
||||
/// </summary>
|
||||
public virtual void OnClientEnterLobby() { }
|
||||
|
||||
public virtual void OnClientExitLobby() {}
|
||||
/// <summary>
|
||||
/// This is a hook that is invoked on all player objects when exiting the lobby.
|
||||
/// </summary>
|
||||
public virtual void OnClientExitLobby() { }
|
||||
|
||||
public virtual void OnClientReady(bool readyState) {}
|
||||
/// <summary>
|
||||
/// This is a hook that is invoked on clients when a LobbyPlayer switches between ready or not ready.
|
||||
/// <para>This function is called when the a client player calls SendReadyToBeginMessage() or SendNotReadyToBeginMessage().</para>
|
||||
/// </summary>
|
||||
/// <param name="readyState">Whether the player is ready or not.</param>
|
||||
public virtual void OnClientReady(bool readyState) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Optional UI
|
||||
|
||||
/// <summary>
|
||||
/// virtual so inheriting classes can roll their own
|
||||
/// </summary>
|
||||
public virtual void OnGUI()
|
||||
{
|
||||
if (!showLobbyGUI)
|
||||
|
Loading…
Reference in New Issue
Block a user