#define HITPOINTS_H_
#include <msp/game/component.h>
+#include "setups.h"
-struct HitPointsSetup
+struct HitPointsData
{
- /*class Loader: public Msp::DataFile::ObjectLoader<HitPointsSetup>
- {
- };*/
-
- unsigned max_hits = 1;
- unsigned vulnerable_to = ~0U;
+ unsigned remaining_hits;
};
-class HitPoints: public Msp::Game::Component
+class HitPoints: public Msp::Game::BufferedComponent<HitPointsData>
{
public:
using Setup = HitPointsSetup;
private:
const Setup &setup;
- unsigned remaining_hits;
public:
HitPoints(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
void take_damage(unsigned, unsigned);
- bool is_alive() const { return remaining_hits; }
+ bool is_alive() const { return read().remaining_hits; }
};
#endif