summaryrefslogtreecommitdiff
path: root/battles/src
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-11-13 16:32:57 +0100
committerAki <please@ignore.pl>2022-11-13 16:32:57 +0100
commit39ae4f2fd4c382f25ab98c6e98816e3e3a6f4e22 (patch)
tree56afaa55eca0d3bf00a2d1b1be5c365223b909d8 /battles/src
parent1b39b8aaf6be5be56530979044fb893a5b51b489 (diff)
downloadkurator-39ae4f2fd4c382f25ab98c6e98816e3e3a6f4e22.zip
kurator-39ae4f2fd4c382f25ab98c6e98816e3e3a6f4e22.tar.gz
kurator-39ae4f2fd4c382f25ab98c6e98816e3e3a6f4e22.tar.bz2
Playing around with hit points
Diffstat (limited to 'battles/src')
-rw-r--r--battles/src/BaseBattle.cpp7
-rw-r--r--battles/src/scenarios.cpp14
2 files changed, 18 insertions, 3 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
}
diff --git a/battles/src/scenarios.cpp b/battles/src/scenarios.cpp
index ffb4f27..cf348ca 100644
--- a/battles/src/scenarios.cpp
+++ b/battles/src/scenarios.cpp
@@ -15,19 +15,27 @@ namespace scenarios
Scenario
example()
{
- const universe::ShipType halo {"halo", 4.0};
- const universe::ShipType cube {"cube", 10.0};
- const universe::ShipType bell {"bell", 10.0};
+ const universe::ShipType halo {"halo", 6.0};
+ const universe::ShipType cube {"cube", 12.0};
+ const universe::ShipType bell {"bell", 20.0};
return {
"example",
{
{0, halo, {}},
{0, halo, {}},
{0, cube, {}},
+ {0, cube, {}},
+ {0, cube, {}},
+ {0, bell, {}},
{0, bell, {}},
+ {0, bell, {}},
+ {1, halo, {}},
+ {1, halo, {}},
{1, bell, {}},
{1, cube, {}},
{1, cube, {}},
+ {1, cube, {}},
+ {1, bell, {}},
{1, bell, {}},
},
};