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
53
54
55
56
57
58
59
|
#include "Builder.h"
#include <entt/entity/registry.hpp>
#include <kurator/sim/components.h>
#include <kurator/sim/FloatingMovement.h>
#include <kurator/sim/HitPoints.h>
#include <kurator/sim/Point.h>
#include <kurator/sim/TurretControl.h>
#include <kurator/universe/ShipType.h>
#include <kurator/universe/TurretType.h>
#include "Spawner.h"
namespace kurator
{
namespace sim
{
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,
ship_type.max_speed,
ship_type.max_speed * 2.0,
ship_type.max_speed * 3.0);
registry.emplace<AIState>(entity, 6000.0, Point{0.0, 0.0});
registry.emplace<HitPoints>(entity, ship_type.base_structure_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, 0.0, turret_type.rounds, owner);
registry.emplace<Transform>(entity, Point{0.0, 0.0}, 0.0, owner);
return entity;
}
} // namespace sim
} // namespace kurator
|