Added AbilityCooldownHUD component and system to track the cooldown on the dashability, this needs to be extended for other abilities when they are implemented. However current dash time needs to be included into the component, since we can currently just see the max cooldown time.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include "Game/Systems/AbilityCooldownHUDSystem.h"
|
||||
|
||||
void AbilityCooldownHUDSystem::Update(double dt)
|
||||
{
|
||||
//HUD element for tracking cooldown on the parent entity with Dashability TODO: Make sure it support other abilities when they are made.
|
||||
|
||||
auto abilityHUDs = m_World->GetComponents("AbilityCooldownHUD");
|
||||
if (abilityHUDs == nullptr)
|
||||
return;
|
||||
|
||||
for (auto& abilityHUDC : *abilityHUDs) {
|
||||
EntityWrapper entity = EntityWrapper(m_World, abilityHUDC.EntityID);
|
||||
EntityWrapper abilityEntity = entity.FirstParentWithComponent("DashAbility");
|
||||
if (!abilityEntity.Valid())
|
||||
return;
|
||||
EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown");
|
||||
if(cooldownTextEntity.Valid()) {
|
||||
if(cooldownTextEntity.HasComponent("Text"))
|
||||
{
|
||||
double abilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"];
|
||||
std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(abilityCD).substr(0, 3);
|
||||
if(entity.HasComponent("Fill")) {
|
||||
entity["Fill"]["Percentage"] = abilityCD/abilityCD; //TODO: current time needs to be in the component.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user