DefaultInput key 'K' to kill player, since we can't respawn when alive. Also moved TakeDamage InputCommand to HealthSystem.
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Core/EPlayerHealthPickup.h"
|
#include "Core/EPlayerHealthPickup.h"
|
||||||
#include "Core/EPlayerDeath.h"
|
#include "Core/EPlayerDeath.h"
|
||||||
|
#include "../Engine/Input/EInputCommand.h"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -28,7 +29,9 @@ private:
|
|||||||
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
||||||
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
||||||
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e);
|
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e);
|
||||||
|
EventRelay<HealthSystem, Events::InputCommand> m_InputCommand;
|
||||||
|
bool HealthSystem::OnInputCommand(Events::InputCommand& e);
|
||||||
|
|
||||||
//vector which will keep track of health changes
|
//vector which will keep track of health changes
|
||||||
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
||||||
|
|
||||||
|
|||||||
@@ -24,4 +24,5 @@ F1=ToggleEditor
|
|||||||
C=ConnectToServer
|
C=ConnectToServer
|
||||||
N=SwitchToServer
|
N=SwitchToServer
|
||||||
M=SwitchToClient
|
M=SwitchToClient
|
||||||
P=SwitchToPlayer
|
P=SwitchToPlayer
|
||||||
|
K=TakeDamage,1500
|
||||||
@@ -7,6 +7,7 @@ HealthSystem::HealthSystem(SystemParams params)
|
|||||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &HealthSystem::OnPlayerDamaged);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &HealthSystem::OnPlayerDamaged);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerHealthPickup, &HealthSystem::OnPlayerHealthPickup);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerHealthPickup, &HealthSystem::OnPlayerHealthPickup);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &HealthSystem::OnInputCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||||
@@ -29,6 +30,17 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
|
|||||||
return true;
|
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)
|
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e)
|
||||||
{
|
{
|
||||||
ComponentWrapper cHealth = e.Player["Health"];
|
ComponentWrapper cHealth = e.Player["Health"];
|
||||||
|
|||||||
@@ -52,12 +52,6 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.Command == "TakeDamage" && e.Value > 0 && LocalPlayer.Valid()) {
|
|
||||||
Events::PlayerDamage ev;
|
|
||||||
ev.Victim = LocalPlayer;
|
|
||||||
ev.Damage = e.Value;
|
|
||||||
m_EventBroker->Publish(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user