Merge remote-tracking branch 'origin/Networking' into Networking

This commit is contained in:
Jocke
2016-01-18 17:13:10 +01:00
6 changed files with 119 additions and 1 deletions
+1
View File
@@ -19,6 +19,7 @@
#include "Core/ConfigFile.h"
#include "Input/EInputCommand.h"
#include "Core/EPlayerDamage.h"
#include "Network/EInterpolate.h"
class Client : public Network
{
+20
View File
@@ -0,0 +1,20 @@
#ifndef Events_Interpolate_h__
#define Events_Interpolate_h__
#include <boost/shared_array.hpp>
#include "Core/EventBroker.h"
#include "Core/Entity.h"
namespace Events
{
struct Interpolate : Event
{
EntityID Entity;
boost::shared_array<char> DataArray;
};
}
#endif
+42
View File
@@ -0,0 +1,42 @@
#ifndef Systems_InterpolationSystem_h__
#define Systems_InterpolationSystem_h__
#include <queue>
#include <unordered_map>
#include <boost/shared_array.hpp>
#include <glm/common.hpp>
#include "Common.h"
#include "Core/System.h"
#include "Core/EventBroker.h"
#include "Network/EInterpolate.h"
struct Transform {
glm::vec3 Position;
glm::vec3 Scale;
glm::vec3 Orientation;
double interpolationTime;
};
class InterpolationSystem : public PureSystem
{
public:
InterpolationSystem(EventBroker* eventbroker)
: PureSystem(eventbroker, "Transform")
{
EVENT_SUBSCRIBE_MEMBER(m_EInterpolate, &InterpolationSystem::OnInterpolate);
}
~InterpolationSystem() { }
virtual void UpdateComponent(World* world, ComponentWrapper& transform, double dt) override;
private:
std::unordered_map<EntityID, std::queue<Transform>> m_InterpolationPoints;
glm::vec3 vectorInterpolation(glm::vec3 prev, glm::vec3 next, double currentTime);
EventRelay<InterpolationSystem, Events::Interpolate> m_EInterpolate;
bool InterpolationSystem::OnInterpolate(const Events::Interpolate& e);
};
#endif