hp really fixed?
This commit is contained in:
@@ -22,8 +22,8 @@ void HealthHUDSystem::Update(double dt)
|
|||||||
if (entityIDParent.HasComponent("Health")) {
|
if (entityIDParent.HasComponent("Health")) {
|
||||||
|
|
||||||
if (entity.HasComponent("Text")) {
|
if (entity.HasComponent("Text")) {
|
||||||
Field<double> health = entityIDParent["Health"]["Health"];
|
double health = (const double&)entityIDParent["Health"]["Health"];
|
||||||
Field<double> maxHealth = entityIDParent["Health"]["Health"];
|
double maxHealth = (const double&)entityIDParent["Health"]["Health"];
|
||||||
std::string s = "";
|
std::string s = "";
|
||||||
s = s + std::to_string((int)health);
|
s = s + std::to_string((int)health);
|
||||||
s = s + "/";
|
s = s + "/";
|
||||||
@@ -34,8 +34,8 @@ void HealthHUDSystem::Update(double dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(entity.HasComponent("Fill")) {
|
if(entity.HasComponent("Fill")) {
|
||||||
Field<double> health = entityIDParent["Health"]["Health"];
|
double health = (const double&)entityIDParent["Health"]["Health"];
|
||||||
Field<double> maxHealth = entityIDParent["Health"]["Health"];
|
double maxHealth = (const double&)entityIDParent["Health"]["Health"];
|
||||||
float healthPercentage = health/maxHealth;
|
float healthPercentage = health/maxHealth;
|
||||||
entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Fill"]["Color"]).a);
|
entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Fill"]["Color"]).a);
|
||||||
entity["Fill"]["Percentage"] = (double)healthPercentage;
|
entity["Fill"]["Percentage"] = (double)healthPercentage;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void PickupSpawnSystem::Update(double dt)
|
|||||||
m_PickupAtMaximum.erase(it);
|
m_PickupAtMaximum.erase(it);
|
||||||
break;
|
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);
|
DoPickup(it->player, it->trigger);
|
||||||
m_PickupAtMaximum.erase(it);
|
m_PickupAtMaximum.erase(it);
|
||||||
break;
|
break;
|
||||||
@@ -59,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//if at maxhealth, save the trigger-touch to a vector since standing inside it will not re-trigger the trigger
|
//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 });
|
m_PickupAtMaximum.push_back({ e.Entity, e.Trigger });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger)
|
|||||||
if (!trigger.Valid()) {
|
if (!trigger.Valid()) {
|
||||||
return;
|
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
|
//only the server will increase the players hp and set it in the next delta
|
||||||
Events::PlayerHealthPickup ePlayerHealthPickup;
|
Events::PlayerHealthPickup ePlayerHealthPickup;
|
||||||
|
|||||||
Reference in New Issue
Block a user