From 9aa25a773d0e6076d49dbe1a0831803c3eecb68c Mon Sep 17 00:00:00 2001 From: hop311 Date: Wed, 31 Jul 2024 00:12:54 +0100 Subject: Cache model and animation definition dictionaries --- .../singletons/ModelSingleton.hpp | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'extension/src/openvic-extension/singletons/ModelSingleton.hpp') diff --git a/extension/src/openvic-extension/singletons/ModelSingleton.hpp b/extension/src/openvic-extension/singletons/ModelSingleton.hpp index 8030ffd..f0c45be 100644 --- a/extension/src/openvic-extension/singletons/ModelSingleton.hpp +++ b/extension/src/openvic-extension/singletons/ModelSingleton.hpp @@ -29,26 +29,32 @@ namespace OpenVic { std::string_view culture, std::string_view name, std::string_view fallback_name ) const; - godot::Dictionary make_animation_dict(GFX::Actor::Animation const& animation) const; - godot::Dictionary make_model_dict(GFX::Actor const& actor) const; + using animation_map_t = deque_ordered_map; + using model_map_t = deque_ordered_map; + + animation_map_t animation_cache; + model_map_t model_cache; + + godot::Dictionary get_animation_dict(GFX::Actor::Animation const& animation); + godot::Dictionary get_model_dict(GFX::Actor const& actor); template bool add_unit_dict( ordered_set*> const& units, godot::TypedArray& unit_array - ) const; + ); bool add_building_dict( BuildingInstance const& building, ProvinceInstance const& province, godot::TypedArray& building_array - ) const; + ); public: - godot::TypedArray get_units() const; - godot::Dictionary get_cultural_gun_model(godot::String const& culture) const; - godot::Dictionary get_cultural_helmet_model(godot::String const& culture) const; + godot::TypedArray get_units(); + godot::Dictionary get_cultural_gun_model(godot::String const& culture); + godot::Dictionary get_cultural_helmet_model(godot::String const& culture); - godot::Dictionary get_flag_model(bool floating) const; + godot::Dictionary get_flag_model(bool floating); - godot::TypedArray get_buildings() const; + godot::TypedArray get_buildings(); }; } -- cgit v1.2.3-56-ga3b1