From a35038ef12fd661720e3bb355a61612985d347e2 Mon Sep 17 00:00:00 2001 From: mechPenSketch Date: Thu, 26 Oct 2023 14:13:19 +0800 Subject: [PATCH] Move Class Descriptions Below Class Names (#236) This allows the descriptions to be seen in the editor. --- addons/beehave/blackboard.gd | 5 +++-- addons/beehave/nodes/beehave_node.gd | 5 +++-- addons/beehave/nodes/beehave_tree.gd | 3 ++- addons/beehave/nodes/composites/composite.gd | 2 +- addons/beehave/nodes/composites/selector.gd | 8 ++++---- addons/beehave/nodes/composites/selector_random.gd | 7 ++++--- addons/beehave/nodes/composites/selector_reactive.gd | 7 ++++--- addons/beehave/nodes/composites/sequence.gd | 10 +++++----- addons/beehave/nodes/composites/sequence_random.gd | 7 ++++--- addons/beehave/nodes/composites/sequence_reactive.gd | 8 ++++---- addons/beehave/nodes/composites/sequence_star.gd | 8 ++++---- addons/beehave/nodes/decorators/decorator.gd | 4 ++-- addons/beehave/nodes/decorators/failer.gd | 2 +- addons/beehave/nodes/decorators/inverter.gd | 4 ++-- addons/beehave/nodes/decorators/limiter.gd | 5 +++-- addons/beehave/nodes/decorators/succeeder.gd | 2 +- addons/beehave/nodes/decorators/time_limiter.gd | 7 ++++--- addons/beehave/nodes/leaves/action.gd | 8 ++++---- addons/beehave/nodes/leaves/blackboard_compare.gd | 6 +++--- addons/beehave/nodes/leaves/blackboard_erase.gd | 4 ++-- addons/beehave/nodes/leaves/blackboard_has.gd | 4 ++-- addons/beehave/nodes/leaves/blackboard_set.gd | 4 ++-- addons/beehave/nodes/leaves/condition.gd | 4 ++-- addons/beehave/nodes/leaves/leaf.gd | 2 +- 24 files changed, 67 insertions(+), 59 deletions(-) diff --git a/addons/beehave/blackboard.gd b/addons/beehave/blackboard.gd index 5655e89a..d710da9f 100644 --- a/addons/beehave/blackboard.gd +++ b/addons/beehave/blackboard.gd @@ -1,8 +1,9 @@ -## The blackboard is an object that can be used to store and access data between -## multiple nodes of the behavior tree. @icon("icons/blackboard.svg") class_name Blackboard extends Node +## The blackboard is an object that can be used to store and access data between +## multiple nodes of the behavior tree. + var blackboard: Dictionary = {} func keys() -> Array[String]: diff --git a/addons/beehave/nodes/beehave_node.gd b/addons/beehave/nodes/beehave_node.gd index 0c94b8ce..399efa3f 100644 --- a/addons/beehave/nodes/beehave_node.gd +++ b/addons/beehave/nodes/beehave_node.gd @@ -1,8 +1,9 @@ -## A node in the behavior tree. Every node must return `SUCCESS`, `FAILURE` or -## `RUNNING` when ticked. @tool class_name BeehaveNode extends Node +## A node in the behavior tree. Every node must return `SUCCESS`, `FAILURE` or +## `RUNNING` when ticked. + enum { SUCCESS, FAILURE, diff --git a/addons/beehave/nodes/beehave_tree.gd b/addons/beehave/nodes/beehave_tree.gd index 7a8d145f..d0f5b925 100644 --- a/addons/beehave/nodes/beehave_tree.gd +++ b/addons/beehave/nodes/beehave_tree.gd @@ -1,8 +1,9 @@ -## Controls the flow of execution of the entire behavior tree. @tool @icon("../icons/tree.svg") class_name BeehaveTree extends Node +## Controls the flow of execution of the entire behavior tree. + enum { SUCCESS, FAILURE, diff --git a/addons/beehave/nodes/composites/composite.gd b/addons/beehave/nodes/composites/composite.gd index b959eea1..67e7afa6 100644 --- a/addons/beehave/nodes/composites/composite.gd +++ b/addons/beehave/nodes/composites/composite.gd @@ -1,8 +1,8 @@ -## A Composite node controls the flow of execution of its children in a specific manner. @tool @icon("../../icons/category_composite.svg") class_name Composite extends BeehaveNode +## A Composite node controls the flow of execution of its children in a specific manner. var running_child: BeehaveNode = null diff --git a/addons/beehave/nodes/composites/selector.gd b/addons/beehave/nodes/composites/selector.gd index eca71ac3..618f6020 100644 --- a/addons/beehave/nodes/composites/selector.gd +++ b/addons/beehave/nodes/composites/selector.gd @@ -1,11 +1,11 @@ -## Selector nodes will attempt to execute each of its children until one of -## them return `SUCCESS`. If all children return `FAILURE`, this node will also -## return `FAILURE`. -## If a child returns `RUNNING` it will tick again. @tool @icon("../../icons/selector.svg") class_name SelectorComposite extends Composite +## Selector nodes will attempt to execute each of its children until one of +## them return `SUCCESS`. If all children return `FAILURE`, this node will also +## return `FAILURE`. +## If a child returns `RUNNING` it will tick again. var last_execution_index: int = 0 diff --git a/addons/beehave/nodes/composites/selector_random.gd b/addons/beehave/nodes/composites/selector_random.gd index b780b5f1..a85e83cb 100644 --- a/addons/beehave/nodes/composites/selector_random.gd +++ b/addons/beehave/nodes/composites/selector_random.gd @@ -1,10 +1,11 @@ -## This node will attempt to execute all of its children just like a -## [code]SelectorStar[/code] would, with the exception that the children -## will be executed in a random order. @tool @icon("../../icons/selector_random.svg") class_name SelectorRandomComposite extends RandomizedComposite +## This node will attempt to execute all of its children just like a +## [code]SelectorStar[/code] would, with the exception that the children +## will be executed in a random order. + ## A shuffled list of the children that will be executed in reverse order. var _children_bag: Array[Node] = [] var c: Node diff --git a/addons/beehave/nodes/composites/selector_reactive.gd b/addons/beehave/nodes/composites/selector_reactive.gd index 869ef8a2..b0d5d23d 100644 --- a/addons/beehave/nodes/composites/selector_reactive.gd +++ b/addons/beehave/nodes/composites/selector_reactive.gd @@ -1,10 +1,11 @@ +@tool +@icon("../../icons/selector_reactive.svg") +class_name SelectorReactiveComposite extends Composite + ## Selector Reactive nodes will attempt to execute each of its children until one of ## them return `SUCCESS`. If all children return `FAILURE`, this node will also ## return `FAILURE`. ## If a child returns `RUNNING` it will restart. -@tool -@icon("../../icons/selector_reactive.svg") -class_name SelectorReactiveComposite extends Composite func tick(actor: Node, blackboard: Blackboard) -> int: for c in get_children(): diff --git a/addons/beehave/nodes/composites/sequence.gd b/addons/beehave/nodes/composites/sequence.gd index 11b5d79f..4f0d07a5 100644 --- a/addons/beehave/nodes/composites/sequence.gd +++ b/addons/beehave/nodes/composites/sequence.gd @@ -1,12 +1,12 @@ -## Sequence nodes will attempt to execute all of its children and report -## `SUCCESS` in case all of the children report a `SUCCESS` status code. -## If at least one child reports a `FAILURE` status code, this node will also -## return `FAILURE` and restart. -## In case a child returns `RUNNING` this node will tick again. @tool @icon("../../icons/sequence.svg") class_name SequenceComposite extends Composite +## Sequence nodes will attempt to execute all of its children and report +## `SUCCESS` in case all of the children report a `SUCCESS` status code. +## If at least one child reports a `FAILURE` status code, this node will also +## return `FAILURE` and restart. +## In case a child returns `RUNNING` this node will tick again. var successful_index: int = 0 diff --git a/addons/beehave/nodes/composites/sequence_random.gd b/addons/beehave/nodes/composites/sequence_random.gd index ab8eb789..77928c82 100644 --- a/addons/beehave/nodes/composites/sequence_random.gd +++ b/addons/beehave/nodes/composites/sequence_random.gd @@ -1,10 +1,11 @@ -## This node will attempt to execute all of its children just like a -## [code]SequenceStar[/code] would, with the exception that the children -## will be executed in a random order. @tool @icon("../../icons/sequence_random.svg") class_name SequenceRandomComposite extends RandomizedComposite +## This node will attempt to execute all of its children just like a +## [code]SequenceStar[/code] would, with the exception that the children +## will be executed in a random order. + # Emitted whenever the children are shuffled. signal reset(new_order: Array[Node]) diff --git a/addons/beehave/nodes/composites/sequence_reactive.gd b/addons/beehave/nodes/composites/sequence_reactive.gd index 50e8b90d..ade4b32a 100644 --- a/addons/beehave/nodes/composites/sequence_reactive.gd +++ b/addons/beehave/nodes/composites/sequence_reactive.gd @@ -1,12 +1,12 @@ +@tool +@icon("../../icons/sequence_reactive.svg") +class_name SequenceReactiveComposite extends Composite + ## Reactive Sequence nodes will attempt to execute all of its children and report ## `SUCCESS` in case all of the children report a `SUCCESS` status code. ## If at least one child reports a `FAILURE` status code, this node will also ## return `FAILURE` and restart. ## In case a child returns `RUNNING` this node will restart. -@tool -@icon("../../icons/sequence_reactive.svg") -class_name SequenceReactiveComposite extends Composite - var successful_index: int = 0 diff --git a/addons/beehave/nodes/composites/sequence_star.gd b/addons/beehave/nodes/composites/sequence_star.gd index 42ceb070..d40cffdc 100644 --- a/addons/beehave/nodes/composites/sequence_star.gd +++ b/addons/beehave/nodes/composites/sequence_star.gd @@ -1,12 +1,12 @@ +@tool +@icon("../../icons/sequence_reactive.svg") +class_name SequenceStarComposite extends Composite + ## Sequence Star nodes will attempt to execute all of its children and report ## `SUCCESS` in case all of the children report a `SUCCESS` status code. ## If at least one child reports a `FAILURE` status code, this node will also ## return `FAILURE` and tick again. ## In case a child returns `RUNNING` this node will restart. -@tool -@icon("../../icons/sequence_reactive.svg") -class_name SequenceStarComposite extends Composite - var successful_index: int = 0 diff --git a/addons/beehave/nodes/decorators/decorator.gd b/addons/beehave/nodes/decorators/decorator.gd index 8cc39443..826fd4aa 100644 --- a/addons/beehave/nodes/decorators/decorator.gd +++ b/addons/beehave/nodes/decorators/decorator.gd @@ -1,9 +1,9 @@ -## Decorator nodes are used to transform the result received by its child. -## Must only have one child. @tool @icon("../../icons/category_decorator.svg") class_name Decorator extends BeehaveNode +## Decorator nodes are used to transform the result received by its child. +## Must only have one child. var running_child: BeehaveNode = null diff --git a/addons/beehave/nodes/decorators/failer.gd b/addons/beehave/nodes/decorators/failer.gd index 4a818ede..d5e937c6 100644 --- a/addons/beehave/nodes/decorators/failer.gd +++ b/addons/beehave/nodes/decorators/failer.gd @@ -1,8 +1,8 @@ -## A Failer node will always return a `FAILURE` status code. @tool @icon("../../icons/failer.svg") class_name AlwaysFailDecorator extends Decorator +## A Failer node will always return a `FAILURE` status code. func tick(actor: Node, blackboard: Blackboard) -> int: var c = get_child(0) diff --git a/addons/beehave/nodes/decorators/inverter.gd b/addons/beehave/nodes/decorators/inverter.gd index 16e3f36c..9f2d2389 100644 --- a/addons/beehave/nodes/decorators/inverter.gd +++ b/addons/beehave/nodes/decorators/inverter.gd @@ -1,9 +1,9 @@ -## An inverter will return `FAILURE` in case it's child returns a `SUCCESS` status -## code or `SUCCESS` in case its child returns a `FAILURE` status code. @tool @icon("../../icons/inverter.svg") class_name InverterDecorator extends Decorator +## An inverter will return `FAILURE` in case it's child returns a `SUCCESS` status +## code or `SUCCESS` in case its child returns a `FAILURE` status code. func tick(actor: Node, blackboard: Blackboard) -> int: var c = get_child(0) diff --git a/addons/beehave/nodes/decorators/limiter.gd b/addons/beehave/nodes/decorators/limiter.gd index 72e73565..4b88f2bc 100644 --- a/addons/beehave/nodes/decorators/limiter.gd +++ b/addons/beehave/nodes/decorators/limiter.gd @@ -1,9 +1,10 @@ -## The limiter will execute its child `x` amount of times. When the number of -## maximum ticks is reached, it will return a `FAILURE` status code. @tool @icon("../../icons/limiter.svg") class_name LimiterDecorator extends Decorator +## The limiter will execute its child `x` amount of times. When the number of +## maximum ticks is reached, it will return a `FAILURE` status code. + @onready var cache_key = 'limiter_%s' % self.get_instance_id() @export var max_count : float = 0 diff --git a/addons/beehave/nodes/decorators/succeeder.gd b/addons/beehave/nodes/decorators/succeeder.gd index 9d9664b1..d6601deb 100644 --- a/addons/beehave/nodes/decorators/succeeder.gd +++ b/addons/beehave/nodes/decorators/succeeder.gd @@ -1,8 +1,8 @@ -## A succeeder node will always return a `SUCCESS` status code. @tool @icon("../../icons/succeeder.svg") class_name AlwaysSucceedDecorator extends Decorator +## A succeeder node will always return a `SUCCESS` status code. func tick(actor: Node, blackboard: Blackboard) -> int: var c = get_child(0) diff --git a/addons/beehave/nodes/decorators/time_limiter.gd b/addons/beehave/nodes/decorators/time_limiter.gd index cedb3977..be4bddb3 100644 --- a/addons/beehave/nodes/decorators/time_limiter.gd +++ b/addons/beehave/nodes/decorators/time_limiter.gd @@ -1,10 +1,11 @@ -## The Time Limit Decorator will give its child a set amount of time to finish -## before interrupting it and return a `FAILURE` status code. The timer is reset -## every time before the node runs. @tool @icon("../../icons/limiter.svg") class_name TimeLimiterDecorator extends Decorator +## The Time Limit Decorator will give its child a set amount of time to finish +## before interrupting it and return a `FAILURE` status code. The timer is reset +## every time before the node runs. + @export var wait_time: = 0.0 var time_left: = 0.0 diff --git a/addons/beehave/nodes/leaves/action.gd b/addons/beehave/nodes/leaves/action.gd index 003bdb4e..7b0957dc 100644 --- a/addons/beehave/nodes/leaves/action.gd +++ b/addons/beehave/nodes/leaves/action.gd @@ -1,11 +1,11 @@ -## Actions are leaf nodes that define a task to be performed by an actor. -## Their execution can be long running, potentially being called across multiple -## frame executions. In this case, the node should return `RUNNING` until the -## action is completed. @tool @icon("../../icons/action.svg") class_name ActionLeaf extends Leaf +## Actions are leaf nodes that define a task to be performed by an actor. +## Their execution can be long running, potentially being called across multiple +## frame executions. In this case, the node should return `RUNNING` until the +## action is completed. func get_class_name() -> Array[StringName]: var classes := super() diff --git a/addons/beehave/nodes/leaves/blackboard_compare.gd b/addons/beehave/nodes/leaves/blackboard_compare.gd index 84fb43fa..3b29cd01 100644 --- a/addons/beehave/nodes/leaves/blackboard_compare.gd +++ b/addons/beehave/nodes/leaves/blackboard_compare.gd @@ -1,9 +1,9 @@ -## Compares two values using the specified comparison operator. -## Returns [code]FAILURE[/code] if any of the expression fails or the -## comparison operation returns [code]false[/code], otherwise it returns [code]SUCCESS[/code]. @tool class_name BlackboardCompareCondition extends ConditionLeaf +## Compares two values using the specified comparison operator. +## Returns [code]FAILURE[/code] if any of the expression fails or the +## comparison operation returns [code]false[/code], otherwise it returns [code]SUCCESS[/code]. enum Operators { EQUAL, diff --git a/addons/beehave/nodes/leaves/blackboard_erase.gd b/addons/beehave/nodes/leaves/blackboard_erase.gd index 89508bd9..31e0a194 100644 --- a/addons/beehave/nodes/leaves/blackboard_erase.gd +++ b/addons/beehave/nodes/leaves/blackboard_erase.gd @@ -1,8 +1,8 @@ -## Erases the specified key from the blackboard. -## Returns [code]FAILURE[/code] if expression execution fails, otherwise [code]SUCCESS[/code]. @tool class_name BlackboardEraseAction extends ActionLeaf +## Erases the specified key from the blackboard. +## Returns [code]FAILURE[/code] if expression execution fails, otherwise [code]SUCCESS[/code]. ## Expression representing a blackboard key. @export_placeholder(EXPRESSION_PLACEHOLDER) var key: String = "" diff --git a/addons/beehave/nodes/leaves/blackboard_has.gd b/addons/beehave/nodes/leaves/blackboard_has.gd index 868fddfd..ccd46d25 100644 --- a/addons/beehave/nodes/leaves/blackboard_has.gd +++ b/addons/beehave/nodes/leaves/blackboard_has.gd @@ -1,8 +1,8 @@ -## Returns [code]FAILURE[/code] if expression execution fails or the specified key doesn't exist. -## Returns [code]SUCCESS[/code] if blackboard has the specified key. @tool class_name BlackboardHasCondition extends ConditionLeaf +## Returns [code]FAILURE[/code] if expression execution fails or the specified key doesn't exist. +## Returns [code]SUCCESS[/code] if blackboard has the specified key. ## Expression representing a blackboard key. @export_placeholder(EXPRESSION_PLACEHOLDER) var key: String = "" diff --git a/addons/beehave/nodes/leaves/blackboard_set.gd b/addons/beehave/nodes/leaves/blackboard_set.gd index d0d6455c..144336d0 100644 --- a/addons/beehave/nodes/leaves/blackboard_set.gd +++ b/addons/beehave/nodes/leaves/blackboard_set.gd @@ -1,8 +1,8 @@ -## Sets the specified key to the specified value. -## Returns [code]FAILURE[/code] if expression execution fails, otherwise [code]SUCCESS[/code]. @tool class_name BlackboardSetAction extends ActionLeaf +## Sets the specified key to the specified value. +## Returns [code]FAILURE[/code] if expression execution fails, otherwise [code]SUCCESS[/code]. ## Expression representing a blackboard key. @export_placeholder(EXPRESSION_PLACEHOLDER) var key: String = "" diff --git a/addons/beehave/nodes/leaves/condition.gd b/addons/beehave/nodes/leaves/condition.gd index 55ec6f9c..b3b5c4fe 100644 --- a/addons/beehave/nodes/leaves/condition.gd +++ b/addons/beehave/nodes/leaves/condition.gd @@ -1,9 +1,9 @@ -## Conditions are leaf nodes that either return SUCCESS or FAILURE depending on -## a single simple condition. They should never return `RUNNING`. @tool @icon("../../icons/condition.svg") class_name ConditionLeaf extends Leaf +## Conditions are leaf nodes that either return SUCCESS or FAILURE depending on +## a single simple condition. They should never return `RUNNING`. func get_class_name() -> Array[StringName]: var classes := super() diff --git a/addons/beehave/nodes/leaves/leaf.gd b/addons/beehave/nodes/leaves/leaf.gd index b8c63b85..6f485d72 100644 --- a/addons/beehave/nodes/leaves/leaf.gd +++ b/addons/beehave/nodes/leaves/leaf.gd @@ -1,8 +1,8 @@ -## Base class for all leaf nodes of the tree. @tool @icon("../../icons/category_leaf.svg") class_name Leaf extends BeehaveNode +## Base class for all leaf nodes of the tree. const EXPRESSION_PLACEHOLDER: String = "Insert an expression..."