#pragma once #include "openvic-simulation/misc/Modifier.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" namespace OpenVic { struct TerrainTypeManager; // Using HasColour rather than HasIdentifierAndColour to avoid needing virtual inheritance // (extending Modifier is more useful than extending HasIdentifierAndColour). struct TerrainType : Modifier, HasColour { friend struct TerrainTypeManager; private: ModifierValue PROPERTY(modifier); const bool PROPERTY(is_water); TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_modifier, bool new_is_water); public: TerrainType(TerrainType&&) = default; }; struct TerrainTypeMapping : HasIdentifier { friend struct TerrainTypeManager; using index_t = uint8_t; private: TerrainType const& PROPERTY(type); std::vector PROPERTY(terrain_indices); const index_t PROPERTY(priority); const bool PROPERTY(has_texture); TerrainTypeMapping( std::string_view new_identifier, TerrainType const& new_type, std::vector&& new_terrain_indicies, index_t new_priority, bool new_has_texture ); public: TerrainTypeMapping(TerrainTypeMapping&&) = default; }; struct TerrainTypeManager { private: using terrain_type_mappings_map_t = ordered_map; IdentifierRegistry IDENTIFIER_REGISTRY(terrain_type); IdentifierRegistry IDENTIFIER_REGISTRY(terrain_type_mapping); terrain_type_mappings_map_t terrain_type_mappings_map; TerrainTypeMapping::index_t terrain_texture_limit = 0, terrain_texture_count = 0; NodeTools::node_callback_t _load_terrain_type_categories(ModifierManager const& modifier_manager); bool _load_terrain_type_mapping(std::string_view key, ast::NodeCPtr value); public: bool add_terrain_type(std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water); bool add_terrain_type_mapping( std::string_view identifier, TerrainType const* type, std::vector&& terrain_indicies, TerrainTypeMapping::index_t priority, bool has_texture ); TerrainTypeMapping const* get_terrain_type_mapping_for(TerrainTypeMapping::index_t idx) const; TerrainTypeMapping::index_t get_terrain_texture_limit() const; bool load_terrain_types(ModifierManager const& modifier_manager, ast::NodeCPtr root); }; }