#pragma once #include #include 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 m_History; using protocol::CommandHandler::Handle; public: ServerSimulation(game::World& a_World, std::uint64_t a_StepTime); protocol::packets::LockStepsPacket Update(); protocol::packets::LockStepsPacket MakePacket(); // no checks are done ! virtual void Handle(const protocol::commands::SpawnTroopCommand& a_SpawnTroop) override; virtual void Handle(const protocol::commands::PlaceTowerCommand& a_PlaceTower) override; protocol::packets::LockStepResponsePacket GetResponse(const protocol::packets::LockStepRequestPacket& a_Missing) const; }; } // namespace sim } // namespace td