Files
Tower-Defense2/include/server/ServerState.h
2025-08-20 12:18:44 +02:00

26 lines
684 B
C++

#pragma once
#include <server/Server.h>
#include <td/misc/SlotGuard.h>
namespace td {
namespace server {
class ServerState : public Server::State, private utils::SlotGuard {
public:
virtual void HandlePacket(PlayerID a_Id, const protocol::PacketBase& a_Packet) = 0;
virtual void Update(float a_Delta) = 0;
virtual void OnPlayerJoin(PlayerID a_Id, const td::PlayerInfo& a_Info) {}
virtual void OnPlayerLeave(PlayerID a_Id) {}
ServerState(Server& a_Server);
virtual ~ServerState();
protected:
void SendPacket(PlayerID a_Id, const protocol::PacketBase& a_Packet);
void BroadcastPacket(const protocol::PacketBase& a_Packet);
};
} // namespace server
} // namespace td