Files
Tower-Defense2/include/td/simulation/WorldTicker.h
2025-07-18 18:56:49 +02:00

41 lines
955 B
C++

#pragma once
#include <td/protocol/command/Commands.h>
#include <td/simulation/WorldSnapshot.h>
namespace td {
namespace game {
class World;
}
namespace sim {
class IWorldSystem {
public:
virtual void Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloat a_Delta) = 0;
};
class WorldTicker {
private:
std::vector<std::unique_ptr<IWorldSystem>> m_Systems;
public:
WorldTicker();
WorldSnapshot NextStep(
const game::World& a_World, WorldSnapshot& a_PreviousState, const protocol::LockStep& a_LockStep, FpFloat a_Delta);
private:
void ApplySteps(const game::World& a_World, WorldSnapshot& a_State, const protocol::LockStep& a_LockStep);
void Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloat a_Delta);
WorldSnapshot CreateNext(WorldSnapshot& a_PreviousState);
template <typename T>
void AddSystem() {
m_Systems.push_back(std::move(std::make_unique<T>()));
}
};
} // namespace sim
} // namespace td