]> git.tdb.fi Git - libs/game.git/blobdiff - examples/bassteroids/source/hitpoints.h
Use the setup generator to create setup structs
[libs/game.git] / examples / bassteroids / source / hitpoints.h
index a11d961783674e1b13b5043ca74c840cf4003525..49fb920d2d1aa5a50919d53f7b06c8e63d04d8ca 100644 (file)
@@ -2,32 +2,27 @@
 #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