summaryrefslogtreecommitdiff
path: root/battles/src/Builder.cpp
blob: 4ead63469782c3b835ed2a5585e9c176c9c92171 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "Builder.h"

#include <entt/entity/registry.hpp>

#include <kurator/battles/components.h>
#include <kurator/battles/Point.h>
#include <kurator/universe/ShipType.h>
#include <kurator/universe/TurretType.h>

#include "Spawner.h"


namespace kurator
{
namespace battles
{


Builder::Builder(entt::registry& _registry, Spawner& _spawner) :
	registry {_registry},
	spawner {_spawner}
{
}


entt::entity
Builder::operator()(const universe::ShipType& ship_type, const int team) const
{
	const auto entity = registry.create();
	registry.emplace<universe::ShipType>(entity, ship_type);
	registry.emplace<Team>(entity, team);
	registry.emplace<Transform>(entity, spawner.get(team));
	registry.emplace<FloatingMovement>(entity, 0.5, 2.0, 3.0, 0.1);
	registry.emplace<AIState>(entity, Point{0.0, 0.0});
	registry.emplace<HitPoints>(entity, ship_type.base_health_points);
	return entity;
}


entt::entity
Builder::operator()(const universe::TurretType& turret_type, const entt::entity& owner) const
{
	const auto entity = registry.create();
	registry.emplace<universe::TurretType>(entity, turret_type);
	registry.emplace<TurretControl>(entity, 0.0, owner);
	registry.emplace<Transform>(entity, Point{0.0, 0.0}, 0.0, owner);
	return entity;
}


}  // namespace battles
}  // namespace kurator