41 lines
967 B
C++
41 lines
967 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, const 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(const WorldSnapshot& a_PreviousState);
|
|
|
|
template <typename T>
|
|
void AddSystem() {
|
|
m_Systems.push_back(std::move(std::make_unique<T>()));
|
|
}
|
|
};
|
|
|
|
} // namespace sim
|
|
} // namespace td
|