pupush
This commit is contained in:
10
include/td/Constants.h
Normal file
10
include/td/Constants.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace td {
|
||||
|
||||
constexpr int TPS = 20;
|
||||
constexpr float STEP_PERIOD = 1.0f / static_cast<float>(TPS);
|
||||
|
||||
} // namespace td
|
||||
@@ -66,5 +66,6 @@ struct EntityCoords {
|
||||
};
|
||||
|
||||
using PeerID = std::uint16_t;
|
||||
using StepsType = std::uint16_t;
|
||||
|
||||
} // namespace td
|
||||
|
||||
@@ -9,12 +9,10 @@ namespace game {
|
||||
|
||||
class GameHistory {
|
||||
private:
|
||||
using HistorySizeType = std::uint16_t;
|
||||
using HistorySizeType = StepsType;
|
||||
|
||||
std::vector<std::optional<protocol::LockStep>> m_History;
|
||||
|
||||
HistorySizeType m_Cursor;
|
||||
|
||||
public:
|
||||
GameHistory();
|
||||
|
||||
@@ -24,10 +22,6 @@ class GameHistory {
|
||||
|
||||
bool HasLockStep(HistorySizeType a_Index) const;
|
||||
|
||||
const protocol::LockStep& GetNextStep();
|
||||
|
||||
bool HasNextStep() const;
|
||||
|
||||
void FromPacket(td::protocol::pdata::LockSteps&& a_Steps);
|
||||
|
||||
td::protocol::packets::LockSteps ToPacket(HistorySizeType a_StartIndex);
|
||||
|
||||
27
include/td/game/World.h
Normal file
27
include/td/game/World.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <td/game/GameHistory.h>
|
||||
#include <td/game/WorldState.h>
|
||||
#include <vector>
|
||||
|
||||
namespace td {
|
||||
namespace game {
|
||||
|
||||
class World {
|
||||
private:
|
||||
std::vector<WorldState> m_WorldStates;
|
||||
GameHistory m_GameHistory;
|
||||
|
||||
float m_OffsetTime;
|
||||
|
||||
public:
|
||||
World();
|
||||
|
||||
void Tick(float a_Delta);
|
||||
|
||||
private:
|
||||
std::uint16_t GetCursorPos();
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
} // namespace td
|
||||
21
include/td/game/WorldState.h
Normal file
21
include/td/game/WorldState.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <td/protocol/command/Commands.h>
|
||||
|
||||
namespace td {
|
||||
namespace game {
|
||||
|
||||
class WorldState {
|
||||
private:
|
||||
// list of players, mobs, towers, castles
|
||||
public:
|
||||
WorldState() {}
|
||||
|
||||
WorldState GetNextState(const protocol::LockStep& a_Step);
|
||||
|
||||
private:
|
||||
void Tick(float a_Delta);
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
} // namespace td
|
||||
1
include/td/network/EnetClient.h
Normal file
1
include/td/network/EnetClient.h
Normal file
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
1
include/td/network/EnetConnection.h
Normal file
1
include/td/network/EnetConnection.h
Normal file
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
1
include/td/network/EnetServer.h
Normal file
1
include/td/network/EnetServer.h
Normal file
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
Reference in New Issue
Block a user