Compare commits

..

No commits in common. "d920060dee81d6edcfdc094c314cc5df25f57aab" and "3cf90f938774a7feb42ece1941460086e848d0dc" have entirely different histories.

10 changed files with 77 additions and 148 deletions

View File

@ -425,11 +425,12 @@ void BlackboardPlan::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_base_plan", "blackboard_plan"), &BlackboardPlan::set_base_plan);
ClassDB::bind_method(D_METHOD("get_base_plan"), &BlackboardPlan::get_base_plan);
ClassDB::bind_method(D_METHOD("is_derived"), &BlackboardPlan::is_derived);
ClassDB::bind_method(D_METHOD("sync_with_base_plan"), &BlackboardPlan::sync_with_base_plan);
ClassDB::bind_method(D_METHOD("set_parent_scope_plan_provider", "callable"), &BlackboardPlan::set_parent_scope_plan_provider);
ClassDB::bind_method(D_METHOD("get_parent_scope_plan_provider"), &BlackboardPlan::get_parent_scope_plan_provider);
ClassDB::bind_method(D_METHOD("create_blackboard", "node", "parent_scope"), &BlackboardPlan::create_blackboard);
ClassDB::bind_method(D_METHOD("is_mapping_enabled"), &BlackboardPlan::is_mapping_enabled);
ClassDB::bind_method(D_METHOD("is_derived"), &BlackboardPlan::is_derived);
ClassDB::bind_method(D_METHOD("sync_with_base_plan"), &BlackboardPlan::sync_with_base_plan);
ClassDB::bind_method(D_METHOD("create_blackboard", "node"), &BlackboardPlan::create_blackboard);
ClassDB::bind_method(D_METHOD("populate_blackboard", "blackboard", "overwrite", "node"), &BlackboardPlan::populate_blackboard);
// To avoid cluttering the member namespace, we do not export unnecessary properties in this class.

View File

@ -35,20 +35,16 @@ Methods
:widths: auto
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Blackboard<class_Blackboard>` | :ref:`create_blackboard<class_BlackboardPlan_method_create_blackboard>` **(** Node node, :ref:`Blackboard<class_Blackboard>` parent_scope **)** |
| :ref:`Blackboard<class_Blackboard>` | :ref:`create_blackboard<class_BlackboardPlan_method_create_blackboard>` **(** Node node **)** |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BlackboardPlan<class_BlackboardPlan>` | :ref:`get_base_plan<class_BlackboardPlan_method_get_base_plan>` **(** **)** |const| |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Callable | :ref:`get_parent_scope_plan_provider<class_BlackboardPlan_method_get_parent_scope_plan_provider>` **(** **)** |const| |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`is_derived<class_BlackboardPlan_method_is_derived>` **(** **)** |const| |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`populate_blackboard<class_BlackboardPlan_method_populate_blackboard>` **(** :ref:`Blackboard<class_Blackboard>` blackboard, bool overwrite, Node node **)** |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_base_plan<class_BlackboardPlan_method_set_base_plan>` **(** :ref:`BlackboardPlan<class_BlackboardPlan>` blackboard_plan **)** |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_parent_scope_plan_provider<class_BlackboardPlan_method_set_parent_scope_plan_provider>` **(** Callable callable **)** |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`sync_with_base_plan<class_BlackboardPlan_method_sync_with_base_plan>` **(** **)** |
+---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@ -87,7 +83,7 @@ Method Descriptions
.. rst-class:: classref-method
:ref:`Blackboard<class_Blackboard>` **create_blackboard** **(** Node node, :ref:`Blackboard<class_Blackboard>` parent_scope **)**
:ref:`Blackboard<class_Blackboard>` **create_blackboard** **(** Node node **)**
Constructs a new instance of a :ref:`Blackboard<class_Blackboard>` using this plan. If ``NodePath`` prefetching is enabled, ``node`` will be used to retrieve node instances for ``NodePath`` variables and substitute their values.
@ -107,18 +103,6 @@ Returns the base plan. See :ref:`is_derived<class_BlackboardPlan_method_is_deriv
----
.. _class_BlackboardPlan_method_get_parent_scope_plan_provider:
.. rst-class:: classref-method
Callable **get_parent_scope_plan_provider** **(** **)** |const|
Returns the parent scope plan provider - a callable that returns a **BlackboardPlan**.
.. rst-class:: classref-item-separator
----
.. _class_BlackboardPlan_method_is_derived:
.. rst-class:: classref-method
@ -157,18 +141,6 @@ Use with caution, as it will remove variables not present in the base plan. Only
----
.. _class_BlackboardPlan_method_set_parent_scope_plan_provider:
.. rst-class:: classref-method
void **set_parent_scope_plan_provider** **(** Callable callable **)**
Sets the parent scope plan provider - a callable that returns a **BlackboardPlan**. Used to provide hints in the inspector. When set, mapping feature becomes available.
.. rst-class:: classref-item-separator
----
.. _class_BlackboardPlan_method_sync_with_base_plan:
.. rst-class:: classref-method

View File

@ -59,61 +59,59 @@ Methods
.. table::
:widths: auto
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_enter<class_BTTask_private_method__enter>` **(** **)** |virtual| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_exit<class_BTTask_private_method__exit>` **(** **)** |virtual| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`_generate_name<class_BTTask_private_method__generate_name>` **(** **)** |virtual| |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| PackedStringArray | :ref:`_get_configuration_warnings<class_BTTask_private_method__get_configuration_warnings>` **(** **)** |virtual| |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_setup<class_BTTask_private_method__setup>` **(** **)** |virtual| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Status<enum_BT_Status>` | :ref:`_tick<class_BTTask_private_method__tick>` **(** float delta **)** |virtual| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`abort<class_BTTask_method_abort>` **(** **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_child<class_BTTask_method_add_child>` **(** :ref:`BTTask<class_BTTask>` task **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_child_at_index<class_BTTask_method_add_child_at_index>` **(** :ref:`BTTask<class_BTTask>` task, int idx **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BTTask<class_BTTask>` | :ref:`clone<class_BTTask_method_clone>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BehaviorTree<class_BehaviorTree>` | :ref:`editor_get_behavior_tree<class_BTTask_method_editor_get_behavior_tree>` **(** **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Status<enum_BT_Status>` | :ref:`execute<class_BTTask_method_execute>` **(** float delta **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BTTask<class_BTTask>` | :ref:`get_child<class_BTTask_method_get_child>` **(** int idx **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| int | :ref:`get_child_count<class_BTTask_method_get_child_count>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| int | :ref:`get_child_count_excluding_comments<class_BTTask_method_get_child_count_excluding_comments>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| int | :ref:`get_index<class_BTTask_method_get_index>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BTTask<class_BTTask>` | :ref:`get_parent<class_BTTask_method_get_parent>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BTTask<class_BTTask>` | :ref:`get_root<class_BTTask_method_get_root>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`get_task_name<class_BTTask_method_get_task_name>` **(** **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`has_child<class_BTTask_method_has_child>` **(** :ref:`BTTask<class_BTTask>` task **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`initialize<class_BTTask_method_initialize>` **(** Node agent, :ref:`Blackboard<class_Blackboard>` blackboard, Node scene_root **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`is_descendant_of<class_BTTask_method_is_descendant_of>` **(** :ref:`BTTask<class_BTTask>` task **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`is_root<class_BTTask_method_is_root>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`BTTask<class_BTTask>` | :ref:`next_sibling<class_BTTask_method_next_sibling>` **(** **)** |const| |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`print_tree<class_BTTask_method_print_tree>` **(** int initial_tabs=0 **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove_child<class_BTTask_method_remove_child>` **(** :ref:`BTTask<class_BTTask>` task **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove_child_at_index<class_BTTask_method_remove_child_at_index>` **(** int idx **)** |
+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
@ -368,18 +366,6 @@ Duplicates the task and its children, copying the exported members. Sub-resource
----
.. _class_BTTask_method_editor_get_behavior_tree:
.. rst-class:: classref-method
:ref:`BehaviorTree<class_BehaviorTree>` **editor_get_behavior_tree** **(** **)**
Returns the behavior tree that owns this task. This is only available in the editor.
.. rst-class:: classref-item-separator
----
.. _class_BTTask_method_execute:
.. rst-class:: classref-method

View File

@ -79,12 +79,6 @@
Duplicates the task and its children, copying the exported members. Sub-resources are shared for efficiency, except for [BBParam] subtypes, which are always copied. Used by the editor to instantiate [BehaviorTree] and copy-paste tasks.
</description>
</method>
<method name="editor_get_behavior_tree">
<return type="BehaviorTree" />
<description>
Returns the behavior tree that owns this task. This is only available in the editor.
</description>
</method>
<method name="execute">
<return type="int" enum="BT.Status" />
<param index="0" name="delta" type="float" />

View File

@ -11,7 +11,6 @@
<method name="create_blackboard">
<return type="Blackboard" />
<param index="0" name="node" type="Node" />
<param index="1" name="parent_scope" type="Blackboard" />
<description>
Constructs a new instance of a [Blackboard] using this plan. If [NodePath] prefetching is enabled, [param node] will be used to retrieve node instances for [NodePath] variables and substitute their values.
</description>
@ -22,12 +21,6 @@
Returns the base plan. See [method is_derived].
</description>
</method>
<method name="get_parent_scope_plan_provider" qualifiers="const">
<return type="Callable" />
<description>
Returns the parent scope plan provider - a callable that returns a [BlackboardPlan].
</description>
</method>
<method name="is_derived" qualifiers="const">
<return type="bool" />
<description>
@ -51,13 +44,6 @@
Use with caution, as it will remove variables not present in the base plan. Only use this for custom tooling.
</description>
</method>
<method name="set_parent_scope_plan_provider">
<return type="void" />
<param index="0" name="callable" type="Callable" />
<description>
Sets the parent scope plan provider - a callable that returns a [BlackboardPlan]. Used to provide hints in the inspector. When set, mapping feature becomes available.
</description>
</method>
<method name="sync_with_base_plan">
<return type="void" />
<description>

View File

@ -55,9 +55,6 @@ void BlackboardPlanEditor::_add_var() {
}
BBVariable var(default_type, default_hint, default_hint_string);
if (default_value.get_type() == default_type) {
var.set_value(default_value);
}
plan->add_var(var_name, var);
reset_defaults();
_refresh();
@ -131,12 +128,11 @@ void BlackboardPlanEditor::edit_plan(const Ref<BlackboardPlan> &p_plan) {
_refresh();
}
void BlackboardPlanEditor::set_defaults(const StringName &p_var_name, Variant::Type p_type, PropertyHint p_hint, String p_hint_string, Variant p_value) {
void BlackboardPlanEditor::set_defaults(const StringName &p_var_name, Variant::Type p_type, PropertyHint p_hint, String p_hint_string) {
default_var_name = p_var_name;
default_type = p_type;
default_hint = p_hint;
default_hint_string = p_hint_string;
default_value = p_value;
}
void BlackboardPlanEditor::reset_defaults() {

View File

@ -62,7 +62,6 @@ private:
Variant::Type default_type = Variant::NIL;
PropertyHint default_hint = PROPERTY_HINT_NONE;
String default_hint_string;
Variant default_value;
VBoxContainer *rows_vbox;
Button *add_var_tool;
@ -103,7 +102,7 @@ public:
_FORCE_INLINE_ static BlackboardPlanEditor *get_singleton() { return singleton; }
void edit_plan(const Ref<BlackboardPlan> &p_plan);
void set_defaults(const StringName &p_name, Variant::Type p_type = Variant::FLOAT, PropertyHint p_hint = PROPERTY_HINT_NONE, String p_hint_string = "", Variant p_value = Variant());
void set_defaults(const StringName &p_name, Variant::Type p_type = Variant::FLOAT, PropertyHint p_hint = PROPERTY_HINT_NONE, String p_hint_string = "");
void reset_defaults();
BlackboardPlanEditor();

View File

@ -105,8 +105,7 @@ void EditorPropertyVariableName::_update_status() {
void EditorPropertyVariableName::_status_pressed() {
ERR_FAIL_NULL(plan);
if (!plan->has_var(name_edit->get_text())) {
BlackboardPlanEditor::get_singleton()->set_defaults(name_edit->get_text(),
expected_type, default_hint, default_hint_string, default_value);
BlackboardPlanEditor::get_singleton()->set_defaults(name_edit->get_text(), expected_type, expected_hint, expected_hint_string);
}
BlackboardPlanEditor::get_singleton()->edit_plan(plan);
BlackboardPlanEditor::get_singleton()->popup_centered();
@ -139,13 +138,12 @@ void EditorPropertyVariableName::_update_property() {
_update_status();
}
void EditorPropertyVariableName::setup(const Ref<BlackboardPlan> &p_plan, bool p_allow_empty, Variant::Type p_type, PropertyHint p_hint, String p_hint_string, Variant p_default_value) {
void EditorPropertyVariableName::setup(const Ref<BlackboardPlan> &p_plan, bool p_allow_empty, Variant::Type p_type, PropertyHint p_hint, String p_hint_string) {
plan = p_plan;
allow_empty = p_allow_empty;
expected_type = p_type;
default_hint = p_hint;
default_hint_string = p_hint_string;
default_value = p_default_value;
expected_hint = p_hint;
expected_hint_string = p_hint_string;
_update_status();
}
@ -240,9 +238,8 @@ bool EditorInspectorPluginVariableName::_parse_property(Object *p_object, const
Ref<BlackboardPlan> plan;
Variant::Type expected_type = Variant::NIL;
PropertyHint default_hint = PROPERTY_HINT_NONE;
String default_hint_string;
Variant default_value;
PropertyHint expected_hint = PROPERTY_HINT_NONE;
String expected_hint_string;
if (is_mapping) {
plan.reference_ptr(Object::cast_to<BlackboardPlan>(p_object));
ERR_FAIL_NULL_V(plan, false);
@ -250,9 +247,8 @@ bool EditorInspectorPluginVariableName::_parse_property(Object *p_object, const
if (plan->has_var(var_name)) {
BBVariable variable = plan->get_var(var_name);
expected_type = variable.get_type();
default_hint = variable.get_hint();
default_hint_string = variable.get_hint_string();
default_value = variable.get_value();
expected_hint = variable.get_hint();
expected_hint_string = variable.get_hint_string();
}
if (plan->get_parent_scope_plan_provider().is_valid()) {
Ref<BlackboardPlan> parent_plan = plan->get_parent_scope_plan_provider().call();
@ -262,11 +258,11 @@ bool EditorInspectorPluginVariableName::_parse_property(Object *p_object, const
}
ERR_FAIL_NULL_V(plan, false);
} else {
plan = editor_plan_provider.call();
plan = plan_getter.call();
}
EditorPropertyVariableName *ed = memnew(EditorPropertyVariableName);
ed->setup(plan, is_mapping, expected_type, default_hint, default_hint_string, default_value);
ed->setup(plan, is_mapping, expected_type, expected_hint, expected_hint_string);
add_property_editor(p_path, ed, expected_type);
return true;

View File

@ -46,9 +46,8 @@ private:
bool allow_empty = false;
Variant::Type expected_type = Variant::NIL;
PropertyHint default_hint = PROPERTY_HINT_NONE;
String default_hint_string;
Variant default_value;
PropertyHint expected_hint = PROPERTY_HINT_NONE;
String expected_hint_string;
LineEdit *name_edit;
Button *drop_btn;
@ -77,7 +76,7 @@ public:
virtual void _update_property() override;
#endif
void setup(const Ref<BlackboardPlan> &p_plan, bool p_allow_empty, Variant::Type p_type = Variant::FLOAT, PropertyHint p_hint = PROPERTY_HINT_NONE, String p_hint_string = "", Variant p_default_value = Variant());
void setup(const Ref<BlackboardPlan> &p_plan, bool p_allow_empty, Variant::Type p_type = Variant::FLOAT, PropertyHint p_hint = PROPERTY_HINT_NONE, String p_hint_string = "");
EditorPropertyVariableName();
};
@ -85,7 +84,7 @@ class EditorInspectorPluginVariableName : public EditorInspectorPlugin {
GDCLASS(EditorInspectorPluginVariableName, EditorInspectorPlugin);
private:
Callable editor_plan_provider;
Callable plan_getter;
protected:
static void _bind_methods() {}
@ -99,7 +98,7 @@ public:
virtual bool _parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
#endif
void set_editor_plan_provider(const Callable &p_getter) { editor_plan_provider = p_getter; }
void set_plan_getter(const Callable &p_getter) { plan_getter = p_getter; }
EditorInspectorPluginVariableName() = default;
};

View File

@ -1486,7 +1486,7 @@ void LimboAIEditorPlugin::_notification(int p_notification) {
add_debugger_plugin(memnew(LimboDebuggerPlugin));
add_inspector_plugin(memnew(EditorInspectorPluginBBPlan));
EditorInspectorPluginVariableName *var_plugin = memnew(EditorInspectorPluginVariableName);
var_plugin->set_editor_plan_provider(Callable(limbo_ai_editor, "get_edited_blackboard_plan"));
var_plugin->set_plan_getter(Callable(limbo_ai_editor, "get_edited_blackboard_plan"));
add_inspector_plugin(var_plugin);
#ifdef LIMBOAI_MODULE
// ! Only used in the module version.