From 8c92b7ceb6c389456260f9b6e0767149d10d8a71 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 13:40:17 +0100 Subject: [PATCH] Small cleanup. Clarified a few comments --- include/Game/Systems/BoostSystem.h | 4 ---- src/Game/Systems/BoostSystem.cpp | 14 +++++++------- src/Game/Systems/HealthSystem.cpp | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index 5e9c47da..f82707ab 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -2,14 +2,10 @@ #define BoostSystem_h__ #include "Core/System.h" -#include "Core/Transform.h" #include "Core/ResourceManager.h" #include "Core/EntityFileParser.h" #include "Core/EPlayerDamage.h" #include "Common.h" -#include - -#include "Rendering/Util/CommonFunctions.h" class BoostSystem : public System { diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index fdd5b6dc..9e4d6968 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -14,30 +14,30 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { return false; } - if (!e.Inflictor.Valid() || !e.Victim.Valid()) { return false; } - auto teamInflictor = m_World->GetComponent(e.Inflictor.ID, "Team"); - auto teamVictim = m_World->GetComponent(e.Victim.ID, "Team"); - if ((int)teamInflictor["Team"] != (int)teamVictim["Team"]) { + //if its not friendly fire, return + if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) { return false; } + //determine the inflictors class auto className = DetermineClass(e.Inflictor); if (className == "") { return false; } - //"Schema/Entities/Boost-.xml" + + //get the XML file, example: "Schema/Entities/BoostclassName.xml" std::string classXML = "Schema/Entities/" + className + ".xml"; - //check if player already has the component + //check if player already has a child with the component, if so delete that child auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className); if (playerBoostAssaultEntity.Valid()) { m_World->DeleteEntity(playerBoostAssaultEntity.ID); } - //load & set the BoostAssault Component + //load boost XML file, set it entity parented with the victim player auto entityFile = ResourceManager::Load(classXML); EntityFileParser parser(entityFile); EntityID boostAssaultEntity = parser.MergeEntities(m_World); diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index 82836d2c..6e1e276f 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -30,6 +30,7 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) ComponentWrapper cHealth = e.Victim["Health"]; double& health = cHealth["Health"]; + //if player has the boost from a defender, subtract the damage taken by StrengthOfEffect amount auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender"); if (playerBoostDefenderEntity.Valid()) { e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];