aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/misc/GameAdvancementHook.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-12-28 17:43:43 +0100
committer GitHub <noreply@github.com>2023-12-28 17:43:43 +0100
commit0a425fbe05d6138b753c0e4a7c06f06695bde8af (patch)
tree8f67577b0101c06e2a7cc4d4c277d686d16d3d75 /src/openvic-simulation/misc/GameAdvancementHook.hpp
parent56a865d7d0868b785eb6b9b723f0e52f65e6457d (diff)
parent12a47833bbe72d50271bde15c7579c1e801863c2 (diff)
Merge pull request #110 from OpenVicProject/clock-refactor
Clock refactor + misc small fixes
Diffstat (limited to 'src/openvic-simulation/misc/GameAdvancementHook.hpp')
-rw-r--r--src/openvic-simulation/misc/GameAdvancementHook.hpp47
1 files changed, 0 insertions, 47 deletions
diff --git a/src/openvic-simulation/misc/GameAdvancementHook.hpp b/src/openvic-simulation/misc/GameAdvancementHook.hpp
deleted file mode 100644
index 75af718..0000000
--- a/src/openvic-simulation/misc/GameAdvancementHook.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#pragma once
-
-#include <chrono>
-#include <functional>
-#include <vector>
-#include "openvic-simulation/utility/Getters.hpp"
-
-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 last_polled_time;
- // A function pointer that advances the simulation, intended to be a capturing
- // lambda or something similar. May need to be reworked later
- AdvancementFunction trigger_function;
- RefreshFunction refresh_function;
- speed_t PROPERTY_CUSTOM_NAME(current_speed, get_simulation_speed);
-
- public:
- bool is_paused;
-
- GameAdvancementHook(
- AdvancementFunction tick_function, RefreshFunction update_function, bool start_paused = true, speed_t starting_speed = 0
- );
-
- void set_simulation_speed(speed_t speed);
- void increase_simulation_speed();
- void decrease_simulation_speed();
- bool can_increase_simulation_speed() const;
- bool can_decrease_simulation_speed() const;
- GameAdvancementHook& operator++();
- GameAdvancementHook& operator--();
- void conditionally_advance_game();
- void reset();
- };
-}