From bb6fab7555f1481fc7d550788977684bbcfa77e3 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sat, 2 Mar 2024 16:06:32 +0100 Subject: [PATCH] API: Expose BlackboardPlan factory methods --- blackboard/blackboard_plan.cpp | 5 +++ blackboard/blackboard_plan.h | 2 +- doc/source/classes/class_blackboardplan.rst | 43 +++++++++++++++++++++ doc_classes/BlackboardPlan.xml | 16 ++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/blackboard/blackboard_plan.cpp b/blackboard/blackboard_plan.cpp index b372199..b6375f5 100644 --- a/blackboard/blackboard_plan.cpp +++ b/blackboard/blackboard_plan.cpp @@ -283,5 +283,10 @@ void BlackboardPlan::populate_blackboard(const Ref &p_blackboard, bo } } +void BlackboardPlan::_bind_methods() { + ClassDB::bind_method(D_METHOD("create_blackboard"), &BlackboardPlan::create_blackboard); + ClassDB::bind_method(D_METHOD("populate_blackboard", "p_blackboard", "p_overwrite"), &BlackboardPlan::populate_blackboard); +} + BlackboardPlan::BlackboardPlan() { } diff --git a/blackboard/blackboard_plan.h b/blackboard/blackboard_plan.h index 4b6e064..b3281f8 100644 --- a/blackboard/blackboard_plan.h +++ b/blackboard/blackboard_plan.h @@ -37,7 +37,7 @@ private: Ref base; protected: - static void _bind_methods() {} + static void _bind_methods(); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; diff --git a/doc/source/classes/class_blackboardplan.rst b/doc/source/classes/class_blackboardplan.rst index 251fab3..d08ac4a 100644 --- a/doc/source/classes/class_blackboardplan.rst +++ b/doc/source/classes/class_blackboardplan.rst @@ -14,6 +14,49 @@ BlackboardPlan Stores and manages variables that will be used in constructing new :ref:`Blackboard` instances. +.. rst-class:: classref-reftable-group + +Methods +------- + +.. table:: + :widths: auto + + +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | :ref:`Blackboard` | :ref:`create_blackboard` **(** **)** | + +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | void | :ref:`populate_blackboard` **(** :ref:`Blackboard` p_blackboard, bool p_overwrite **)** | + +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. rst-class:: classref-section-separator + +---- + +.. rst-class:: classref-descriptions-group + +Method Descriptions +------------------- + +.. _class_BlackboardPlan_method_create_blackboard: + +.. rst-class:: classref-method + +:ref:`Blackboard` **create_blackboard** **(** **)** + +Constructs a new instance of a :ref:`Blackboard` using this plan. + +.. rst-class:: classref-item-separator + +---- + +.. _class_BlackboardPlan_method_populate_blackboard: + +.. rst-class:: classref-method + +void **populate_blackboard** **(** :ref:`Blackboard` p_blackboard, bool p_overwrite **)** + +Populates ``p_blackboard`` with the variables from this plan. If ``p_override`` is ``true``, existing variables with the same names will be overwritten. + .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` diff --git a/doc_classes/BlackboardPlan.xml b/doc_classes/BlackboardPlan.xml index 6a7a48c..0b39b81 100644 --- a/doc_classes/BlackboardPlan.xml +++ b/doc_classes/BlackboardPlan.xml @@ -7,4 +7,20 @@ + + + + + Constructs a new instance of a [Blackboard] using this plan. + + + + + + + + Populates [param p_blackboard] with the variables from this plan. If [param p_override] is [code]true[/code], existing variables with the same names will be overwritten. + + +