From dfc30f4693bb3c59cd3d6c794a6d6455617ae6ee Mon Sep 17 00:00:00 2001 From: viktorljung Date: Sat, 12 Mar 2016 17:39:50 +0100 Subject: [PATCH] Boost fixes? --- src/Game/Systems/BoostSystem.cpp | 90 ++++++++++++++++---------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index 5074e1c7..f6148192 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -8,54 +8,52 @@ BoostSystem::BoostSystem(SystemParams params) bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) { - if (!IsClient) { - - if (e.Victim.ID == e.Inflictor.ID) { - return false; - } - - if (!e.Victim.Valid() || !LocalPlayer.Valid()) { - return false; - } - - if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { - return false; - } - - if (!e.Inflictor.Valid()) { - return false; - } - - //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; - } - - if (className == "SidearmWeapon") { // give ammo - giveAmmo(e.Inflictor, e.Victim); - } else { //give boost - //get the XML file, example: "Schema/Entities/BoostclassName.xml" - std::string classXML = "Schema/Entities/" + className + ".xml"; - - //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 boost XML file, set it entity parented with the victim player - auto entityFile = ResourceManager::Load(classXML); - EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World); - m_World->SetName(boostAssaultEntity.ID, className); - m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID); - } + if (e.Victim.ID == e.Inflictor.ID) { + return false; } + if (!e.Victim.Valid() || !LocalPlayer.Valid()) { + return false; + } + + if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { + return false; + } + + if (!e.Inflictor.Valid()) { + return false; + } + + //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; + } + + if (className == "SidearmWeapon") { // give ammo + giveAmmo(e.Inflictor, e.Victim); + } else { //give boost + //get the XML file, example: "Schema/Entities/BoostclassName.xml" + std::string classXML = "Schema/Entities/" + className + ".xml"; + + //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 boost XML file, set it entity parented with the victim player + auto entityFile = ResourceManager::Load(classXML); + EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World); + m_World->SetName(boostAssaultEntity.ID, className); + m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID); + } + + return true; }