Merge remote-tracking branch 'origin/Networking' into Networking
This commit is contained in:
@@ -26,6 +26,7 @@ struct EntityWrapper
|
|||||||
bool HasComponent(const std::string& componentName);
|
bool HasComponent(const std::string& componentName);
|
||||||
EntityWrapper Parent();
|
EntityWrapper Parent();
|
||||||
EntityWrapper FirstChildByName(const std::string& name);
|
EntityWrapper FirstChildByName(const std::string& name);
|
||||||
|
bool IsChildOf(EntityWrapper potentialParent);
|
||||||
bool Valid();
|
bool Valid();
|
||||||
|
|
||||||
ComponentWrapper operator[](const char* componentName);
|
ComponentWrapper operator[](const char* componentName);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Network/EInterpolate.h"
|
#include "Network/EInterpolate.h"
|
||||||
#include "Game/Events/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
|
||||||
class Client : public Network
|
class Client : public Network
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Game/Events/EPlayerSpawned.h"
|
|
||||||
|
|
||||||
class Server : public Network
|
class Server : public Network
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "PointLightJob.h"
|
#include "PointLightJob.h"
|
||||||
#include "../Core/Transform.h"
|
#include "../Core/Transform.h"
|
||||||
#include "../../Game/Events/EPlayerSpawned.h"
|
#include "../Core/EPlayerSpawned.h"
|
||||||
|
|
||||||
class RenderSystem : public ImpureSystem
|
class RenderSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/ResourceManager.h"
|
#include "Core/ResourceManager.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
#include "Events/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
|
||||||
#include "Network/EInterpolate.h"
|
#include "Network/EInterpolate.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "GLM.h"
|
#include "GLM.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Events/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Input/FirstPersonInputController.h"
|
#include "Input/FirstPersonInputController.h"
|
||||||
|
|
||||||
class PlayerMovementSystem : public ImpureSystem, PureSystem
|
class PlayerMovementSystem : public ImpureSystem, PureSystem
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Systems/SpawnerSystem.h"
|
#include "Systems/SpawnerSystem.h"
|
||||||
#include "Events/ESpawnerSpawn.h"
|
#include "Events/ESpawnerSpawn.h"
|
||||||
#include "Events/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Rendering/ESetCamera.h"
|
#include "Rendering/ESetCamera.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,18 @@ EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
|
|||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
|
||||||
|
{
|
||||||
|
EntityWrapper entity = *this;
|
||||||
|
while (entity.Parent().Valid()) {
|
||||||
|
entity = entity.Parent();
|
||||||
|
if (entity == potentialParent) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool EntityWrapper::Valid()
|
bool EntityWrapper::Valid()
|
||||||
{
|
{
|
||||||
if (this->World == nullptr) {
|
if (this->World == nullptr) {
|
||||||
|
|||||||
@@ -48,14 +48,9 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
EntityWrapper entity(m_World, modelComponent.EntityID);
|
EntityWrapper entity(m_World, modelComponent.EntityID);
|
||||||
bool isLocalPlayer = entity == m_LocalPlayer;
|
|
||||||
while (entity.Parent().Valid()) {
|
// Don't render the local player
|
||||||
entity = entity.Parent();
|
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
|
||||||
if (entity == m_LocalPlayer) {
|
|
||||||
isLocalPlayer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isLocalPlayer) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,18 +144,6 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityWrapper entity(m_World, textComponent.EntityID);
|
|
||||||
bool isLocalPlayer = entity == m_LocalPlayer;
|
|
||||||
while (entity.Parent().Valid()) {
|
|
||||||
entity = entity.Parent();
|
|
||||||
if (entity == m_LocalPlayer) {
|
|
||||||
isLocalPlayer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isLocalPlayer) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Font* font;
|
Font* font;
|
||||||
try {
|
try {
|
||||||
font = ResourceManager::Load<Font>(resource);
|
font = ResourceManager::Load<Font>(resource);
|
||||||
|
|||||||
@@ -27,16 +27,17 @@ void InterpolationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transform.Info.Name == "Transform") {
|
if (transform.Info.Name == "Transform") {
|
||||||
bool isLocalPlayer = entity == m_LocalPlayer || entity.Parent() == m_LocalPlayer;
|
bool isLocalPlayer = entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer);
|
||||||
// Position
|
// Position
|
||||||
glm::vec3 nextPosition = sTransform.Position;
|
glm::vec3 nextPosition = sTransform.Position;
|
||||||
glm::vec3 currentPosition = static_cast<glm::vec3>(transform["Position"]);
|
glm::vec3 currentPosition = static_cast<glm::vec3>(transform["Position"]);
|
||||||
|
// HACK: Hardcoded tolerance value for player position desync = 1
|
||||||
if (isLocalPlayer && glm::length(nextPosition - currentPosition) < 1.f) {
|
if (isLocalPlayer && glm::length(nextPosition - currentPosition) < 1.f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(glm::vec3&)transform["Position"] += vectorInterpolation<glm::vec3>(currentPosition, nextPosition, sTransform.interpolationTime);
|
(glm::vec3&)transform["Position"] += vectorInterpolation<glm::vec3>(currentPosition, nextPosition, sTransform.interpolationTime);
|
||||||
// Orientation
|
// Orientation
|
||||||
//bool isPlayer = entity.HasComponent("Player") || entity.Parent().HasComponent("Player");
|
// Don't force orientation for players
|
||||||
if (!isLocalPlayer) {
|
if (!isLocalPlayer) {
|
||||||
glm::quat nextOrientation = sTransform.Orientation;
|
glm::quat nextOrientation = sTransform.Orientation;
|
||||||
glm::quat currentOrientation = glm::quat(static_cast<glm::vec3>(transform["Orientation"]));
|
glm::quat currentOrientation = glm::quat(static_cast<glm::vec3>(transform["Orientation"]));
|
||||||
|
|||||||
Reference in New Issue
Block a user