mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-02-14 17:31:32 +00:00
41 lines
957 B
C++
41 lines
957 B
C++
//
|
|
// Created by Tom Augier on 2021-05-20.
|
|
// Edited by Benjamin Henry on 2021-05-20.
|
|
// Edited by Louis Auzuret on 2021-05-20.
|
|
//
|
|
|
|
#include "HealthComponent.hpp"
|
|
|
|
#include <utility>
|
|
|
|
namespace BBM
|
|
{
|
|
HealthComponent::HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback<WAL::Entity &, WAL::Wal &> &onDeathCallback)
|
|
: WAL::Component(entity),
|
|
_healthPoint(healthPoint),
|
|
onDeath(onDeathCallback)
|
|
{}
|
|
|
|
WAL::Component *HealthComponent::clone(WAL::Entity &entity) const
|
|
{
|
|
return new HealthComponent(entity, this->_healthPoint, this->onDeath);
|
|
}
|
|
|
|
void HealthComponent::addHealthPoint(unsigned int healthPoint)
|
|
{
|
|
this->_healthPoint += healthPoint;
|
|
}
|
|
|
|
void HealthComponent::takeDmg(unsigned int damage)
|
|
{
|
|
if (damage >= this->_healthPoint) {
|
|
this->_healthPoint = 0;
|
|
} else
|
|
this->_healthPoint -= damage;
|
|
}
|
|
|
|
unsigned int HealthComponent::getHealthPoint(void) const
|
|
{
|
|
return (this->_healthPoint);
|
|
}
|
|
} |