aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/singletons/ModelSingleton.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-08-01 21:27:58 +0200
committer GitHub <noreply@github.com>2024-08-01 21:27:58 +0200
commitc254e078e5644699dd712361c891301d10eccc02 (patch)
tree70103040ed1e902c133eaee137c762bae53da3e6 /extension/src/openvic-extension/singletons/ModelSingleton.hpp
parentbf4d061b06374cd696f1f1644548f4d7af86f5ec (diff)
parent9aa25a773d0e6076d49dbe1a0831803c3eecb68c (diff)
Merge pull request #247 from OpenVicProject/model-dict-cache
Cache model and animation definition dictionaries
Diffstat (limited to 'extension/src/openvic-extension/singletons/ModelSingleton.hpp')
-rw-r--r--extension/src/openvic-extension/singletons/ModelSingleton.hpp24
1 files changed, 15 insertions, 9 deletions
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<GFX::Actor::Animation const*, godot::Dictionary>;
+ using model_map_t = deque_ordered_map<GFX::Actor const*, godot::Dictionary>;
+
+ 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<UnitType::branch_t Branch>
bool add_unit_dict(
ordered_set<UnitInstanceGroupBranched<Branch>*> const& units, godot::TypedArray<godot::Dictionary>& unit_array
- ) const;
+ );
bool add_building_dict(
BuildingInstance const& building, ProvinceInstance const& province,
godot::TypedArray<godot::Dictionary>& building_array
- ) const;
+ );
public:
- godot::TypedArray<godot::Dictionary> 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<godot::Dictionary> 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<godot::Dictionary> get_buildings() const;
+ godot::TypedArray<godot::Dictionary> get_buildings();
};
}