blob: eacaaa52eb0348710eb2febe8b24e903accb3e5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#ifndef COMPONENTS_HEALTH_HPP_
#define COMPONENTS_HEALTH_HPP_
#include "base.hpp"
/**
* @struct Health
* @brief Gives and entity health and stuff.
*/
struct Health : public Component {
/**
* Constructor that sets the variables, with 1 health as default.
*/
Health(int m = 1, int h = 0)
: health(h != 0 ? h : m), maxHealth(m) {}
Health(XMLElement* imp, XMLElement* def) {
fromXML(imp, def);
}
int health; /**< The current amount of health */
int maxHealth; /**< The maximum amount of health */
void fromXML(XMLElement* imp, XMLElement* def) final {
(void)imp;
(void)def;
// TODO
if (def->QueryIntAttribute("value", &health) != XML_NO_ERROR)
health = 1;
maxHealth = health;
}
};
#endif // COMPONENTS_HEALTH_HPP_
|