Override _to_string() to print useful info about objects in GDExtension

This commit is contained in:
Serhii Snitsaruk 2024-09-05 13:39:47 +02:00
parent ac209e7fc3
commit 16a3bb0273
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
7 changed files with 28 additions and 0 deletions

View File

@ -40,6 +40,10 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
void set_parent(const Ref<Blackboard> &p_blackboard) { parent = p_blackboard; } void set_parent(const Ref<Blackboard> &p_blackboard) { parent = p_blackboard; }
Ref<Blackboard> get_parent() const { return parent; } Ref<Blackboard> get_parent() const { return parent; }

View File

@ -55,6 +55,10 @@ protected:
bool _property_can_revert(const StringName &p_name) const; bool _property_can_revert(const StringName &p_name) const;
bool _property_get_revert(const StringName &p_name, Variant &r_property) const; bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
void set_base_plan(const Ref<BlackboardPlan> &p_base); void set_base_plan(const Ref<BlackboardPlan> &p_base);
Ref<BlackboardPlan> get_base_plan() const { return base; } Ref<BlackboardPlan> get_base_plan() const { return base; }

View File

@ -43,6 +43,10 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
virtual bool editor_can_reload_from_file() override { return false; } virtual bool editor_can_reload_from_file() override { return false; }

View File

@ -37,6 +37,10 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
_FORCE_INLINE_ Ref<BTTask> get_root_task() const { return root_task; } _FORCE_INLINE_ Ref<BTTask> get_root_task() const { return root_task; }
_FORCE_INLINE_ Node *get_owner_node() const { return owner_node_id ? Object::cast_to<Node>(OBJECT_DB_GET_INSTANCE(owner_node_id)) : nullptr; } _FORCE_INLINE_ Node *get_owner_node() const { return owner_node_id ? Object::cast_to<Node>(OBJECT_DB_GET_INSTANCE(owner_node_id)) : nullptr; }

View File

@ -56,6 +56,10 @@ protected:
void _notification(int p_notification); void _notification(int p_notification);
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return String(get_name()) + ":<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
void set_behavior_tree(const Ref<BehaviorTree> &p_tree); void set_behavior_tree(const Ref<BehaviorTree> &p_tree);
Ref<BehaviorTree> get_behavior_tree() const { return behavior_tree; }; Ref<BehaviorTree> get_behavior_tree() const { return behavior_tree; };

View File

@ -111,6 +111,10 @@ protected:
GDVIRTUAL1R(Status, _tick, double); GDVIRTUAL1R(Status, _tick, double);
GDVIRTUAL0RC(PackedStringArray, _get_configuration_warnings); GDVIRTUAL0RC(PackedStringArray, _get_configuration_warnings);
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
// TODO: GDExtension doesn't have this method hmm... // TODO: GDExtension doesn't have this method hmm...

View File

@ -65,6 +65,10 @@ protected:
GDVIRTUAL0(_exit); GDVIRTUAL0(_exit);
GDVIRTUAL1(_update, double); GDVIRTUAL1(_update, double);
#ifdef LIMBOAI_GDEXTENSION
String _to_string() const { return String(get_name()) + ":<" + get_class() + "#" + itos(get_instance_id()) + ">"; }
#endif
public: public:
void set_blackboard_plan(const Ref<BlackboardPlan> &p_plan); void set_blackboard_plan(const Ref<BlackboardPlan> &p_plan);
_FORCE_INLINE_ Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; } _FORCE_INLINE_ Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; }