From 16a3bb02732c5ec938c282db46e889baaaf0f8f6 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 5 Sep 2024 13:39:47 +0200 Subject: [PATCH] Override _to_string() to print useful info about objects in GDExtension --- blackboard/blackboard.h | 4 ++++ blackboard/blackboard_plan.h | 4 ++++ bt/behavior_tree.h | 4 ++++ bt/bt_instance.h | 4 ++++ bt/bt_player.h | 4 ++++ bt/tasks/bt_task.h | 4 ++++ hsm/limbo_state.h | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/blackboard/blackboard.h b/blackboard/blackboard.h index 5758cfb..7d3e693 100644 --- a/blackboard/blackboard.h +++ b/blackboard/blackboard.h @@ -40,6 +40,10 @@ private: protected: static void _bind_methods(); +#ifdef LIMBOAI_GDEXTENSION + String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; } +#endif + public: void set_parent(const Ref &p_blackboard) { parent = p_blackboard; } Ref get_parent() const { return parent; } diff --git a/blackboard/blackboard_plan.h b/blackboard/blackboard_plan.h index c58fb21..a4e2071 100644 --- a/blackboard/blackboard_plan.h +++ b/blackboard/blackboard_plan.h @@ -55,6 +55,10 @@ protected: bool _property_can_revert(const StringName &p_name) 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: void set_base_plan(const Ref &p_base); Ref get_base_plan() const { return base; } diff --git a/bt/behavior_tree.h b/bt/behavior_tree.h index d6944c1..f2f2ce8 100644 --- a/bt/behavior_tree.h +++ b/bt/behavior_tree.h @@ -43,6 +43,10 @@ private: protected: static void _bind_methods(); +#ifdef LIMBOAI_GDEXTENSION + String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; } +#endif + public: #ifdef LIMBOAI_MODULE virtual bool editor_can_reload_from_file() override { return false; } diff --git a/bt/bt_instance.h b/bt/bt_instance.h index ad75915..d691529 100644 --- a/bt/bt_instance.h +++ b/bt/bt_instance.h @@ -37,6 +37,10 @@ private: protected: static void _bind_methods(); +#ifdef LIMBOAI_GDEXTENSION + String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; } +#endif + public: _FORCE_INLINE_ Ref get_root_task() const { return root_task; } _FORCE_INLINE_ Node *get_owner_node() const { return owner_node_id ? Object::cast_to(OBJECT_DB_GET_INSTANCE(owner_node_id)) : nullptr; } diff --git a/bt/bt_player.h b/bt/bt_player.h index 76987c9..8789314 100644 --- a/bt/bt_player.h +++ b/bt/bt_player.h @@ -56,6 +56,10 @@ protected: void _notification(int p_notification); +#ifdef LIMBOAI_GDEXTENSION + String _to_string() const { return String(get_name()) + ":<" + get_class() + "#" + itos(get_instance_id()) + ">"; } +#endif + public: void set_behavior_tree(const Ref &p_tree); Ref get_behavior_tree() const { return behavior_tree; }; diff --git a/bt/tasks/bt_task.h b/bt/tasks/bt_task.h index adc6759..2e5f92e 100644 --- a/bt/tasks/bt_task.h +++ b/bt/tasks/bt_task.h @@ -111,6 +111,10 @@ protected: GDVIRTUAL1R(Status, _tick, double); GDVIRTUAL0RC(PackedStringArray, _get_configuration_warnings); +#ifdef LIMBOAI_GDEXTENSION + String _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; } +#endif + public: // TODO: GDExtension doesn't have this method hmm... diff --git a/hsm/limbo_state.h b/hsm/limbo_state.h index d68d86c..31eed04 100644 --- a/hsm/limbo_state.h +++ b/hsm/limbo_state.h @@ -65,6 +65,10 @@ protected: GDVIRTUAL0(_exit); GDVIRTUAL1(_update, double); +#ifdef LIMBOAI_GDEXTENSION + String _to_string() const { return String(get_name()) + ":<" + get_class() + "#" + itos(get_instance_id()) + ">"; } +#endif + public: void set_blackboard_plan(const Ref &p_plan); _FORCE_INLINE_ Ref get_blackboard_plan() const { return blackboard_plan; }