diff options
author | zaaarf <80046572+zaaarf@users.noreply.github.com> | 2023-12-05 22:53:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 22:53:07 +0100 |
commit | 48a3f1729d709847d7cad33f594c77cac414e802 (patch) | |
tree | d890ed3ca182a960a35e5d1edae16e32e7f2b836 /src/openvic-simulation/research/Invention.hpp | |
parent | db00dcfb8c72448fea73e752e1f5c18047738876 (diff) | |
parent | fa2ca50905f327713207069cf9a2e66cf6c00076 (diff) |
Merge pull request #83 from OpenVicProject/dataloading-inventions
Dataloading inventions
Diffstat (limited to 'src/openvic-simulation/research/Invention.hpp')
-rw-r--r-- | src/openvic-simulation/research/Invention.hpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/openvic-simulation/research/Invention.hpp b/src/openvic-simulation/research/Invention.hpp new file mode 100644 index 0000000..321d982 --- /dev/null +++ b/src/openvic-simulation/research/Invention.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include "openvic-simulation/economy/BuildingType.hpp" +#include "openvic-simulation/military/Unit.hpp" +#include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/types/IdentifierRegistry.hpp" +#include <string_view> +#include <unordered_set> + +namespace OpenVic { + struct Invention : Modifier { + friend struct InventionManager; + //TODO implement limit and chance + using unit_set_t = std::unordered_set<Unit const*>; + using building_set_t = std::unordered_set<BuildingType const*>; + using crime_set_t = std::unordered_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 identifier, ModifierValue&& values, bool news, unit_set_t activated_units, + building_set_t activated_buildings, crime_set_t enabled_crimes, bool unlock_gas_attack, + bool unlock_gas_defence + ); + + public: + Invention(Invention&&) = default; + }; + + struct InventionManager { + IdentifierRegistry<Invention> inventions; + + public: + InventionManager(); + + 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 + ); + + IDENTIFIER_REGISTRY_ACCESSORS(invention); + + bool load_inventions_file( + ModifierManager const& modifier_manager, UnitManager const& unit_manager, BuildingManager const& building_manager, + ast::NodeCPtr root + ); // inventions/*.txt + }; +}
\ No newline at end of file |