Fixed PlayerDeath being fired multiple times per frame on the server, causing multiple spawns and other weirdness

This commit is contained in:
2016-02-12 06:30:19 +01:00
parent 2e5ee633ce
commit cc422cf73a
+8 -8
View File
@@ -10,8 +10,15 @@ HealthSystem::HealthSystem(SystemParams params)
EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &HealthSystem::OnInputCommand);
}
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cHealth, double dt)
{
double& health = cHealth["Health"];
if (health <= 0.0) {
Events::PlayerDeath ePlayerDeath;
ePlayerDeath.Player = entity;
m_EventBroker->Publish(ePlayerDeath);
//Note: we will delete the entity in PlayerDeathSystem
}
}
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
@@ -20,13 +27,6 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
double& health = cHealth["Health"];
health -= e.Damage;
if (health <= 0.0) {
Events::PlayerDeath ePlayerDeath;
ePlayerDeath.Player = e.Victim;
m_EventBroker->Publish(ePlayerDeath);
//Note: we will delete the entity in PlayerDeathSystem
}
return true;
}