Celte
Loading...
Searching...
No Matches
celte::api::HooksTable Class Reference

To allow maximum customization of celte's behaviors, most actions taken by celte can be coupled with user defined hooks. More...

#include <CelteHooks.hpp>

Public Member Functions

template<typename T , typename... Args>
bool Call (T &&hook, Args &&...args)
 This function will call the hook if it is not null.
 

Public Attributes

struct { 
 
   struct { 
 
      std::function< bool()>   onConnectionProcedureInitiated 
 This hook is called when the server starts trying to reach for the kafka cluster. More...
 
      std::function< bool()>   onConnectionSuccess = []() { return true; } 
 This hook is called when the server successfully connects to the kafka cluster.
 
      std::function< bool()>   onConnectionError = []() { return true; } 
 This hook is called when the server fails to connect to the kafka cluster.
 
      std::function< bool()>   onServerDisconnected = []() { return true; } 
 This hook is called when the server is disconnected from the kafka cluster for any reason.
 
      std::function< std::tuple< std::string, float, float, float >(std::string)>   onSpawnPositionRequest 
 This hook is called when the master receives a new connection and must decide where to redirect the player. The game dev is expected to look up the player's last known position and data, and return it so that it can be forwarded to the server node. More...
 
   }   connection 
 
   struct { 
 
      std::function< bool(std::string)>   accept 
 This hook is called when a new player connects to the server. More...
 
      std::function< bool(std::string, int, int, int)>   execPlayerSpawn 
 This hook is called when a new player connects to the server, and must be instantiated in the game world. More...
 
   }   newPlayerConnected 
 
   struct { 
 
      std::function< bool(std::string)>   loadGrape 
 This hook is called when the server is informed that a new grape has been assigned to it. More...
 
   }   grape 
 This collection of hooks regroups all hooks related to managing the lifecycle of a grape, and instantiating it into the game world.
 
server 
 

Detailed Description

To allow maximum customization of celte's behaviors, most actions taken by celte can be coupled with user defined hooks.

pre_cev should return a boolean which, if false, will prevent the event cev from being processed and abord the procedure.

Member Function Documentation

◆ Call()

template<typename T , typename... Args>
bool celte::api::HooksTable::Call ( T && hook,
Args &&... args )
inline

This function will call the hook if it is not null.

Template Parameters
TThe type of the hook.
ArgsThe type of the arguments to pass to the hook

Member Data Documentation

◆ accept

std::function<bool(std::string)> celte::api::HooksTable::accept
Initial value:
= [](std::string clientId) {
return true;
}

This hook is called when a new player connects to the server.

◆ execPlayerSpawn

std::function<bool(std::string, int, int, int)> celte::api::HooksTable::execPlayerSpawn
Initial value:
=
[](std::string clientId, int x, int y, int z) { return true; }

This hook is called when a new player connects to the server, and must be instantiated in the game world.

◆ loadGrape

std::function<bool(std::string)> celte::api::HooksTable::loadGrape
Initial value:
= [](std::string grapeId) {
return true;
}

This hook is called when the server is informed that a new grape has been assigned to it.

◆ onConnectionProcedureInitiated

std::function<bool()> celte::api::HooksTable::onConnectionProcedureInitiated
Initial value:
= []() {
return true;
}

This hook is called when the server starts trying to reach for the kafka cluster.

◆ onSpawnPositionRequest

std::function<std::tuple<std::string, float, float, float>(std::string)> celte::api::HooksTable::onSpawnPositionRequest
Initial value:
= [](std::string clientId) {
return std::make_tuple(
"hook onSpawnPositionRequest not implemented", 0, 0, 0);
}

This hook is called when the master receives a new connection and must decide where to redirect the player. The game dev is expected to look up the player's last known position and data, and return it so that it can be forwarded to the server node.

The hook is called by the impolementation of celte::server::states::Connected::__rp_getPlayerSpawnPosition.

Returns
A tuple containing the grape id, the x, y, z coordinates of the spawn for the client that has been requested

The documentation for this class was generated from the following file: