GodotMattohaLobbySystem 0.2.4
Loading...
Searching...
No Matches
Mattoha.Nodes.MattohaSystem Class Reference

Public Member Functions

delegate void ServerRpcReceivedEventHandler (string methodName, Dictionary< string, Variant > payload, long sender)
 Emmited on server when a server rpc received.
 
delegate void ClientRpcReceivedEventHandler (string methodName, Dictionary< string, Variant > payload, long sender)
 Emmited on client when a client rpc received.
 
override void _Ready ()
 
Node GetLobbyNodeFor (Node node)
 Get lobby node from a given node.
 
void StartServer ()
 Start Server that clients wil connect to.
 
void StartClient ()
 Establish a connection to server.
 
Node CreateInstance (string sceneFile)
 Used to create an instance from scene, use this method to initialize instance if the instance will be spawned for all players or has MattohaSpawner node.
 
Node CreateInstance (PackedScene scene)
 Used to create an instance from scene, use this method to initialize instance if the instance will be spawned for all players or has MattohaSpawner node.
 
void SpawnNodeFromPayload (Dictionary< string, Variant > payload)
 spawn a node by a payload generated by "GenerateNodePayloadData()", this method is used under the hood to spawn nodes.
 
void DespawnNodeFromPayload (Dictionary< string, Variant > payload)
 despawn a node by a payload generated by "GenerateNodePayloadData()", this method is used under the hood to despawn nodes.
 
Dictionary< string, Variant > GenerateNodePayloadData (Node node, Array< string > additionalProps=null)
 Generate a spawning payload form a given node, this method is used under the hood to generate payloads for spawning nodes across players.
 
void SendReliableServerRpc (string methodName, Dictionary< string, Variant > payload)
 Send reliable server RPC to server, this will emmit "ServerRpcReceived".
 
void SendReliableClientRpc (long peer, string methodName, Dictionary< string, Variant > payload)
 Send reliable client RPC to peer, this will emmit "ClientRpcReceived".
 
bool IsNodeOwner (Node node)
 Check if (current player) is the owner of the spawned node or a given node.
 
bool IsLobbyOwner ()
 Check if (Current client) is the owner of the lobby.
 

Static Public Member Functions

static int ExtractLobbyId (string nodePath)
 Extract Lobby ID from node path, all lobby games has "LobbyNN" when NN is the lobby ID.
 

Properties

string Address = "127.0.0.1" [get, set]
 
int Port = 7001 [get, set]
 
int MaxChannels = 5 [get, set]
 
int MaxPlayers = 4000 [get, set]
 
int MaxLobbiesCount = 100 [get, set]
 
int MaxPlayersPerLobby = 10 [get, set]
 
bool AutoLoadAvailableLobbies = true [get, set]
 When lobby data changed or game started, auto load available lobbies for all online players.
 
MattohaServer Server [get]
 
MattohaClient Client [get]
 
long LobbySize = 5000 [get, set]
 Server split lobbies along x axis, specify lobby size will prevent overlapping available lobbies.
 
static MattohaSystem Instance [get, set]
 

Member Function Documentation

◆ ClientRpcReceivedEventHandler()

delegate void Mattoha.Nodes.MattohaSystem.ClientRpcReceivedEventHandler ( string methodName,
Dictionary< string, Variant > payload,
long sender )

Emmited on client when a client rpc received.

Parameters
methodNamemethod name to call.
payloadpayload as godot dictionaty.
senderpeer id who send the rpc.

◆ CreateInstance() [1/2]

Node Mattoha.Nodes.MattohaSystem.CreateInstance ( PackedScene scene)

Used to create an instance from scene, use this method to initialize instance if the instance will be spawned for all players or has MattohaSpawner node.

Parameters
scenePackedScene to initialize from.
Returns
Created node instance with multiplayer authority that belongs to the owner of node who created it.

◆ CreateInstance() [2/2]

Node Mattoha.Nodes.MattohaSystem.CreateInstance ( string sceneFile)

Used to create an instance from scene, use this method to initialize instance if the instance will be spawned for all players or has MattohaSpawner node.

Parameters
sceneFileScene file to initialize from.
Returns
Created node instance with multiplayer authority that belongs to the owner of node who created it.

◆ DespawnNodeFromPayload()

void Mattoha.Nodes.MattohaSystem.DespawnNodeFromPayload ( Dictionary< string, Variant > payload)

despawn a node by a payload generated by "GenerateNodePayloadData()", this method is used under the hood to despawn nodes.

Parameters
payloadspawn node payload

◆ ExtractLobbyId()

static int Mattoha.Nodes.MattohaSystem.ExtractLobbyId ( string nodePath)
static

Extract Lobby ID from node path, all lobby games has "LobbyNN" when NN is the lobby ID.

Parameters
nodePathnode path to extract lobby id from.
Returns
extracted lobby id.

◆ GenerateNodePayloadData()

Dictionary< string, Variant > Mattoha.Nodes.MattohaSystem.GenerateNodePayloadData ( Node node,
Array< string > additionalProps = null )

Generate a spawning payload form a given node, this method is used under the hood to generate payloads for spawning nodes across players.

Parameters
nodeNode object (should be in game tree)
additionalPropsAdditional properties to get from node, these will be synced to other players.
Returns
Dictionary that has node data to spawn

◆ IsLobbyOwner()

bool Mattoha.Nodes.MattohaSystem.IsLobbyOwner ( )

Check if (Current client) is the owner of the lobby.

Returns
true if current client is the owner of joined lobby.

◆ IsNodeOwner()

bool Mattoha.Nodes.MattohaSystem.IsNodeOwner ( Node node)

Check if (current player) is the owner of the spawned node or a given node.

Parameters
node
Returns
true if the current player is the owner

◆ SendReliableClientRpc()

void Mattoha.Nodes.MattohaSystem.SendReliableClientRpc ( long peer,
string methodName,
Dictionary< string, Variant > payload )

Send reliable client RPC to peer, this will emmit "ClientRpcReceived".

Parameters
peerpeer id that will recive the event, 0 for all
methodNamemethod name you want to handle.
payload

◆ SendReliableServerRpc()

void Mattoha.Nodes.MattohaSystem.SendReliableServerRpc ( string methodName,
Dictionary< string, Variant > payload )

Send reliable server RPC to server, this will emmit "ServerRpcReceived".

Parameters
methodNamemethod name you want to handle.
payload

◆ ServerRpcReceivedEventHandler()

delegate void Mattoha.Nodes.MattohaSystem.ServerRpcReceivedEventHandler ( string methodName,
Dictionary< string, Variant > payload,
long sender )

Emmited on server when a server rpc received.

Parameters
methodNamemethod name to call.
payloadpayload as godot dictionaty.
senderpeer id who send the rpc.

◆ SpawnNodeFromPayload()

void Mattoha.Nodes.MattohaSystem.SpawnNodeFromPayload ( Dictionary< string, Variant > payload)

spawn a node by a payload generated by "GenerateNodePayloadData()", this method is used under the hood to spawn nodes.

Parameters
payloadspawn node payload