Merge branch 'WeaponSystem'
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "../Core/EPlayerSpawned.h"
|
#include "../Core/EPlayerSpawned.h"
|
||||||
#include "../Core/Octree.h"
|
#include "../Core/Octree.h"
|
||||||
#include "../Collision/EntityAABB.h"
|
#include "../Collision/EntityAABB.h"
|
||||||
|
#include "../Core/ConfigFile.h"
|
||||||
|
|
||||||
class RenderSystem : public ImpureSystem
|
class RenderSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -48,6 +49,9 @@ private:
|
|||||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
||||||
void fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
|
||||||
|
bool isEntityVisible(EntityWrapper& entity);
|
||||||
|
|
||||||
bool isChildOfACamera(EntityWrapper entity);
|
bool isChildOfACamera(EntityWrapper entity);
|
||||||
bool isChildOfCurrentCamera(EntityWrapper entity);
|
bool isChildOfCurrentCamera(EntityWrapper entity);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ public:
|
|||||||
DamageIndicatorSystem(SystemParams params);
|
DamageIndicatorSystem(SystemParams params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<DamageIndicatorSystem, Events::PlayerDamage> m_DamageTakenFromPlayer;
|
EventRelay<DamageIndicatorSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
bool OnPlayerDamageTaken(Events::PlayerDamage& e);
|
bool OnPlayerDamage(Events::PlayerDamage& e);
|
||||||
|
|
||||||
EventRelay<DamageIndicatorSystem, Events::SetCamera> m_ESetCamera;
|
EventRelay<DamageIndicatorSystem, Events::SetCamera> m_ESetCamera;
|
||||||
bool OnSetCamera(const Events::SetCamera& e);
|
bool OnSetCamera(const Events::SetCamera& e);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ LoadMap=
|
|||||||
; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation.
|
; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation.
|
||||||
; if false -> Use pool allocation.
|
; if false -> Use pool allocation.
|
||||||
DisableMemoryPool=false
|
DisableMemoryPool=false
|
||||||
|
EditorEnabled=false
|
||||||
|
OutOfBodyExperience=false
|
||||||
|
|
||||||
[Editor]
|
[Editor]
|
||||||
CameraSpeed=3
|
CameraSpeed=3
|
||||||
|
|||||||
@@ -47,16 +47,8 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EntityWrapper entity(world, cSprite.EntityID);
|
EntityWrapper entity(world, cSprite.EntityID);
|
||||||
|
if (!isEntityVisible(entity)) {
|
||||||
// Only render children of a camera if that camera is currently active
|
|
||||||
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
|
||||||
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +77,23 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderSystem::isEntityVisible(EntityWrapper& entity)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Only render children of a camera if that camera is currently active
|
||||||
|
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||||
|
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
|
||||||
|
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) && !outOfBodyExperience) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool RenderSystem::isChildOfACamera(EntityWrapper entity)
|
bool RenderSystem::isChildOfACamera(EntityWrapper entity)
|
||||||
{
|
{
|
||||||
return entity.FirstParentWithComponent("Camera").Valid();
|
return entity.FirstParentWithComponent("Camera").Valid();
|
||||||
@@ -112,13 +121,7 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only render children of a camera if that camera is currently active
|
if (!isEntityVisible(entity)) {
|
||||||
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
|
||||||
if ((entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid()) && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +302,11 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityWrapper entity(world, textComponent.EntityID);
|
||||||
|
if (!isEntityVisible(entity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Font* font;
|
Font* font;
|
||||||
try {
|
try {
|
||||||
font = ResourceManager::Load<Font>(resource);
|
font = ResourceManager::Load<Font>(resource);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
|
DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
|
||||||
: System(params)
|
: System(params)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_DamageTakenFromPlayer, &DamageIndicatorSystem::OnPlayerDamageTaken);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &DamageIndicatorSystem::OnPlayerDamage);
|
||||||
//current camera
|
//current camera
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera);
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera);
|
||||||
|
|
||||||
@@ -12,23 +12,27 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
|
|||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e)
|
bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||||
{
|
{
|
||||||
if (m_CurrentCamera == -1) {
|
if (m_CurrentCamera == EntityID_Invalid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Victim != LocalPlayer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//grab players direction
|
//grab players direction
|
||||||
auto playerOrientation = glm::quat((glm::vec3)e.Player["Transform"]["Orientation"]);
|
auto playerOrientation = glm::quat((glm::vec3)e.Victim["Transform"]["Orientation"]);
|
||||||
|
|
||||||
//get the position vectors, but ignore the y-height
|
//get the position vectors, but ignore the y-height
|
||||||
auto enemyPosition = (glm::vec3) e.PlayerShooter["Transform"]["Position"];
|
auto enemyPosition = (glm::vec3)e.Inflictor["Transform"]["Position"];
|
||||||
auto playerPosition = (glm::vec3) e.Player["Transform"]["Position"];
|
auto playerPosition = (glm::vec3)e.Victim["Transform"]["Position"];
|
||||||
enemyPosition.y = 0.0f;
|
enemyPosition.y = 0.0f;
|
||||||
playerPosition.y = 0.0f;
|
playerPosition.y = 0.0f;
|
||||||
|
|
||||||
//calculate the enemy to player vector
|
//calculate the enemy to player vector
|
||||||
auto enemyPlayerVector = glm::normalize((glm::vec3) playerPosition - enemyPosition);
|
auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition);
|
||||||
|
|
||||||
//get angle from players current rotation, this angle is how much you rotate around the y-axis
|
//get angle from players current rotation, this angle is how much you rotate around the y-axis
|
||||||
auto playerAngle = glm::angle(playerOrientation);
|
auto playerAngle = glm::angle(playerOrientation);
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
|
|
||||||
// Set the camera to the correct entity
|
// Set the camera to the correct entity
|
||||||
EntityWrapper cameraEntity = e.Player.FirstChildByName("Camera");
|
EntityWrapper cameraEntity = e.Player.FirstChildByName("Camera");
|
||||||
if (cameraEntity.Valid()) {
|
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
|
||||||
|
if (cameraEntity.Valid() && !outOfBodyExperience) {
|
||||||
Events::SetCamera e;
|
Events::SetCamera e;
|
||||||
e.CameraEntity = cameraEntity;
|
e.CameraEntity = cameraEntity;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ bool AssaultWeaponBehaviour::shoot(double damage)
|
|||||||
|
|
||||||
// Deal damage!
|
// Deal damage!
|
||||||
Events::PlayerDamage ePlayerDamage;
|
Events::PlayerDamage ePlayerDamage;
|
||||||
|
ePlayerDamage.Inflictor = m_Player;
|
||||||
ePlayerDamage.Victim = victim;
|
ePlayerDamage.Victim = victim;
|
||||||
ePlayerDamage.Damage = damage;
|
ePlayerDamage.Damage = damage;
|
||||||
m_EventBroker->Publish(ePlayerDamage);
|
m_EventBroker->Publish(ePlayerDamage);
|
||||||
|
|||||||
@@ -93,6 +93,4 @@ bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
// Select primary weapon on player spawn
|
// Select primary weapon on player spawn
|
||||||
// TODO: Select the active one specified by player component
|
// TODO: Select the active one specified by player component
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ePlayerDamage.PlayerShooter = eShoot.Player;
|
|
||||||
@@ -22,7 +22,9 @@ MKLINK "%DeployLocation%\Schema\" "resources\Schema" /J
|
|||||||
RMDIR /S /Q "%DeployLocation%\Shaders"
|
RMDIR /S /Q "%DeployLocation%\Shaders"
|
||||||
MKLINK "%DeployLocation%\Shaders\" "resources\Shaders" /J
|
MKLINK "%DeployLocation%\Shaders\" "resources\Shaders" /J
|
||||||
:: Configuration files
|
:: Configuration files
|
||||||
|
DEL "%DeployLocation%\DefaultConfig.ini"
|
||||||
MKLINK "%DeployLocation%\DefaultConfig.ini" "resources\DefaultConfig.ini" /H
|
MKLINK "%DeployLocation%\DefaultConfig.ini" "resources\DefaultConfig.ini" /H
|
||||||
|
DEL "%DeployLocation%\DefaultInput.ini"
|
||||||
MKLINK "%DeployLocation%\DefaultInput.ini" "resources\DefaultInput.ini" /H
|
MKLINK "%DeployLocation%\DefaultInput.ini" "resources\DefaultInput.ini" /H
|
||||||
|
|
||||||
:: Platform specific binaries
|
:: Platform specific binaries
|
||||||
|
|||||||
Reference in New Issue
Block a user