diff options
author | Hop311 <Hop3114@gmail.com> | 2024-05-12 17:17:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-12 17:17:32 +0200 |
commit | bfccdb87d66304604ad018037db1581746646bfa (patch) | |
tree | ac4394e8ceaca22fa0deaeebd8cf5eafedecaa3e /extension/src/openvic-extension/singletons/ModelSingleton.hpp | |
parent | b0a533f945bbc6201fd7df4bc60746cb98efaba4 (diff) | |
parent | ac29e4040fc20c50c8f0eb64b1194f6398165eb0 (diff) |
Merge pull request #227 from OpenVicProject/models
Models
Diffstat (limited to 'extension/src/openvic-extension/singletons/ModelSingleton.hpp')
-rw-r--r-- | extension/src/openvic-extension/singletons/ModelSingleton.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/singletons/ModelSingleton.hpp b/extension/src/openvic-extension/singletons/ModelSingleton.hpp new file mode 100644 index 0000000..17c2dd0 --- /dev/null +++ b/extension/src/openvic-extension/singletons/ModelSingleton.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include <godot_cpp/classes/object.hpp> + +#include <openvic-simulation/interface/GFXObject.hpp> +#include <openvic-simulation/military/UnitInstance.hpp> + +namespace OpenVic { + class ModelSingleton : public godot::Object { + GDCLASS(ModelSingleton, godot::Object) + + static inline ModelSingleton* singleton = nullptr; + + protected: + static void _bind_methods(); + + public: + static ModelSingleton* get_singleton(); + + ModelSingleton(); + ~ModelSingleton(); + + private: + GFX::Actor const* get_actor(std::string_view name, bool error_on_fail = true) const; + GFX::Actor const* get_cultural_actor( + 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; + + template<utility::is_derived_from_specialization_of<UnitInstanceGroup> T> + bool add_unit_dict(ordered_set<T*> const& units, godot::TypedArray<godot::Dictionary>& unit_array) const; + + bool add_building_dict( + BuildingInstance const& building, Province 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::Dictionary get_flag_model(bool floating) const; + + godot::TypedArray<godot::Dictionary> get_buildings() const; + }; +} |