--- /dev/null
+#include "hitpoints.h"
+
+using namespace Msp;
+
+HitPoints::HitPoints(Game::Handle<Game::Entity> e, const Setup &s):
+ Component(e),
+ setup(s),
+ remaining_hits(setup.max_hits)
+{ }
+
+void HitPoints::take_damage(unsigned amount, unsigned type)
+{
+ if(!(setup.vulnerable_to&(1<<type)))
+ return;
+
+ remaining_hits = (amount<remaining_hits ? remaining_hits-amount : 0);
+}