diff options
author | hop311 <hop3114@gmail.com> | 2023-11-14 22:42:00 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-11-15 21:06:20 +0100 |
commit | 8271b1519e095ee3e7245cde2f0b54561c3ec619 (patch) | |
tree | 0168ea3d3125f68b700d53e3fa0ebdd80b337653 /src/openvic-simulation/economy/Building.hpp | |
parent | e031758cf68535e97045c07f36e2524676447778 (diff) |
Bookmark loading + province and building cleanup
Diffstat (limited to 'src/openvic-simulation/economy/Building.hpp')
-rw-r--r-- | src/openvic-simulation/economy/Building.hpp | 138 |
1 files changed, 49 insertions, 89 deletions
diff --git a/src/openvic-simulation/economy/Building.hpp b/src/openvic-simulation/economy/Building.hpp index c2eb1ef..ed1190b 100644 --- a/src/openvic-simulation/economy/Building.hpp +++ b/src/openvic-simulation/economy/Building.hpp @@ -18,7 +18,16 @@ namespace OpenVic { struct BuildingManager; - struct BuildingType; + + struct BuildingType : HasIdentifier { + friend struct BuildingManager; + + private: + BuildingType(std::string_view new_identifier); + + public: + BuildingType(BuildingType&&) = default; + }; /* REQUIREMENTS: * MAP-11, MAP-72, MAP-73 @@ -31,81 +40,43 @@ namespace OpenVic { using level_t = int16_t; private: - BuildingType const& type; - const ModifierValue modifier; - const std::string on_completion; // probably sound played on completion - const fixed_point_t completion_size; - const level_t max_level; - const Good::good_map_t goods_cost; - const fixed_point_t cost; - const Timespan build_time; // time - const bool visibility; - const bool on_map; // onmap - - const bool default_enabled; - ProductionType const* production_type; - const bool pop_build_factory; - const bool strategic_factory; - const bool advanced_factory; - - const level_t fort_level; // probably the step-per-level - - const uint64_t naval_capacity; - const std::vector<fixed_point_t> colonial_points; - const bool in_province; // province - const bool one_per_state; - const fixed_point_t colonial_range; - - const fixed_point_t infrastructure; - const bool spawn_railway_track; - - const bool sail; // only in clipper shipyard - const bool steam; // only in steamer shipyard - const bool capital; // only in naval base - const bool port; // only in naval base + BuildingType const& PROPERTY(type); + ModifierValue PROPERTY(modifier); + std::string PROPERTY(on_completion); // probably sound played on completion + fixed_point_t PROPERTY(completion_size); + level_t PROPERTY(max_level); + Good::good_map_t PROPERTY(goods_cost); + fixed_point_t PROPERTY(cost); + Timespan PROPERTY(build_time); // time + bool PROPERTY(visibility); + bool PROPERTY(on_map); // onmap + + bool PROPERTY(default_enabled); + ProductionType const* PROPERTY(production_type); + bool PROPERTY(pop_build_factory); + bool PROPERTY(strategic_factory); + bool PROPERTY(advanced_factory); + + level_t PROPERTY(fort_level); // probably the step-per-level + + uint64_t PROPERTY(naval_capacity); + std::vector<fixed_point_t> PROPERTY(colonial_points); + bool PROPERTY(in_province); // province + bool PROPERTY(one_per_state); + fixed_point_t PROPERTY(colonial_range); + + fixed_point_t PROPERTY(infrastructure); + bool PROPERTY(spawn_railway_track); + + bool PROPERTY(sail); // only in clipper shipyard + bool PROPERTY(steam); // only in steamer shipyard + bool PROPERTY(capital); // only in naval base + bool PROPERTY(port); // only in naval base Building(std::string_view identifier, BuildingType const& type, ARGS); public: Building(Building&&) = default; - - BuildingType const& get_type() const; - ModifierValue const& get_modifier() const; - std::string_view get_on_completion() const; - fixed_point_t get_completion_size() const; - level_t get_max_level() const; - Good::good_map_t const& get_goods_cost() const; - fixed_point_t get_cost() const; - Timespan get_build_time() const; - bool has_visibility() const; - bool is_on_map() const; - - bool is_default_enabled() const; - ProductionType const* get_production_type() const; - bool is_pop_built_factory() const; - bool is_strategic_factory() const; - bool is_advanced_factory() const; - - level_t get_fort_level() const; - - uint64_t get_naval_capacity() const; - std::vector<fixed_point_t> const& get_colonial_points() const; - bool is_in_province() const; - bool is_one_per_state() const; - fixed_point_t get_colonial_range() const; - - fixed_point_t get_infrastructure() const; - bool spawned_railway_track() const; - }; - - struct BuildingType : HasIdentifier { - friend struct BuildingManager; - - private: - BuildingType(std::string_view new_identifier); - - public: - BuildingType(BuildingType&&) = default; }; enum class ExpansionState { CannotExpand, CanExpand, Preparing, Expanding }; @@ -115,36 +86,27 @@ namespace OpenVic { using level_t = Building::level_t; private: - Building const& building; + Building const& PROPERTY(building); - level_t level = 0; - ExpansionState expansion_state = ExpansionState::CannotExpand; - Date start, end; - float expansion_progress; + level_t PROPERTY(level); + ExpansionState PROPERTY(expansion_state); + Date PROPERTY(start_date) + Date PROPERTY(end_date); + float PROPERTY(expansion_progress); bool _can_expand() const; public: - BuildingInstance(Building const& building); + BuildingInstance(Building const& new_building, level_t new_level = 0); BuildingInstance(BuildingInstance&&) = default; - Building const& get_building() const; - - level_t get_current_level() const; void set_level(level_t new_level); - ExpansionState get_expansion_state() const; - Date get_start_date() const; - Date get_end_date() const; - float get_expansion_progress() const; - bool expand(); void update_state(Date today); void tick(Date today); }; - struct Province; - struct BuildingManager { using level_t = Building::level_t; // this is getting ridiculous @@ -165,7 +127,5 @@ namespace OpenVic { GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, ModifierManager& modifier_manager, ast::NodeCPtr root ); - - bool generate_province_buildings(Province& province) const; }; } |