aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/GameManager.hpp
blob: 3ac9de32d321f2dd4293fbe13c0f248e086fa2b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include "openvic-simulation/GameAdvancementHook.hpp"
#include "openvic-simulation/Modifier.hpp"
#include "openvic-simulation/country/Country.hpp"
#include "openvic-simulation/economy/EconomyManager.hpp"
#include "openvic-simulation/history/HistoryManager.hpp"
#include "openvic-simulation/interface/UI.hpp"
#include "openvic-simulation/map/Map.hpp"
#include "openvic-simulation/military/MilitaryManager.hpp"
#include "openvic-simulation/misc/Define.hpp"
#include "openvic-simulation/politics/PoliticsManager.hpp"

namespace OpenVic {
   struct GameManager {
      using state_updated_func_t = std::function<void()>;

   private:
      Map map;
      DefineManager define_manager;
      EconomyManager economy_manager;
      MilitaryManager military_manager;
      ModifierManager modifier_manager;
      PoliticsManager politics_manager;
      HistoryManager history_manager;
      PopManager pop_manager;
      CountryManager country_manager;
      UIManager ui_manager;
      GameAdvancementHook clock;

      time_t session_start; /* SS-54, as well as allowing time-tracking */
      Bookmark const* PROPERTY(bookmark);
      Date PROPERTY(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);

      REF_GETTERS(map)
      REF_GETTERS(define_manager)
      REF_GETTERS(economy_manager)
      REF_GETTERS(military_manager)
      REF_GETTERS(modifier_manager)
      REF_GETTERS(politics_manager)
      REF_GETTERS(history_manager)
      REF_GETTERS(pop_manager)
      REF_GETTERS(country_manager)
      REF_GETTERS(ui_manager)
      REF_GETTERS(clock)

      bool reset();
      bool load_bookmark(Bookmark const* new_bookmark);

      bool expand_building(Province::index_t province_index, 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();
   };
}