38 lines
843 B
C++
38 lines
843 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();
|
|
|
|
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;
|
|
};
|
|
|
|
} // namespace sim
|
|
} // namespace td
|