aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/research/Invention.hpp
blob: 5d311550bbf620f99367078843ebb40fb509f66f (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
#pragma once

#include "openvic-simulation/misc/Modifier.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
#include "openvic-simulation/types/OrderedContainers.hpp"

namespace OpenVic {
   struct Unit;
   struct BuildingType;
   struct Crime;

   struct UnitManager;
   struct BuildingTypeManager;
   struct CrimeManager;

   struct Invention : Modifier {
      friend struct InventionManager;
      //TODO implement limit and chance
      using unit_set_t = ordered_set<Unit const*>;
      using building_set_t = ordered_set<BuildingType const*>;
      using crime_set_t = ordered_set<Crime const*>;

   private:
      const bool PROPERTY_CUSTOM_PREFIX(news, is);
      unit_set_t PROPERTY(activated_units);
      building_set_t PROPERTY(activated_buildings);
      crime_set_t PROPERTY(enabled_crimes);
      const bool PROPERTY_CUSTOM_PREFIX(unlock_gas_attack, will);
      const bool PROPERTY_CUSTOM_PREFIX(unlock_gas_defence, will);

      Invention(
         std::string_view new_identifier, ModifierValue&& new_values, bool new_news, unit_set_t&& new_activated_units,
         building_set_t&& new_activated_buildings, crime_set_t&& new_enabled_crimes, bool new_unlock_gas_attack,
         bool new_unlock_gas_defence
      );

   public:
      Invention(Invention&&) = default;
   };

   struct InventionManager {
      IdentifierRegistry<Invention> IDENTIFIER_REGISTRY(invention);

   public:
      bool add_invention(
         std::string_view identifier, ModifierValue&& values, bool news, Invention::unit_set_t&& activated_units,
         Invention::building_set_t&& activated_buildings, Invention::crime_set_t&& enabled_crimes, bool unlock_gas_attack,
         bool unlock_gas_defence
      );

      bool load_inventions_file(
         ModifierManager const& modifier_manager, UnitManager const& unit_manager,
         BuildingTypeManager const& building_type_manager, CrimeManager const& crime_manager, ast::NodeCPtr root
      ); // inventions/*.txt
   };
}