Skip to content

Commit

Permalink
Util: Function to decorate output variable
Browse files Browse the repository at this point in the history
  • Loading branch information
limbonaut committed Feb 10, 2024
1 parent 95c2496 commit 899335d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bt/tasks/utility/bt_call_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ String BTCallMethod::_generate_name() {
method != StringName() ? method : "???",
args_str,
node_param.is_valid() && !node_param->to_string().is_empty() ? node_param->to_string() : "???",
result_var.is_empty() ? "" : LW_NAME(output_var_prefix) + LimboUtility::get_singleton()->decorate_var(result_var));
result_var.is_empty() ? "" : LimboUtility::get_singleton()->decorate_output_var(result_var));
}

BT::Status BTCallMethod::_tick(double p_delta) {
Expand Down
10 changes: 5 additions & 5 deletions doc_classes/BehaviorTreeData.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BehaviorTreeData" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Represents current state of a [BehaviorTree] instance.
Represents current state of a [BehaviorTree] instance.
</brief_description>
<description>
This class is used by the LimboAI debugger for the serialization and deserialization of [BehaviorTree] instance data.
Additionally, it can be used with [BehaviorTreeView] to visualize the current state of a [BehaviorTree] instance. It is meant to be utilized in custom in-game tools.
This class is used by the LimboAI debugger for the serialization and deserialization of [BehaviorTree] instance data.
Additionally, it can be used with [BehaviorTreeView] to visualize the current state of a [BehaviorTree] instance. It is meant to be utilized in custom in-game tools.
</description>
<tutorials>
</tutorials>
Expand All @@ -14,8 +14,8 @@
<return type="BehaviorTreeData" />
<param index="0" name="p_tree_instance" type="BTTask" />
<description>
Returns current state of the [param p_tree_instance] encoded as a [BehaviorTreeData], suitable for use with [BehaviorTreeView].
Behavior tree instance can be acquired with [method BTPlayer.get_tree_instance].
Returns current state of the [param p_tree_instance] encoded as a [BehaviorTreeData], suitable for use with [BehaviorTreeView].
Behavior tree instance can be acquired with [method BTPlayer.get_tree_instance].
</description>
</method>
</methods>
Expand Down
6 changes: 3 additions & 3 deletions doc_classes/BehaviorTreeView.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BehaviorTreeView" inherits="Control" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Visualizes the current state of a [BehaviorTree] instance.
Visualizes the current state of a [BehaviorTree] instance.
</brief_description>
<description>
Visualizes the current state of a [BehaviorTree] instance. See also [BehaviorTreeData].
Visualizes the current state of a [BehaviorTree] instance. See also [BehaviorTreeData].
</description>
<tutorials>
</tutorials>
Expand All @@ -13,7 +13,7 @@
<return type="void" />
<param index="0" name="p_behavior_tree_data" type="BehaviorTreeData" />
<description>
Updates the representation of a [BehaviorTree] instance. See also [BehaviorTreeData].
Updates the representation of a [BehaviorTree] instance. See also [BehaviorTreeData].
</description>
</method>
</methods>
Expand Down
7 changes: 7 additions & 0 deletions doc_classes/LimboUtility.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<tutorials>
</tutorials>
<methods>
<method name="decorate_output_var" qualifiers="const">
<return type="String" />
<param index="0" name="p_variable" type="String" />
<description>
Just like [method decorate_var], produces a string with a [Blackboard] variable name that is formatted for display, and also adds an additional symbol to indicate that the variable is used as an output.
</description>
</method>
<method name="decorate_var" qualifiers="const">
<return type="String" />
<param index="0" name="p_variable" type="String" />
Expand Down
5 changes: 5 additions & 0 deletions util/limbo_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ String LimboUtility::decorate_var(String p_variable) const {
}
}

String LimboUtility::decorate_output_var(String p_variable) const {
return LW_NAME(output_var_prefix) + decorate_var(p_variable);
}

String LimboUtility::get_status_name(int p_status) const {
switch (p_status) {
case BTTask::FRESH:
Expand Down Expand Up @@ -606,6 +610,7 @@ void LimboUtility::open_doc_class(const String &p_class_name) {

void LimboUtility::_bind_methods() {
ClassDB::bind_method(D_METHOD("decorate_var", "p_variable"), &LimboUtility::decorate_var);
ClassDB::bind_method(D_METHOD("decorate_output_var", "p_variable"), &LimboUtility::decorate_output_var);
ClassDB::bind_method(D_METHOD("get_status_name", "p_status"), &LimboUtility::get_status_name);
ClassDB::bind_method(D_METHOD("get_task_icon", "p_class_or_script_path"), &LimboUtility::get_task_icon);

Expand Down
1 change: 1 addition & 0 deletions util/limbo_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class LimboUtility : public Object {
static LimboUtility *get_singleton();

String decorate_var(String p_variable) const;
String decorate_output_var(String p_variable) const;
String get_status_name(int p_status) const;
Ref<Texture2D> get_task_icon(String p_class_or_script_path) const;

Expand Down

0 comments on commit 899335d

Please sign in to comment.