Mirror::NetworkRoomPlayer
This component works in conjunction with the NetworkRoomManager to make up the multiplayer room system. More...
Inherits from NetworkBehaviour, MonoBehaviour
Inherited by NetworkRoomPlayerExt, NetworkLobbyPlayer
Public Functions
Name | |
---|---|
void | Start() Do not use Start - Override OnStartrHost / OnStartClient instead! |
virtual void | OnDisable() |
void | CmdChangeReadyState(bool readyState) |
virtual void | IndexChanged(int oldIndex, int newIndex) This is a hook that is invoked on clients when the index changes. |
virtual void | ReadyStateChanged(bool oldReadyState, bool newReadyState) This is a hook that is invoked on clients when a RoomPlayer switches between ready or not ready. |
virtual void | OnClientEnterRoom() This is a hook that is invoked on clients for all room player objects when entering the room. |
virtual void | OnClientExitRoom() This is a hook that is invoked on clients for all room player objects when exiting the room. |
virtual void | OnGUI() Render a UI for the room. Override to provide your on UI |
Public Attributes
Name | |
---|---|
bool | showRoomGUI This flag controls whether the default UI is shown for the room player. |
bool | readyToBegin Diagnostic flag indicating whether this player is ready for the game to begin. |
int | index Diagnostic index of the player, e.g. Player1, Player2, etc. |
Additional inherited members
Public Functions inherited from NetworkBehaviour
Name | |
---|---|
void | SetDirtyBit(ulong dirtyBit) Used to set the behaviour as dirty, so that a network update will be sent for the object. these are masks, not bit numbers, ie. 0x004 not 2 |
void | ClearAllDirtyBits() This clears all the dirty bits that were set on this script by SetDirtyBits(); |
bool | IsDirty() |
virtual bool | OnSerialize(NetworkWriter writer, bool initialState) Virtual function to override to send custom serialization data. The corresponding function to send serialization data is OnDeserialize(). |
virtual void | OnDeserialize(NetworkReader reader, bool initialState) Virtual function to override to receive custom serialization data. The corresponding function to send serialization data is OnSerialize(). |
bool | SerializeObjectsAll(NetworkWriter writer) |
bool | SerializeObjectsDelta(NetworkWriter writer) |
virtual void | OnStopClient() This is invoked on clients when the server has caused this object to be destroyed. |
virtual void | OnStartServer() This is invoked for NetworkBehaviour objects when they become active on the server. |
virtual void | OnStopServer() Invoked on the server when the object is unspawned |
virtual void | OnStartClient() Called on every NetworkBehaviour when it is activated on a client. |
virtual void | OnStartLocalPlayer() Called when the local player object has been set up. |
virtual void | OnStartAuthority() This is invoked on behaviours that have authority, based on context and NetworkIdentity.hasAuthority. |
virtual void | OnStopAuthority() This is invoked on behaviours when authority is removed. |
Protected Functions inherited from NetworkBehaviour
Name | |
---|---|
bool | getSyncVarHookGuard(ulong dirtyBit) |
void | setSyncVarHookGuard(ulong dirtyBit, bool value) |
void | InitSyncObject(SyncObject syncObject) |
void | SendCommandInternal(Type invokeClass, string cmdName, NetworkWriter writer, int channelId, bool ignoreAuthority =false) |
void | SendRPCInternal(Type invokeClass, string rpcName, NetworkWriter writer, int channelId, bool excludeOwner) |
void | SendTargetRPCInternal(NetworkConnection conn, Type invokeClass, string rpcName, NetworkWriter writer, int channelId) |
bool | SyncVarGameObjectEqual(GameObject newGameObject, uint netIdField) |
void | SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, ulong dirtyBit, ref uint netIdField) |
GameObject | GetSyncVarGameObject(uint netId, ref GameObject gameObjectField) |
bool | SyncVarNetworkIdentityEqual(NetworkIdentity newIdentity, uint netIdField) |
void | SetSyncVarNetworkIdentity(NetworkIdentity newIdentity, ref NetworkIdentity identityField, ulong dirtyBit, ref uint netIdField) |
NetworkIdentity | GetSyncVarNetworkIdentity(uint netId, ref NetworkIdentity identityField) |
bool | SyncVarEqual< T >(T value, ref T fieldValue) |
void | SetSyncVar< T >(T value, ref T fieldValue, ulong dirtyBit) |
virtual bool | SerializeSyncVars(NetworkWriter writer, bool initialState) |
virtual void | DeserializeSyncVars(NetworkReader reader, bool initialState) |
Public Properties inherited from NetworkBehaviour
Name | |
---|---|
NetworkIdentity | netIdentity Returns the NetworkIdentity of this object |
int | ComponentIndex Returns the index of the component on this object |
Protected Properties inherited from NetworkBehaviour
Name | |
---|---|
ulong | syncVarDirtyBits |
Public Attributes inherited from NetworkBehaviour
Name | |
---|---|
SyncMode | syncMode sync mode for OnSerialize |
float | syncInterval sync interval for OnSerialize (in seconds) |
bool | isServer Returns true if this object is active on an active server. |
bool | isClient Returns true if running as a client and this object was spawned by a server. |
bool | isLocalPlayer This returns true if this object is the one that represents the player on the local machine. |
bool | isServerOnly True if this object only exists on the server |
bool | isClientOnly True if this object exists on a client that is not also acting as a server |
bool | hasAuthority This returns true if this object is the authoritative version of the object in the distributed network application. |
uint | netId The unique network Id of this object. |
NetworkConnection | connectionToServer The NetworkConnection associated with this NetworkIdentity. This is only valid for player objects on the client. |
NetworkConnection | connectionToClient The NetworkConnection associated with this NetworkIdentity. This is only valid for player objects on the server. |
Protected Attributes inherited from NetworkBehaviour
Name | |
---|---|
readonly List< SyncObject > | syncObjects objects that can synchronize themselves, such as synclists |
Detailed Description
class Mirror::NetworkRoomPlayer;
This component works in conjunction with the NetworkRoomManager to make up the multiplayer room system.
The RoomPrefab object of the NetworkRoomManager must have this component on it. This component holds basic room player data required for the room to function. Game specific data for room players can be put in other components on the RoomPrefab or in scripts derived from NetworkRoomPlayer.
Public Functions Documentation
function Start
inline void Start()
Do not use Start - Override OnStartrHost / OnStartClient instead!
function OnDisable
inline virtual void OnDisable()
function CmdChangeReadyState
inline void CmdChangeReadyState(
bool readyState
)
function IndexChanged
inline virtual void IndexChanged(
int oldIndex,
int newIndex
)
This is a hook that is invoked on clients when the index changes.
Parameters:
- oldIndex The old index value
- newIndex The new index value
function ReadyStateChanged
inline virtual void ReadyStateChanged(
bool oldReadyState,
bool newReadyState
)
This is a hook that is invoked on clients when a RoomPlayer switches between ready or not ready.
Parameters:
- newReadyState New Ready State
Reimplemented by: Mirror::Examples::NetworkRoom::NetworkRoomPlayerExt::ReadyStateChanged
This function is called when the a client player calls CmdChangeReadyState.
function OnClientEnterRoom
inline virtual void OnClientEnterRoom()
This is a hook that is invoked on clients for all room player objects when entering the room.
Reimplemented by: Mirror::Examples::NetworkRoom::NetworkRoomPlayerExt::OnClientEnterRoom
Note: isLocalPlayer is not guaranteed to be set until OnStartLocalPlayer is called.
function OnClientExitRoom
inline virtual void OnClientExitRoom()
This is a hook that is invoked on clients for all room player objects when exiting the room.
Reimplemented by: Mirror::Examples::NetworkRoom::NetworkRoomPlayerExt::OnClientExitRoom
function OnGUI
inline virtual void OnGUI()
Render a UI for the room. Override to provide your on UI
Public Attributes Documentation
variable showRoomGUI
bool showRoomGUI = true;
This flag controls whether the default UI is shown for the room player.
As this UI is rendered using the old GUI system, it is only recommended for testing purposes.
variable readyToBegin
bool readyToBegin;
Diagnostic flag indicating whether this player is ready for the game to begin.
Invoke CmdChangeReadyState method on the client to set this flag.
When all players are ready to begin, the game will start. This should not be set directly, CmdChangeReadyState should be called on the client to set it on the server.
variable index
int index;
Diagnostic index of the player, e.g. Player1, Player2, etc.
Updated on 22 January 2021 at 08:52:35 UTC