DefaultInput key 'K' to kill player, since we can't respawn when alive. Also moved TakeDamage InputCommand to HealthSystem.
This commit is contained in:
@@ -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"];
|
||||
|
||||
Reference in New Issue
Block a user