From c541a249247b7fe3bdd4c62bce6638e875790f8a Mon Sep 17 00:00:00 2001 From: zaaarf Date: Thu, 28 Sep 2023 15:40:34 +0200 Subject: feat: implemented building loading and missing parameters --- src/openvic-simulation/map/Building.hpp | 60 +++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'src/openvic-simulation/map/Building.hpp') diff --git a/src/openvic-simulation/map/Building.hpp b/src/openvic-simulation/map/Building.hpp index cd649ff..9b11c1c 100644 --- a/src/openvic-simulation/map/Building.hpp +++ b/src/openvic-simulation/map/Building.hpp @@ -1,19 +1,18 @@ #pragma once -#include -#include -#include - #include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" #include "openvic-simulation/economy/Good.hpp" #include "openvic-simulation/economy/ProductionType.hpp" +#include "openvic-simulation/Modifier.hpp" -#define ARGS BuildingType const& type, sound_t on_completion, fixed_point_t completion_size, level_t max_level, std::map build_cost, \ - Timespan build_time, bool visibility, bool on_map, const bool default_enabled, ProductionType const* production_type, bool pop_build_factory, \ - bool strategic_factory, level_t fort_level, uint64_t naval_capacity, std::vector colonial_points, bool in_province, bool one_per_state, \ - uint64_t colonial_range, fixed_point_t infrastructure, fixed_point_t movement_cost, bool spawn_railway_track +#define ARGS BuildingType const& type, std::string_view on_completion, fixed_point_t completion_size, level_t max_level, \ + std::map goods_cost, fixed_point_t cost, Timespan build_time, bool visibility, bool on_map, bool default_enabled, \ + ProductionType const* production_type, bool pop_build_factory, bool strategic_factory, bool advanced_factory, level_t fort_level, \ + uint64_t naval_capacity, std::vector colonial_points, bool in_province, bool one_per_state, fixed_point_t colonial_range, \ + fixed_point_t infrastructure, fixed_point_t movement_cost, fixed_point_t local_ship_build, bool spawn_railway_track, bool sail, bool steam, \ + bool capital, bool port, ModifierValue&& modifiers namespace OpenVic { @@ -25,40 +24,45 @@ namespace OpenVic { * MAP-12, MAP-75, MAP-76 * MAP-13, MAP-78, MAP-79 */ - struct Building : HasIdentifier { + struct Building : HasIdentifier, ModifierValue { friend struct BuildingManager; using level_t = uint8_t; - using sound_t = std::string_view; private: BuildingType const& type; - const sound_t on_completion; //probably sound played on completion + const std::string_view on_completion; //probably sound played on completion const fixed_point_t completion_size; const level_t max_level; - const std::map build_cost; + const std::map goods_cost; + const fixed_point_t cost; const Timespan build_time; //time const bool visibility; const bool on_map; //onmap - const bool default_enabled; //some(false) + 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; //some(0), probably the step-per-level? + const level_t fort_level; //probably the step-per-level - const uint64_t naval_capacity; //some(0) + const uint64_t naval_capacity; const std::vector colonial_points; - const bool in_province; //province some(false) + const bool in_province; //province const bool one_per_state; - const uint64_t colonial_range; + const fixed_point_t colonial_range; const fixed_point_t infrastructure; const fixed_point_t movement_cost; - const bool spawn_railway_track; //some(false) + const fixed_point_t local_ship_build; + const bool spawn_railway_track; - //any modifiers really + 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 Building(std::string_view identifier, ARGS); @@ -66,10 +70,11 @@ namespace OpenVic { Building(Building&&) = default; BuildingType const& get_type() const; - sound_t get_on_completion() const; + std::string_view get_on_completion() const; fixed_point_t get_completion_size() const; level_t get_max_level() const; - std::map const& get_build_cost() const; + std::map 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; @@ -78,6 +83,7 @@ namespace OpenVic { 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; @@ -85,10 +91,11 @@ namespace OpenVic { std::vector const& get_colonial_points() const; bool is_in_province() const; bool is_one_per_state() const; - uint64_t get_colonial_range() const; + fixed_point_t get_colonial_range() const; fixed_point_t get_infrastructure() const; fixed_point_t get_movement_cost() const; + fixed_point_t get_local_ship_build() const; bool spawned_railway_track() const; }; @@ -145,6 +152,8 @@ namespace OpenVic { struct Province; struct BuildingManager { + using level_t = Building::level_t; //this is getting ridiculous + private: IdentifierRegistry building_types; IdentifierRegistry buildings; @@ -154,11 +163,12 @@ namespace OpenVic { bool add_building_type(const std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(BuildingType, building_type) - bool generate_province_buildings(Province& province) const; - bool add_building(std::string_view identifier); + bool add_building(std::string_view identifier, ARGS); IDENTIFIER_REGISTRY_ACCESSORS(Building, building) - //bool load_buildings_file(ast::NodeCPtr root); + bool load_buildings_file(GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root); + + bool generate_province_buildings(Province& province) const; }; } -- cgit v1.2.3-56-ga3b1