begin client-server

This commit is contained in:
2025-08-06 20:10:56 +02:00
parent 89213e9a97
commit c813c49707
26 changed files with 264 additions and 188 deletions

View File

@@ -0,0 +1,24 @@
#include <server/state/GameState.h>
#include <server/state/GameStateHandler.h>
namespace td {
namespace server {
GameStateHandler::GameStateHandler(GameState& a_GameState, PlayerID a_PlayerId) : m_GameState(a_GameState), m_PlayerId(a_PlayerId) {}
// TODO: redo this
void GameStateHandler::Handle(const protocol::packets::SpawnTroopPacket& a_Packet) {
static const EntityCoords DEFAULT_POS(td::FpFloat(77), td::FpFloat(13));
td::protocol::commands::SpawnTroopCommand spawn(*a_Packet->m_Type, *a_Packet->m_Level, DEFAULT_POS, m_PlayerId);
m_GameState.m_Simulation.Handle(spawn);
}
// TODO: and this
void GameStateHandler::Handle(const protocol::packets::PlaceTowerPacket& a_Packet) {
td::protocol::commands::PlaceTowerCommand place(a_Packet->m_Type, m_PlayerId, a_Packet->m_Position);
m_GameState.m_Simulation.Handle(place);
}
} // namespace server
} // namespace td