Added Healthrelated events and start of HealthSystem, also reverted the crash "fix"

This commit is contained in:
verysecrethero
2016-01-06 13:36:53 +01:00
parent f3ff433bf7
commit f67f22c82d
7 changed files with 127 additions and 1 deletions
+18
View File
@@ -0,0 +1,18 @@
#ifndef EPlayerDamage_h__
#define EPlayerDamage_h__
#include "EventBroker.h"
#include "../Core/Entity.h"
namespace Events
{
struct PlayerDamage : Event
{
int DamageAmount;
EntityID PlayerID;
};
}
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef EPlayerDeath_h__
#define EPlayerDeath_h__
#include "EventBroker.h"
#include "../Core/Entity.h"
namespace Events
{
struct PlayerDeath : Event
{
std::string KilledBy;
EntityID PlayerID;
};
}
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef EPlayerHealthPickup_h__
#define EPlayerHealthPickup_h__
#include "EventBroker.h"
#include "../Core/Entity.h"
namespace Events
{
struct PlayerHealthPickup : Event
{
int HealthAmount;
EntityID HealthPickupID;
};
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef HealthSystem_h__
#define HealthSystem_h__
#include <GLFW/glfw3.h>
#include <glm/common.hpp>
#include "Common.h"
#include "Core/System.h"
#include "Core\EPlayerDamage.h";
#include "Core\EPlayerHealthPickup.h";
#include "Core\EPlayerDeath.h";
class HealthSystem : public PureSystem
{
public:
HealthSystem(EventBroker* eventBroker);
virtual void UpdateComponent(World* world, ComponentWrapper& player, double dt) override;
private:
float m_Speed = 5;
//create the methods which will take care of specific events
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
bool HealthSystem::OnPlayerDamaged(const Events::PlayerDamage& e);
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
bool HealthSystem::OnPlayerHealthPickup(const Events::PlayerHealthPickup& e);
int playerDeltaHealth;
};
#endif