From 2cd0e94a6013b7bdc22e0f050fcd0fe37c7bf0d4 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Mon, 11 Jan 2016 14:37:43 +0100 Subject: [PATCH] Changed the comparison method in PlayerSystem since its currently using doubles --- src/Game/PlayerSystem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Game/PlayerSystem.cpp b/src/Game/PlayerSystem.cpp index e40469cc..2e2120d9 100644 --- a/src/Game/PlayerSystem.cpp +++ b/src/Game/PlayerSystem.cpp @@ -30,27 +30,27 @@ void PlayerSystem::UpdateComponent(World * world, ComponentWrapper & player, dou double currentAmmo = (double)0; double currentCoolDownTimer = (double)0; - if ((double)player["EquippedItem"] == (double)1) { + if (fabs((double)player["EquippedItem"] - (double)1) < (double) 0.0001f) { ComponentWrapper& currentItem = world->GetComponent(player.EntityID, "PrimaryItem"); - currentAmmo = currentItem["Ammo"]; + currentAmmo = (double)currentItem["Ammo"]; currentCoolDownTimer = (double)currentItem["CoolDownTimer"]; } - if ((double)player["EquippedItem"] == (double)2) { + if (fabs((double)player["EquippedItem"] - (double)2) < (double) 0.0001f) { ComponentWrapper& currentItem = world->GetComponent(player.EntityID, "SecondaryItem"); - currentAmmo = currentItem["Ammo"]; + currentAmmo = (double)currentItem["Ammo"]; currentCoolDownTimer = (double)currentItem["CoolDownTimer"]; } if (currentHealth > (double)0.0f && currentAmmo > (double)0.0f && currentCoolDownTimer < (double)0.001f) { //decrease ammo count //TODO: temp, set the cooldowntimer - probably done in some other system (itemSystem?) later - if ((double)player["EquippedItem"] == (double)1) { + if (fabs((double)player["EquippedItem"] - (double)1) < (double) 0.0001f) { ComponentWrapper& currentItem = world->GetComponent(player.EntityID, "PrimaryItem"); int currentAmmoInt = (int)((double)currentItem["Ammo"]); currentItem["Ammo"] = (double)(currentAmmoInt - 1); currentItem["CoolDownTimer"] = (double)2; } - if ((double)player["EquippedItem"] == (double)2) { + if (fabs((double)player["EquippedItem"] - (double)2) < (double) 0.0001f) { ComponentWrapper& currentItem = world->GetComponent(player.EntityID, "SecondaryItem"); int currentAmmoInt = (int)((double)currentItem["Ammo"]); currentItem["Ammo"] = (double)(currentAmmoInt - 1);