aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/GameAdvancementHook.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-05-04 15:47:20 +0200
committer GitHub <noreply@github.com>2023-05-04 15:47:20 +0200
commit7791a18094efaf62377606a7e5a7cba85a4c7a64 (patch)
treecd3ebcae0f67b07488fadb31ba3b376b306e03f6 /extension/src/openvic2/GameAdvancementHook.hpp
parent6fd8fc3a786370207508631e569c1e8f5ab0e4e3 (diff)
parent2420f8b8fdd2db84e053ebb2d7f6e4840171009e (diff)
Merge pull request #106 from OpenVic2Project/simulation-submodule
Moved simulation code to separate submodule
Diffstat (limited to 'extension/src/openvic2/GameAdvancementHook.hpp')
-rw-r--r--extension/src/openvic2/GameAdvancementHook.hpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/extension/src/openvic2/GameAdvancementHook.hpp b/extension/src/openvic2/GameAdvancementHook.hpp
deleted file mode 100644
index 1fe7737..0000000
--- a/extension/src/openvic2/GameAdvancementHook.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-
-#include <chrono>
-#include <functional>
-#include <vector>
-
-namespace OpenVic2 {
- // Conditionally advances game with provided behaviour
- // Class governs game speed and pause state
- class GameAdvancementHook {
- public:
- using AdvancementFunction = std::function<void()>;
- using RefreshFunction = std::function<void()>;
- using speed_t = int8_t;
-
- // Minimum number of miliseconds before the simulation advances
- static const std::vector<std::chrono::milliseconds> GAME_SPEEDS;
-
- private:
- std::chrono::time_point<std::chrono::high_resolution_clock> lastPolledTime;
- // A function pointer that advances the simulation, intended to be a capturing lambda or something similar. May need to be reworked later
- AdvancementFunction triggerFunction;
- RefreshFunction refreshFunction;
- speed_t currentSpeed;
-
- public:
- bool isPaused;
-
- GameAdvancementHook(AdvancementFunction tickFunction, RefreshFunction updateFunction, bool startPaused = true, speed_t startingSpeed = 0);
-
- void setSimulationSpeed(speed_t speed);
- speed_t getSimulationSpeed() const;
- void increaseSimulationSpeed();
- void decreaseSimulationSpeed();
- bool canIncreaseSimulationSpeed() const;
- bool canDecreaseSimulationSpeed() const;
- GameAdvancementHook& operator++();
- GameAdvancementHook& operator--();
- void conditionallyAdvanceGame();
- void reset();
- };
-} \ No newline at end of file