diff options
author | ClarkeCode <33846391+ClarkeCode@users.noreply.github.com> | 2023-04-14 22:16:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 22:16:23 +0200 |
commit | f168c91ff266beda8066014257a30d93704882ee (patch) | |
tree | 2c49198c3cbbbb575dc14795132a20c7b9267a2c /extension/src/Simulation.hpp | |
parent | 436b038c1806e326ff6458f1692e9009d3a54346 (diff) | |
parent | 48558fdfec509942515b0e2d92e3f1357b201400 (diff) |
Merge pull request #73 from OpenVic2Project/in-game-date
Added in-game date
Diffstat (limited to 'extension/src/Simulation.hpp')
-rw-r--r-- | extension/src/Simulation.hpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/extension/src/Simulation.hpp b/extension/src/Simulation.hpp index b84016b..58ba7c7 100644 --- a/extension/src/Simulation.hpp +++ b/extension/src/Simulation.hpp @@ -2,28 +2,39 @@ #include <godot_cpp/core/class_db.hpp> #include <vector> +#include <chrono> +#include "openvic2/Date.hpp" namespace OpenVic2 { class Simulation : public godot::Object { GDCLASS(Simulation, godot::Object) std::vector<uint64_t> exampleProvinces; + enum class Speed { Speed1 = 4000, Speed2 = 3000, Speed3 = 2000, Speed4 = 1000, Speed5 = 100, Speed6 = 1 }; + + std::chrono::time_point<std::chrono::high_resolution_clock> lastPolledTime; + bool isPaused; + Speed currentSpeed; + Date inGameDate; + //BEGIN BOILERPLATE inline static Simulation* _simulation = nullptr; - protected: + 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: + public: inline static Simulation* get_singleton() { return _simulation; } - inline Simulation() { + inline Simulation() : inGameDate(1836, 1, 1) { ERR_FAIL_COND(_simulation != nullptr); _simulation = this; - + this->lastPolledTime = std::chrono::high_resolution_clock::now(); + this->isPaused = false; + this->currentSpeed = Speed::Speed1; exampleProvinces.resize(10, 1); } inline ~Simulation() { @@ -32,6 +43,13 @@ namespace OpenVic2 { } //END BOILERPLATE + void togglePauseState(); + bool getPauseState(); + void increaseSimulationSpeed(); + void decreaseSimulationSpeed(); + void setSimulationSpeed(Speed speed); + int getSimulationSpeed(); + inline void conductSimulationStep() { for (uint64_t x = 0; x < exampleProvinces.size(); x++) { exampleProvinces[x] += (x + 1); @@ -44,5 +62,7 @@ namespace OpenVic2 { } return exampleProvinces[provinceID]; } + + void conditionallyAdvanceSimulation(); }; -} +}
\ No newline at end of file |