Merge branch 'WeaponSystem'

This commit is contained in:
2016-02-11 23:46:23 +01:00
9 changed files with 49 additions and 29 deletions
+24 -16
View File
@@ -47,16 +47,8 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
continue;
}
EntityWrapper entity(world, cSprite.EntityID);
// 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))) {
if (!isEntityVisible(entity)) {
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)
{
return entity.FirstParentWithComponent("Camera").Valid();
@@ -112,13 +121,7 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
continue;
}
// 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.FirstParentWithComponent("HiddenForLocalPlayer").Valid()) && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
if (!isEntityVisible(entity)) {
continue;
}
@@ -299,6 +302,11 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
continue;
}
EntityWrapper entity(world, textComponent.EntityID);
if (!isEntityVisible(entity)) {
continue;
}
Font* font;
try {
font = ResourceManager::Load<Font>(resource);
+11 -7
View File
@@ -3,7 +3,7 @@
DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
: System(params)
{
EVENT_SUBSCRIBE_MEMBER(m_DamageTakenFromPlayer, &DamageIndicatorSystem::OnPlayerDamageTaken);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &DamageIndicatorSystem::OnPlayerDamage);
//current camera
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera);
@@ -12,23 +12,27 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
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;
}
//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
auto enemyPosition = (glm::vec3) e.PlayerShooter["Transform"]["Position"];
auto playerPosition = (glm::vec3) e.Player["Transform"]["Position"];
auto enemyPosition = (glm::vec3)e.Inflictor["Transform"]["Position"];
auto playerPosition = (glm::vec3)e.Victim["Transform"]["Position"];
enemyPosition.y = 0.0f;
playerPosition.y = 0.0f;
//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
auto playerAngle = glm::angle(playerOrientation);
+2 -1
View File
@@ -88,7 +88,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
// Set the camera to the correct entity
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;
e.CameraEntity = cameraEntity;
m_EventBroker->Publish(e);
@@ -323,6 +323,7 @@ bool AssaultWeaponBehaviour::shoot(double damage)
// Deal damage!
Events::PlayerDamage ePlayerDamage;
ePlayerDamage.Inflictor = m_Player;
ePlayerDamage.Victim = victim;
ePlayerDamage.Damage = damage;
m_EventBroker->Publish(ePlayerDamage);
+1 -3
View File
@@ -93,6 +93,4 @@ bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
// Select primary weapon on player spawn
// TODO: Select the active one specified by player component
return true;
}
ePlayerDamage.PlayerShooter = eShoot.Player;
}