API: Expose BlackboardPlan factory methods

This commit is contained in:
Serhii Snitsaruk 2024-03-02 16:06:32 +01:00
parent c4931ae420
commit bb6fab7555
4 changed files with 65 additions and 1 deletions

View File

@ -283,5 +283,10 @@ void BlackboardPlan::populate_blackboard(const Ref<Blackboard> &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() { BlackboardPlan::BlackboardPlan() {
} }

View File

@ -37,7 +37,7 @@ private:
Ref<BlackboardPlan> base; Ref<BlackboardPlan> base;
protected: protected:
static void _bind_methods() {} static void _bind_methods();
bool _set(const StringName &p_name, const Variant &p_value); bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const; bool _get(const StringName &p_name, Variant &r_ret) const;

View File

@ -14,6 +14,49 @@ BlackboardPlan
Stores and manages variables that will be used in constructing new :ref:`Blackboard<class_Blackboard>` instances. Stores and manages variables that will be used in constructing new :ref:`Blackboard<class_Blackboard>` instances.
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Blackboard<class_Blackboard>` | :ref:`create_blackboard<class_BlackboardPlan_method_create_blackboard>` **(** **)** |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`populate_blackboard<class_BlackboardPlan_method_populate_blackboard>` **(** :ref:`Blackboard<class_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<class_Blackboard>` **create_blackboard** **(** **)**
Constructs a new instance of a :ref:`Blackboard<class_Blackboard>` using this plan.
.. rst-class:: classref-item-separator
----
.. _class_BlackboardPlan_method_populate_blackboard:
.. rst-class:: classref-method
void **populate_blackboard** **(** :ref:`Blackboard<class_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.)` .. |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.)` .. |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.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`

View File

@ -7,4 +7,20 @@
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
<methods>
<method name="create_blackboard">
<return type="Blackboard" />
<description>
Constructs a new instance of a [Blackboard] using this plan.
</description>
</method>
<method name="populate_blackboard">
<return type="void" />
<param index="0" name="p_blackboard" type="Blackboard" />
<param index="1" name="p_overwrite" type="bool" />
<description>
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.
</description>
</method>
</methods>
</class> </class>