diff options
Diffstat (limited to 'battles/src')
-rw-r--r-- | battles/src/Battle.cpp | 17 | ||||
-rw-r--r-- | battles/src/scenarios.cpp | 39 |
2 files changed, 44 insertions, 12 deletions
diff --git a/battles/src/Battle.cpp b/battles/src/Battle.cpp index e59f951..e410f07 100644 --- a/battles/src/Battle.cpp +++ b/battles/src/Battle.cpp @@ -1,10 +1,7 @@ #include <kurator/battles/Battle.h> -#include <cmath> #include <random> -#include <entt/entity/entity.hpp> - #include <kurator/battles/components.h> #include <kurator/battles/Scenario.h> #include <kurator/universe/ShipType.h> @@ -20,15 +17,11 @@ Battle::Battle(Scenario scenario) { std::random_device dev; std::uniform_real_distribution<> pos{-5.0, 5.0}; - int team = 0; - for (const auto& ships : scenario.teams) { - for (const auto& ship : ships) { - const auto entity = registry.create(); - registry.emplace<universe::ShipType>(entity, ship.type); - registry.emplace<Team>(entity, team); - registry.emplace<Transform>(entity, Point{pos(dev), pos(dev)}, Point{0.0, 0.0}); - } - team++; + for (const auto& ship : scenario.ships) { + const auto entity = registry.create(); + registry.emplace<universe::ShipType>(entity, ship.type); + registry.emplace<Team>(entity, ship.team); + registry.emplace<Transform>(entity, Point{pos(dev), pos(dev)}, Point{0.0, 0.0}); } } diff --git a/battles/src/scenarios.cpp b/battles/src/scenarios.cpp new file mode 100644 index 0000000..ffb4f27 --- /dev/null +++ b/battles/src/scenarios.cpp @@ -0,0 +1,39 @@ +#include <kurator/battles/scenarios.h> + +#include <kurator/battles/Scenario.h> +#include <kurator/universe/ShipType.h> + + +namespace kurator +{ +namespace battles +{ +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}; + return { + "example", + { + {0, halo, {}}, + {0, halo, {}}, + {0, cube, {}}, + {0, bell, {}}, + {1, bell, {}}, + {1, cube, {}}, + {1, cube, {}}, + {1, bell, {}}, + }, + }; +} + + +} // namespace scenarios +} // namespace battles +} // namespace kurator |