From 148d60f8f8e10adf58137d2b04283656338b613f Mon Sep 17 00:00:00 2001 From: viktorljung Date: Sun, 13 Mar 2016 21:24:27 +0100 Subject: [PATCH] hp really fixed? --- src/Game/Systems/HealthHUDSystem.cpp | 8 ++++---- src/Game/Systems/PickupSpawnSystem.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Game/Systems/HealthHUDSystem.cpp b/src/Game/Systems/HealthHUDSystem.cpp index cd8a428f..efa70167 100644 --- a/src/Game/Systems/HealthHUDSystem.cpp +++ b/src/Game/Systems/HealthHUDSystem.cpp @@ -22,8 +22,8 @@ void HealthHUDSystem::Update(double dt) if (entityIDParent.HasComponent("Health")) { if (entity.HasComponent("Text")) { - Field health = entityIDParent["Health"]["Health"]; - Field maxHealth = entityIDParent["Health"]["Health"]; + double health = (const double&)entityIDParent["Health"]["Health"]; + double maxHealth = (const double&)entityIDParent["Health"]["Health"]; std::string s = ""; s = s + std::to_string((int)health); s = s + "/"; @@ -34,8 +34,8 @@ void HealthHUDSystem::Update(double dt) } if(entity.HasComponent("Fill")) { - Field health = entityIDParent["Health"]["Health"]; - Field maxHealth = entityIDParent["Health"]["Health"]; + double health = (const double&)entityIDParent["Health"]["Health"]; + double maxHealth = (const double&)entityIDParent["Health"]["Health"]; float healthPercentage = health/maxHealth; entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Fill"]["Color"]).a); entity["Fill"]["Percentage"] = (double)healthPercentage; diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index b0efd696..c05d3bd2 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -45,7 +45,7 @@ void PickupSpawnSystem::Update(double dt) m_PickupAtMaximum.erase(it); break; } - if ((double)it->player["Health"]["Health"] < (double)it->player["Health"]["MaxHealth"]) { + if ((const double&)it->player["Health"]["Health"] < (const double&)it->player["Health"]["MaxHealth"]) { DoPickup(it->player, it->trigger); m_PickupAtMaximum.erase(it); break; @@ -59,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e) return false; } //if at maxhealth, save the trigger-touch to a vector since standing inside it will not re-trigger the trigger - if ((double)e.Entity["Health"]["Health"] >= (double)e.Entity["Health"]["MaxHealth"]) { + if ((const double&)e.Entity["Health"]["Health"] >= (const double&)e.Entity["Health"]["MaxHealth"]) { m_PickupAtMaximum.push_back({ e.Entity, e.Trigger }); return false; } @@ -87,7 +87,7 @@ void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) if (!trigger.Valid()) { return; } - double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"]; + double healthGiven = 0.01*(const double&)trigger["HealthPickup"]["HealthGain"] * (const double&)player["Health"]["MaxHealth"]; //only the server will increase the players hp and set it in the next delta Events::PlayerHealthPickup ePlayerHealthPickup;