16 if (!optionalEvent.has_value()) {
25 std::cerr <<
"Invalid action received: " <<
event.type << std::endl;
bool performAction(const GameMessage &event, Registry &r)
Performs the action associated with the event.
bool validateAction(const GameMessage &event, Registry &r)
Validates the action associated with the event.
void event_system(Registry &r)
Processes events from the queue and performs actions.
@ P_SHOOT
Represents a player shooting event.
@ P_CONNECT
Represents a connecting player event.
@ P_KILL
Represents a kill event.
@ P_MOVE
Represents a movement event.
@ P_DISCONNECT
Represents a disconnecting player event.
void move_player(Registry &r, std::size_t id, float x, float y)
Moves a player to a specified position.
std::size_t getIdByClientId(Registry &r, const unsigned int client_id)
Gets entity id by the player's client id.
void spawn_player(Registry &r, const float pos_x, const float pos_y, const uint32_t client_id, const std::string &username)
Spawns a player with the specified username at the given position.
void make_shot(Registry &r, std::size_t id)
Changes the state of the weapon.
Represents an entity in an Entity-Component-System (ECS) architecture.
void notify(const GameMessage &event)
Notifies the subscribed listener of an event.
bool isEmpty()
Check if the queue is empty.
std::optional< GameMessage > pop()
Try to pop a GameMessage item from the queue.
Manages entities and their associated components, enabling the creation, deletion,...
void kill_entity(const Entity &entity)
Deletes an entity and removes all its components.
EventDispatcher * dispatcher
A structure representing a game message.
messageType type
The type of message (e.g., SPAWN, MOVE, etc.).
messageInfo msg
Additional information about the event (status, asset ID, and coordinates).
std::size_t id
The unique identifier for the entity or object involved in the event.
uint32_t cli_id
Id of the player's client.
coord coords
Coordinates associated with the event, such as the position of an entity.
char username[9]
Username of player connecting.