begin serversimulation
This commit is contained in:
@@ -21,10 +21,8 @@ struct UpgradeTower {
|
||||
sp::BitField<std::uint8_t, 4> m_Upgrade;
|
||||
};
|
||||
|
||||
using EntityTypeInt = std::uint8_t;
|
||||
|
||||
struct SpawnTroop {
|
||||
sp::BitField<EntityTypeInt, 5> m_Type;
|
||||
sp::BitField<EntityType, 5> m_Type;
|
||||
sp::BitField<std::uint8_t, 3> m_Level;
|
||||
EntityCoords m_Position;
|
||||
PlayerID m_Sender;
|
||||
|
||||
@@ -95,6 +95,16 @@ struct WorldData {
|
||||
game::ChunkList m_Chunks;
|
||||
};
|
||||
|
||||
struct SpawnTroop {
|
||||
sp::BitField<EntityType, 5> m_Type;
|
||||
sp::BitField<std::uint8_t, 3> m_Level;
|
||||
};
|
||||
|
||||
struct PlaceTower {
|
||||
TowerType m_Type;
|
||||
TowerCoords m_Position;
|
||||
};
|
||||
|
||||
} // namespace pdata
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
|
||||
@@ -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