diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-08 18:12:22 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-08 18:12:22 +0200 |
commit | 7772f8871348b7b52cb0a478bb76df68d8799a07 (patch) | |
tree | fd8c4626b2cee69a9fe9250365af6b18eea63c70 /src/openvic/GameAdvancementHook.hpp | |
parent | 7f9a9a8241ba81be9213e6606b8be4a48f1cbaab (diff) |
More refactoring and duplicate code removal
Diffstat (limited to 'src/openvic/GameAdvancementHook.hpp')
-rw-r--r-- | src/openvic/GameAdvancementHook.hpp | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/openvic/GameAdvancementHook.hpp b/src/openvic/GameAdvancementHook.hpp deleted file mode 100644 index 59e43a4..0000000 --- a/src/openvic/GameAdvancementHook.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include <chrono> -#include <functional> -#include <vector> - -namespace OpenVic { - // 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: - using time_point_t = std::chrono::time_point<std::chrono::high_resolution_clock>; - - time_point_t 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 |