From 7772f8871348b7b52cb0a478bb76df68d8799a07 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Fri, 8 Sep 2023 17:12:22 +0100 Subject: More refactoring and duplicate code removal --- src/openvic-simulation/GameManager.hpp | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/openvic-simulation/GameManager.hpp (limited to 'src/openvic-simulation/GameManager.hpp') diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp new file mode 100644 index 0000000..d221a99 --- /dev/null +++ b/src/openvic-simulation/GameManager.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include "openvic-simulation/GameAdvancementHook.hpp" +#include "openvic-simulation/economy/Good.hpp" +#include "openvic-simulation/map/Map.hpp" + +namespace OpenVic { + struct GameManager { + using state_updated_func_t = std::function; + + Map map; + BuildingManager building_manager; + GoodManager good_manager; + PopManager pop_manager; + GameAdvancementHook clock; + + private: + time_t session_start; /* SS-54, as well as allowing time-tracking */ + Date today; + state_updated_func_t state_updated; + bool needs_update; + + void set_needs_update(); + void update_state(); + void tick(); + + public: + GameManager(state_updated_func_t state_updated_callback); + + bool setup(); + + Date const& get_today() const; + bool expand_building(Province::index_t province_index, const std::string_view building_type_identifier); + + /* Hardcoded data for defining things for which parsing from files has + * not been implemented, currently mapmodes and building types. + */ + bool load_hardcoded_defines(); + }; +} -- cgit v1.2.3-56-ga3b1