summaryrefslogtreecommitdiff
path: root/battles/src/BaseBattle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'battles/src/BaseBattle.cpp')
-rw-r--r--battles/src/BaseBattle.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/battles/src/BaseBattle.cpp b/battles/src/BaseBattle.cpp
index 92ab351..4d80671 100644
--- a/battles/src/BaseBattle.cpp
+++ b/battles/src/BaseBattle.cpp
@@ -30,6 +30,7 @@ BaseBattle::BaseBattle(const Scenario& scenario) :
_registry.emplace<Transform>(entity, spawner.get(ship.team));
_registry.emplace<FloatingMovement>(entity, 0.4);
_registry.emplace<AIState>(entity, Point{0.0, 0.0});
+ _registry.emplace<HitPoints>(entity, ship.type.base_health_points);
manager.add(ship.team, entity); // registry supports on construction events
}
}
@@ -60,6 +61,12 @@ BaseBattle::update(const float dt)
transform.position.y += eff.y;
}
}
+ auto view2 = _registry.view<HitPoints>();
+ for (auto&& [entity, points] : view2.each()) {
+ points.health -= dt;
+ if (points.health <= 0.0)
+ _registry.destroy(entity);
+ }
manager.clear(_registry); // registry supports on destructions events
}