begin serversimulation
This commit is contained in:
@@ -9,7 +9,8 @@ namespace sim {
|
||||
using GameHistory = std::vector<td::protocol::LockStep>;
|
||||
using GameBuffer = std::vector<std::optional<td::protocol::LockStep>>;
|
||||
|
||||
class RealTimeSimulation {
|
||||
// TODO: OnEnd signal
|
||||
class ClientSimulation : public protocol::PacketHandler {
|
||||
private:
|
||||
std::uint64_t m_StepTime;
|
||||
game::World& m_World;
|
||||
@@ -28,21 +29,21 @@ class RealTimeSimulation {
|
||||
* \brief Replay constructor
|
||||
* \param a_StepTime in ms
|
||||
*/
|
||||
RealTimeSimulation(game::World& a_World, GameHistory&& a_History, std::uint64_t a_StepTime);
|
||||
ClientSimulation(game::World& a_World, GameHistory&& a_History, std::uint64_t a_StepTime);
|
||||
|
||||
/**
|
||||
* \brief Live update constructor (continuous game updates)
|
||||
* \param a_StepTime in ms
|
||||
*/
|
||||
RealTimeSimulation(game::World& a_World, std::uint64_t a_StepTime);
|
||||
ClientSimulation(game::World& a_World, std::uint64_t a_StepTime);
|
||||
|
||||
/**
|
||||
* \return the progress [0-1] between two steps
|
||||
*/
|
||||
float Update();
|
||||
|
||||
void HandlePacket(const protocol::packets::LockStepsPacket& a_LockSteps);
|
||||
void HandlePacket(const protocol::packets::PredictCommandPacket& a_Predict);
|
||||
void Handle(const protocol::packets::LockStepsPacket& a_LockSteps) override;
|
||||
void Handle(const protocol::packets::PredictCommandPacket& a_Predict) override;
|
||||
|
||||
private:
|
||||
void Step();
|
||||
22
include/td/simulation/ServerSimulation.h
Normal file
22
include/td/simulation/ServerSimulation.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <td/game/World.h>
|
||||
|
||||
namespace td {
|
||||
namespace sim {
|
||||
|
||||
// TODO: OnEnd signal
|
||||
class ServerSimulation {
|
||||
private:
|
||||
game::World& m_World;
|
||||
std::uint64_t m_StepTime;
|
||||
std::uint64_t m_CurrentTime;
|
||||
|
||||
public:
|
||||
ServerSimulation(game::World& a_World, std::uint64_t a_StepTime);
|
||||
|
||||
void Update();
|
||||
};
|
||||
|
||||
} // namespace sim
|
||||
} // namespace td
|
||||
Reference in New Issue
Block a user