-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcenturia.cpp
More file actions
83 lines (74 loc) · 2.02 KB
/
Copy pathcenturia.cpp
File metadata and controls
83 lines (74 loc) · 2.02 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "centuria.h"
///
/// \brief Constructor.
/// \param t_inanimate_objects All static objects of the simulation
/// \param t_soldiers All moving objects, only Legionaries and Decani at this point
///
Centuria::Centuria(flist_PhysicalObject_ptr_cstref t_inanimate_objects,
flist_Soldier_ptr_cstref t_soldiers)
: m_soldiers(t_soldiers),
m_inanimate_objects(t_inanimate_objects)
{
formation(SQUARE);
//{ 10 , Contubernium{m_inanimate_objects, m_soldiers}}; jakoś nie działa tak jak sobie to wyobrażałem
for (int i = 0; i<10 ; i++ ) {
m_contubernia.push_back(Contubernium{m_inanimate_objects, m_soldiers});
}
}
///
/// \brief Make a next step of simulation.
///
void Centuria::step()
{
std::for_each(m_contubernia.begin(), m_contubernia.end(), [&](Contubernium& contubernium) {
contubernium.step();
});
}
///
/// \brief Gets actual formation set in Centuria.
/// \return Formation Formation enum
///
const Formation &Centuria::formation() const
{
return m_formation;
}
///
/// \brief Sets new formation for Centuria.
/// \param new_formation New formation
///
void Centuria::formation(const enum Formation &new_formation)
{
m_formation = new_formation;
sendOrdersDown();
}
///
/// \brief Contubernia getter.
/// \return Vector of all contubernia the centuria consists of.
///
const std::vector<Contubernium> &Centuria::contubernia() const
{
return m_contubernia;
}
///
/// \brief Center of contubernia getter.
/// \return Requested center point of centuria
///
const Position &Centuria::center()
{
return m_center;
}
///
/// \brief Center of contubernia setter.
///
void Centuria::center(const Position &requested_center)
{
m_center = requested_center;
}
///
/// \brief Sends orders put most likely by user down to contubernia and to decani.
///
void Centuria::sendOrdersDown() {
std::for_each(m_contubernia.begin(), m_contubernia.end(), [&](Contubernium& u) {
u.sendOrdersDown(formation());
});
}