DefaultInput key 'K' to kill player, since we can't respawn when alive. Also moved TakeDamage InputCommand to HealthSystem.

This commit is contained in:
William Moberg
2016-02-12 00:52:58 +01:00
parent f1c2413cf9
commit 40ae2b8cbb
4 changed files with 18 additions and 8 deletions
+12
View File
@@ -7,6 +7,7 @@ HealthSystem::HealthSystem(SystemParams params)
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &HealthSystem::OnPlayerDamaged);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerHealthPickup, &HealthSystem::OnPlayerHealthPickup);
EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &HealthSystem::OnInputCommand);
}
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
@@ -29,6 +30,17 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
return true;
}
bool HealthSystem::OnInputCommand(Events::InputCommand& e)
{
if (e.Command == "TakeDamage" && e.Value > 0 && LocalPlayer.Valid()) {
Events::PlayerDamage ev;
ev.Victim = LocalPlayer;
ev.Damage = e.Value;
m_EventBroker->Publish(ev);
}
return true;
}
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e)
{
ComponentWrapper cHealth = e.Player["Health"];