group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
ServerGame.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
8#include "network/Server.hpp"
10
11#include <SDL3/SDL.h>
12
13#include <entt/entity/entity.hpp>
14#include <unordered_map>
15
21{
22public:
28 bool init(const char* addr, Uint16 port, int tickRateHz = 128);
29
31 void run();
32
34 void shutdown();
35
36private:
39 void eventHandler(Event event);
40
44 void tick(float dt, Uint64 nextTick);
45
48 void initNewPlayerEntity(ClientId clientId);
49
52 void deletePlayerEntity(ClientId clientId);
53
54 Server server;
55 Registry registry;
56 MatchController matchController;
57 std::unordered_map<ClientId, entt::entity> clientEntities;
58 bool running = false;
59 int tickRateHz = 128;
60 int tickCount = 0;
61};
Network client identifier component for multiplayer entities.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
TCP game server that accepts clients and dispatches incoming packets.
A single gameplay event produced by network input processing.
Definition Event.hpp:10
Definition MatchController.hpp:10
Top-level server game loop.
Definition ServerGame.hpp:21
void shutdown()
Signal the loop to stop and release all resources.
Definition ServerGame.cpp:68
void run()
Block and run the game loop until shutdown() is called.
Definition ServerGame.cpp:40
bool init(const char *addr, Uint16 port, int tickRateHz=128)
Bind to the given address and port, spawn test entities.
Definition ServerGame.cpp:28
TCP stream socket — receives client packets and echoes them back.
Definition Server.hpp:24
Associates an entity with a connected network client.
Definition ClientId.hpp:10