aboutsummaryrefslogtreecommitdiff
path: root/GameAdvancementHook.hpp
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-05-03 20:37:26 +0200
committer Hop311 <hop3114@gmail.com>2023-05-03 20:37:26 +0200
commit64bbf86b623a3cca2eaf9009d7acdcde067592e3 (patch)
tree5d607f28019675c9eaaa2883acf036717fa45b2f /GameAdvancementHook.hpp
parentc92481448159d3a363d6a99b3025bd2358c3dab6 (diff)
Moved code to src/openvic2
Diffstat (limited to 'GameAdvancementHook.hpp')
-rw-r--r--GameAdvancementHook.hpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/GameAdvancementHook.hpp b/GameAdvancementHook.hpp
deleted file mode 100644
index 07f8414..0000000
--- a/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