Small cleanup. Clarified a few comments
This commit is contained in:
@@ -2,14 +2,10 @@
|
|||||||
#define BoostSystem_h__
|
#define BoostSystem_h__
|
||||||
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/Transform.h"
|
|
||||||
#include "Core/ResourceManager.h"
|
#include "Core/ResourceManager.h"
|
||||||
#include "Core/EntityFileParser.h"
|
#include "Core/EntityFileParser.h"
|
||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
#include "Rendering/Util/CommonFunctions.h"
|
|
||||||
|
|
||||||
class BoostSystem : public System
|
class BoostSystem : public System
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,30 +14,30 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
|||||||
if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
|
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto teamInflictor = m_World->GetComponent(e.Inflictor.ID, "Team");
|
//if its not friendly fire, return
|
||||||
auto teamVictim = m_World->GetComponent(e.Victim.ID, "Team");
|
if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) {
|
||||||
if ((int)teamInflictor["Team"] != (int)teamVictim["Team"]) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//determine the inflictors class
|
||||||
auto className = DetermineClass(e.Inflictor);
|
auto className = DetermineClass(e.Inflictor);
|
||||||
if (className == "") {
|
if (className == "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//"Schema/Entities/Boost-.xml"
|
|
||||||
|
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
|
||||||
std::string classXML = "Schema/Entities/" + className + ".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);
|
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
|
||||||
if (playerBoostAssaultEntity.Valid()) {
|
if (playerBoostAssaultEntity.Valid()) {
|
||||||
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
|
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<EntityFile>(classXML);
|
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
|
||||||
EntityFileParser parser(entityFile);
|
EntityFileParser parser(entityFile);
|
||||||
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
|
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
|
|||||||
|
|
||||||
ComponentWrapper cHealth = e.Victim["Health"];
|
ComponentWrapper cHealth = e.Victim["Health"];
|
||||||
double& health = cHealth["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");
|
auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender");
|
||||||
if (playerBoostDefenderEntity.Valid()) {
|
if (playerBoostDefenderEntity.Valid()) {
|
||||||
e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];
|
e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];
|
||||||
|
|||||||
Reference in New Issue
Block a user