PlayerSystem now counts down the CoolDownTimer on both HeldItems for the player. Updated ShootEventTest to verify this
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include "PlayerSystem.h"
|
#include "PlayerSystem.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
void PlayerSystem::UpdateComponent(World * world, ComponentWrapper & player, double dt)
|
void PlayerSystem::UpdateComponent(World * world, ComponentWrapper & player, double dt)
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,12 @@ void PlayerSystem::UpdateComponent(World * world, ComponentWrapper & player, dou
|
|||||||
(glm::vec3&)transform["Position"] += (glm::vec3)player["Velocity"];
|
(glm::vec3&)transform["Position"] += (glm::vec3)player["Velocity"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//decrease CoolDownTimers for both HeldItems
|
||||||
|
ComponentWrapper& currentItem = world->GetComponent(player.EntityID, "PrimaryItem");
|
||||||
|
ComponentWrapper& currentItem2 = world->GetComponent(player.EntityID, "SecondaryItem");
|
||||||
|
currentItem["CoolDownTimer"] = std::max(0.0, (double)currentItem["CoolDownTimer"] - dt);
|
||||||
|
currentItem2["CoolDownTimer"] = std::max(0.0, (double)currentItem2["CoolDownTimer"] - dt);
|
||||||
|
|
||||||
//do shootEvent: if left mouse was released, and ammo/weaponcooldown/playeralive/shootingcooldown are ok
|
//do shootEvent: if left mouse was released, and ammo/weaponcooldown/playeralive/shootingcooldown are ok
|
||||||
if (leftMouseWasReleased) {
|
if (leftMouseWasReleased) {
|
||||||
leftMouseWasReleased = false;
|
leftMouseWasReleased = false;
|
||||||
@@ -44,7 +51,7 @@ void PlayerSystem::UpdateComponent(World * world, ComponentWrapper & player, dou
|
|||||||
//decrease ammo count
|
//decrease ammo count
|
||||||
//TODO: temp, set the cooldowntimer - probably done in some other system (itemSystem?) later
|
//TODO: temp, set the cooldowntimer - probably done in some other system (itemSystem?) later
|
||||||
currentItem["Ammo"] = (int)currentItem["Ammo"] - 1;
|
currentItem["Ammo"] = (int)currentItem["Ammo"] - 1;
|
||||||
currentItem["CoolDownTimer"] = 2.0;//change later!
|
currentItem["CoolDownTimer"] = 2.0;//change later! probably to maxCoolDownTimer
|
||||||
//create and publish the shoot event
|
//create and publish the shoot event
|
||||||
Events::Shoot eShoot;
|
Events::Shoot eShoot;
|
||||||
eShoot.currentAimingPoint = aimingCoordinates;
|
eShoot.currentAimingPoint = aimingCoordinates;
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ void ShootEventTest::TestSetup4(ComponentWrapper &player, ComponentWrapper &pIte
|
|||||||
player["EquippedItem"] = 1;
|
player["EquippedItem"] = 1;
|
||||||
//set ammo set cooldown
|
//set ammo set cooldown
|
||||||
pItem["Ammo"] = 100;
|
pItem["Ammo"] = 100;
|
||||||
pItem["CoolDownTimer"] = 5.0;
|
pItem["CoolDownTimer"] = 99999999.0;//very long coolDownTimer
|
||||||
//TestSucceeded will be set to false if ammo changes during the 100 loops
|
//TestSucceeded will be set to false if ammo changes during the 100 loops
|
||||||
TestSucceeded = true;
|
TestSucceeded = true;
|
||||||
}
|
}
|
||||||
@@ -225,10 +225,12 @@ void ShootEventTest::Tick()
|
|||||||
{
|
{
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
double currentTime = glfwGetTime();
|
//double currentTime = glfwGetTime();
|
||||||
double dt = currentTime - m_LastTime;
|
//double dt = currentTime - m_LastTime;
|
||||||
m_LastTime = currentTime;
|
//m_LastTime = currentTime;
|
||||||
|
|
||||||
|
//just set dt to 1.0
|
||||||
|
double dt = 0.34567;
|
||||||
// Iterate through systems and update world!
|
// Iterate through systems and update world!
|
||||||
m_SystemPipeline->Update(m_World, dt);
|
m_SystemPipeline->Update(m_World, dt);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user