1 #include "Simulation.hpp"
6 #include "../creature/Creature.hpp"
14 Simulation::Simulation(Body &r, app::Assets &assets)
25 records[0].name = "Age";
26 records[0].type = Record::TIME;
27 records[1].name = "Mass";
28 records[1].type = Record::MASS;
29 records[2].name = "Size";
30 records[2].type = Record::LENGTH;
31 records[3].name = "Strength";
32 records[4].name = "Stamina";
33 records[5].name = "Dexerty";
34 records[6].name = "Intelligence";
37 Simulation::~Simulation() {
38 for (auto c : alive) {
46 void Simulation::Tick(double dt) {
48 for (auto body : bodies) {
51 for (auto c : alive) {
56 void Simulation::AddBody(Body &b) {
57 b.SetSimulation(*this);
61 void Simulation::AddPlanet(Planet &p) {
66 void Simulation::AddSun(Sun &s) {
71 void Simulation::SetAlive(creature::Creature *c) {
75 void Simulation::SetDead(creature::Creature *c) {
76 auto entry = std::find(alive.begin(), alive.end(), c);
77 if (entry != alive.end()) {
84 void Simulation::CheckRecords(creature::Creature &c) noexcept {
85 if (c.Age() > records[0].value) {
86 records[0].value = c.Age();
87 records[0].time = Time();
88 records[0].holder = &c;
90 if (c.Mass() > records[1].value) {
91 records[1].value = c.Mass();
92 records[1].time = Time();
93 records[1].holder = &c;
95 if (c.Size() > records[2].value) {
96 records[2].value = c.Size();
97 records[2].time = Time();
98 records[2].holder = &c;
100 if (c.Strength() > records[3].value) {
101 records[3].value = c.Strength();
102 records[3].time = Time();
103 records[3].holder = &c;
105 if (c.Stamina() > records[4].value) {
106 records[4].value = c.Stamina();
107 records[4].time = Time();
108 records[4].holder = &c;
110 if (c.Dexerty() > records[5].value) {
111 records[5].value = c.Dexerty();
112 records[5].time = Time();
113 records[5].holder = &c;
115 if (c.Intelligence() > records[6].value) {
116 records[6].value = c.Intelligence();
117 records[6].time = Time();
118 records[6].holder = &c;