WIP
Adding models now crashes. Threading Added a create player event that currently is not used.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
|
||||
|
||||
class Client
|
||||
@@ -75,6 +76,8 @@ private:
|
||||
bool OnKeyDown(const Events::KeyDown &e);
|
||||
EventRelay<Client, Events::KeyUp> m_EKeyUp;
|
||||
bool OnKeyUp(const Events::KeyUp &e);
|
||||
EventRelay<Client, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand &e);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
|
||||
struct PlayerDefinition {
|
||||
int EntityID = -1;
|
||||
unsigned int EntityID = -1;
|
||||
std::string Name = "";
|
||||
boost::asio::ip::udp::endpoint Endpoint;
|
||||
};
|
||||
|
||||
@@ -12,13 +12,15 @@
|
||||
#include "Network/NetworkDefinitions.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/ECreatePlayer.h"
|
||||
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server();
|
||||
~Server();
|
||||
void Start(World* m_world);
|
||||
void Start(World* m_world, EventBroker *eventBroker);
|
||||
void Close();
|
||||
|
||||
private:
|
||||
@@ -32,6 +34,7 @@ private:
|
||||
std::clock_t m_StopTimes[8];
|
||||
// Game logic
|
||||
World* m_World;
|
||||
EventBroker* m_EventBroker;
|
||||
// Packet loss logic
|
||||
unsigned int m_PacketID;
|
||||
unsigned int m_PreviousPacketID;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef Events_CreatePlayer_h__
|
||||
#define Events_CreatePlayer_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct CreatePlayer : Event
|
||||
{
|
||||
unsigned int entityID;
|
||||
std::string modelPath;
|
||||
World* world;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "ECreatePlayer.h"
|
||||
|
||||
struct KeyInput
|
||||
{
|
||||
@@ -26,6 +27,7 @@ public:
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &PlayerSystem::OnKeyDown);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &PlayerSystem::OnKeyUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECreatePlayer, &PlayerSystem::OnCreatePlayer);
|
||||
}
|
||||
|
||||
virtual void Update(World* world, ComponentWrapper& player, double dt) override;
|
||||
@@ -34,11 +36,15 @@ private:
|
||||
float m_Speed = 5;
|
||||
glm::vec3 m_Direction;
|
||||
KeyInput input;
|
||||
bool ShouldCreatePlayer = false;
|
||||
|
||||
void CreatePlayer(World * world, unsigned int& entityID);
|
||||
EventRelay<PlayerSystem, Events::KeyDown> m_EKeyDown;
|
||||
bool OnKeyDown(const Events::KeyDown &event);
|
||||
EventRelay<PlayerSystem, Events::KeyUp> m_EKeyUp;
|
||||
bool OnKeyUp(const Events::KeyUp &event);
|
||||
EventRelay<PlayerSystem, Events::CreatePlayer> m_ECreatePlayer;
|
||||
bool OnCreatePlayer(const Events::CreatePlayer &event);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user