blob: 6ade8464890567b53561706502a5765955ddbefd (
plain) (
blame)
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
|
#pragma once
#include <godot_cpp/classes/object.hpp>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
#include <vector>
namespace OpenVic2 {
class Simulation : public godot::Object {
std::vector<size_t> exampleProvinces;
//BEGIN BOILERPLATE
GDCLASS(Simulation, godot::Object);
static Simulation* _simulation;
protected:
static void _bind_methods() {
godot::ClassDB::bind_method(godot::D_METHOD("conductSimulationStep"), &Simulation::conductSimulationStep);
godot::ClassDB::bind_method(godot::D_METHOD("queryProvinceSize"), &Simulation::queryProvinceSize);
}
public:
inline static Simulation* get_singleton() { return _simulation; }
inline Simulation() {
ERR_FAIL_COND(_simulation != nullptr);
_simulation = this;
exampleProvinces.resize(10, 1);
}
inline ~Simulation() {
ERR_FAIL_COND(_simulation != this);
_simulation = nullptr;
}
//END BOILERPLATE
inline void conductSimulationStep() {
for (size_t x = 0; x < exampleProvinces.size(); x++) {
exampleProvinces[x] += (x + 1);
}
}
inline size_t queryProvinceSize(size_t provinceID) {
if (provinceID >= exampleProvinces.size()) {
return 0;
}
return exampleProvinces[provinceID];
}
};
Simulation* Simulation::_simulation = nullptr;
}
|