add StateMachine
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <server/IServerState.h>
|
||||
#include <server/ServerState.h>
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
class EndGameState : public IServerState {
|
||||
class EndGameState : public ServerState {
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <server/IServerState.h>
|
||||
#include <server/ServerState.h>
|
||||
#include <td/game/World.h>
|
||||
#include <td/simulation/ServerSimulation.h>
|
||||
|
||||
@@ -9,23 +9,18 @@ namespace server {
|
||||
|
||||
class GameStateHandler;
|
||||
|
||||
class GameState : public IServerState {
|
||||
class GameState : public ServerState {
|
||||
private:
|
||||
std::shared_ptr<game::World> m_World;
|
||||
sim::ServerSimulation m_Simulation;
|
||||
float m_Time;
|
||||
|
||||
public:
|
||||
GameState(const std::shared_ptr<game::World>& a_World);
|
||||
GameState(Server& a_Server, const std::shared_ptr<game::World>& a_World);
|
||||
~GameState() {}
|
||||
|
||||
virtual void HandlePacket(PlayerID a_Id, const protocol::PacketBase& a_Packet) override;
|
||||
virtual void Update(float a_Delta) override;
|
||||
virtual void OnPlayerJoin(PlayerID a_Id) override;
|
||||
virtual void OnPlayerLeave(PlayerID a_Id) override;
|
||||
|
||||
protected:
|
||||
virtual void Init() override;
|
||||
|
||||
friend class GameStateHandler;
|
||||
};
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <server/IServerState.h>
|
||||
#include <server/ServerState.h>
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
// this class is temporary useless
|
||||
class LobbyState : public IServerState {
|
||||
class LobbyState : public ServerState {
|
||||
private:
|
||||
std::shared_ptr<game::World> m_World;
|
||||
public:
|
||||
LobbyState(const std::shared_ptr<game::World>& a_World) : m_World(a_World) {}
|
||||
LobbyState(Server& a_Server, const std::shared_ptr<game::World>& a_World);
|
||||
~LobbyState() {}
|
||||
|
||||
virtual void HandlePacket(PlayerID a_Id, const protocol::PacketBase& a_Packet) override;
|
||||
virtual void Update(float a_Delta) override;
|
||||
virtual void OnPlayerJoin(PlayerID a_Id) override;
|
||||
virtual void OnPlayerLeave(PlayerID a_Id) override;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
Reference in New Issue
Block a user