summaryrefslogtreecommitdiff
path: root/battles/src/Battle.cpp
blob: e59f9517a9cd3df834757ef8f41a677ff5a7fd01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#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>


namespace kurator
{
namespace battles
{


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++;
	}
}


}  // namespace battles
}  // namespace kurator