]> git.tdb.fi Git - libs/game.git/blobdiff - examples/bassteroids/source/hitpoints.h
Convert components to buffered where appropriate
[libs/game.git] / examples / bassteroids / source / hitpoints.h
index a11d961783674e1b13b5043ca74c840cf4003525..f6000d7abab3c6dc54782d4fc2c413817c8263e8 100644 (file)
@@ -13,21 +13,25 @@ struct HitPointsSetup
        unsigned vulnerable_to = ~0U;
 };
 
-class HitPoints: public Msp::Game::Component
+struct HitPointsData
+{
+       unsigned remaining_hits;
+};
+
+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