aboutsummaryrefslogtreecommitdiff
path: root/extension/src/Simulation.cpp
diff options
context:
space:
mode:
author ClarkeCode <clarke.john.robert@gmail.com>2023-04-15 05:41:57 +0200
committer ClarkeCode <clarke.john.robert@gmail.com>2023-04-17 22:04:28 +0200
commit04b213d4e20ca4e7ea66b059329771f6fd36c650 (patch)
tree4ab10469ceff9a536587af6e9901a170c56af0ff /extension/src/Simulation.cpp
parentf168c91ff266beda8066014257a30d93704882ee (diff)
Removing TestSingleton
Extracted game advancement behaviour to separate class
Diffstat (limited to 'extension/src/Simulation.cpp')
-rw-r--r--extension/src/Simulation.cpp64
1 files changed, 0 insertions, 64 deletions
diff --git a/extension/src/Simulation.cpp b/extension/src/Simulation.cpp
deleted file mode 100644
index 5ea99c5..0000000
--- a/extension/src/Simulation.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "Simulation.hpp"
-
-namespace OpenVic2 {
- void Simulation::togglePauseState() {
- this->isPaused = !isPaused;
- }
-
- bool Simulation::getPauseState() {
- return this->isPaused;
- }
-
- void Simulation::increaseSimulationSpeed() {
- switch (this->currentSpeed) {
- case(Speed::Speed1):
- this->currentSpeed = Speed::Speed2;
- break;
- case(Speed::Speed2):
- this->currentSpeed = Speed::Speed3;
- break;
- case(Speed::Speed3):
- this->currentSpeed = Speed::Speed4;
- break;
- case(Speed::Speed4):
- this->currentSpeed = Speed::Speed5;
- break;
- }
- }
-
- void Simulation::decreaseSimulationSpeed() {
- switch (this->currentSpeed) {
- case(Speed::Speed2):
- this->currentSpeed = Speed::Speed1;
- break;
- case(Speed::Speed3):
- this->currentSpeed = Speed::Speed2;
- break;
- case(Speed::Speed4):
- this->currentSpeed = Speed::Speed3;
- break;
- case(Speed::Speed5):
- this->currentSpeed = Speed::Speed4;
- break;
- }
- }
-
- void Simulation::setSimulationSpeed(Speed speed) {
- this->currentSpeed = speed;
- }
-
- int Simulation::getSimulationSpeed() {
- return static_cast<int>(this->currentSpeed);
- }
-
- void Simulation::conditionallyAdvanceSimulation() {
- if (!(this->isPaused)) {
- std::chrono::time_point<std::chrono::high_resolution_clock> previousTime = this->lastPolledTime;
- std::chrono::time_point<std::chrono::high_resolution_clock> currentTime = std::chrono::high_resolution_clock::now();
- if (std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - previousTime).count() >= this->getSimulationSpeed()) {
- this->lastPolledTime = currentTime;
- this->inGameDate++;
- }
- }
- }
-}