Bomberman
HealthComponent.hpp
Go to the documentation of this file.
1 //
2 // Created by Tom Augier on 2021-05-20.
3 // Edited by Benjamin Henry on 2021-05-20.
4 // Edited by Louis Auzuret on 2021-05-20.
5 //
6 
7 #pragma once
8 
9 #include <Models/Callback.hpp>
10 #include "Component/Component.hpp"
11 #include "Entity/Entity.hpp"
12 #include "Wal.hpp"
13 
14 namespace BBM
15 {
17  {
18 
19  private:
21  unsigned int _healthPoint;
22 
23  public:
26 
28  void addHealthPoint(unsigned int healthPoint);
29 
31  void takeDmg(unsigned int damage);
32 
34  unsigned int getHealthPoint(void) const;
35 
37  WAL::Component *clone(WAL::Entity &entity) const override;
38 
40  HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback<WAL::Entity &, WAL::Wal &> &onDeathCallback = WAL::Callback<WAL::Entity &, WAL::Wal &>());
41 
43  HealthComponent(const HealthComponent &) = default;
44 
46  ~HealthComponent() override = default;
47 
49  HealthComponent &operator=(const HealthComponent &) = delete;
50  };
51 }
BBM::HealthComponent::takeDmg
void takeDmg(unsigned int damage)
reduce health
Definition: HealthComponent.cpp:29
BBM::HealthComponent::~HealthComponent
~HealthComponent() override=default
default destructor
Callback.hpp
BBM::HealthComponent::onDeath
WAL::Callback< WAL::Entity &, WAL::Wal & > onDeath
The callback invoked on this entity's death.
Definition: HealthComponent.hpp:25
WAL::Component
Represent a single component of WAL.
Definition: Component.hpp:17
BBM
Definition: AnimationsComponent.cpp:9
Entity.hpp
WAL::Entity
An entity of the WAL's ECS.
Definition: Entity.hpp:20
Component.hpp
BBM::HealthComponent::addHealthPoint
void addHealthPoint(unsigned int healthPoint)
add health to the entity
Definition: HealthComponent.cpp:24
WAL::Callback< WAL::Entity &, WAL::Wal & >
BBM::HealthComponent
Definition: HealthComponent.hpp:16
BBM::HealthComponent::_healthPoint
unsigned int _healthPoint
life of an entity
Definition: HealthComponent.hpp:21
Wal.hpp
BBM::HealthComponent::getHealthPoint
unsigned int getHealthPoint(void) const
return health point of the entity
Definition: HealthComponent.cpp:37
BBM::HealthComponent::operator=
HealthComponent & operator=(const HealthComponent &)=delete
A Health component can't be assigned.
BBM::HealthComponent::HealthComponent
HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback< WAL::Entity &, WAL::Wal & > &onDeathCallback=WAL::Callback< WAL::Entity &, WAL::Wal & >())
Constructor.
Definition: HealthComponent.cpp:13
BBM::HealthComponent::clone
WAL::Component * clone(WAL::Entity &entity) const override
Clone a component for another or the same entity.
Definition: HealthComponent.cpp:19