From 7af17049e9489a0df32418da8dfe994c75c862dc Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 18:13:09 +0100 Subject: [PATCH] BoostIcons should now track correctly --- include/Game/Systems/BoostIconsHUDSystem.h | 6 ++-- src/Game/Systems/BoostIconsHUDSystem.cpp | 40 ++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/BoostIconsHUDSystem.h b/include/Game/Systems/BoostIconsHUDSystem.h index fbcdfc16..d8de777d 100644 --- a/include/Game/Systems/BoostIconsHUDSystem.h +++ b/include/Game/Systems/BoostIconsHUDSystem.h @@ -4,14 +4,16 @@ #include "../../Engine/Core/System.h" #include "../../Engine/GLM.h" -class BoostIconsHUDSystem : public ImpureSystem +class BoostIconsHUDSystem : public PureSystem { public: BoostIconsHUDSystem(SystemParams params) : System(params) + , PureSystem("BoostIconsHUD") { } - virtual void Update(double dt) override; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; + }; #endif \ No newline at end of file diff --git a/src/Game/Systems/BoostIconsHUDSystem.cpp b/src/Game/Systems/BoostIconsHUDSystem.cpp index 6d181233..f83278ff 100644 --- a/src/Game/Systems/BoostIconsHUDSystem.cpp +++ b/src/Game/Systems/BoostIconsHUDSystem.cpp @@ -1,6 +1,42 @@ #include "Game/Systems/BoostIconsHUDSystem.h" -void BoostIconsHUDSystem::Update(double dt) +void BoostIconsHUDSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - //Logic here + EntityWrapper assaultEntity = entity.FirstChildByName("Assault"); + EntityWrapper defenderEntity = entity.FirstChildByName("Defender"); + EntityWrapper sniperEntity = entity.FirstChildByName("Sniper"); + + if(assaultEntity.Valid()) { + if (assaultEntity.HasComponent("Fill")) { + EntityWrapper parentWithAssaultBoost = assaultEntity.FirstParentWithComponent("BoostAssault"); + if (parentWithAssaultBoost.Valid()) { + (double&)assaultEntity["Fill"]["Percentage"] = 1.0; + } else { + (double&)assaultEntity["Fill"]["Percentage"] = 0.0; + } + } + } + + if (defenderEntity.Valid()) { + if (defenderEntity.HasComponent("Fill")) { + EntityWrapper parentWithAssaultBoost = defenderEntity.FirstParentWithComponent("BoostDefender"); + if (parentWithAssaultBoost.Valid()) { + (double&)defenderEntity["Fill"]["Percentage"] = 1.0; + } else { + (double&)defenderEntity["Fill"]["Percentage"] = 0.0; + } + } + } + + if (sniperEntity.Valid()) { + if (sniperEntity.HasComponent("Fill")) { + EntityWrapper parentWithAssaultBoost = sniperEntity.FirstParentWithComponent("BoostSniper"); + if (parentWithAssaultBoost.Valid()) { + (double&)sniperEntity["Fill"]["Percentage"] = 1.0; + } else { + (double&)sniperEntity["Fill"]["Percentage"] = 0.0; + } + } + } } +