Files
Tower-Defense2/include/td/simulation/ServerSimulation.h
2025-08-04 12:47:27 +02:00

36 lines
792 B
C++

#pragma once
#include <mutex>
#include <td/game/World.h>
namespace td {
namespace sim {
// TODO: OnEnd signal
/**
* \note This class is thread safe
*/
class ServerSimulation : public protocol::CommandHandler {
private:
std::mutex m_Mutex;
game::World& m_World;
std::uint64_t m_StepTime;
std::uint64_t m_CurrentTime;
std::vector<td::protocol::LockStep> m_History;
using protocol::CommandHandler::Handle;
public:
ServerSimulation(game::World& a_World, std::uint64_t a_StepTime);
protocol::packets::LockStepsPacket Update();
// no checks are done !
virtual void Handle(const protocol::commands::SpawnTroopCommand& a_SpawnTroop) override;
virtual void Handle(const protocol::commands::PlaceTowerCommand& a_PlaceTower) override;
};
} // namespace sim
} // namespace td