Skip to content

Commit f94f692

Browse files
authored
Move docstrings above class annotations for better Godot editor integration (#410)
Move all the docstrings up to the top of the file so that the Add Node Window picks them up and shows them. This gives you a nice little preview and explaination of what each node does in the Editor before you add it to your scene tree.
1 parent 99acec1 commit f94f692

28 files changed

+72
-94
lines changed

addons/beehave/nodes/beehave_node.gd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
@tool
2-
class_name BeehaveNode extends Node
3-
41
## A node in the behavior tree. Every node must return `SUCCESS`, `FAILURE` or
52
## `RUNNING` when ticked.
3+
@tool
4+
class_name BeehaveNode extends Node
65

76
enum { SUCCESS, FAILURE, RUNNING }
87

addons/beehave/nodes/beehave_tree.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
## Controls the flow of execution of the entire behavior tree.
12
@tool
23
@icon("../icons/tree.svg")
34
class_name BeehaveTree extends Node
45

5-
## Controls the flow of execution of the entire behavior tree.
6-
76
enum { SUCCESS, FAILURE, RUNNING }
87

98
enum ProcessThread { IDLE, PHYSICS, MANUAL }

addons/beehave/nodes/composites/composite.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
## A Composite node controls the flow of execution of its children in a specific manner.
12
@tool
23
@icon("../../icons/category_composite.svg")
34
class_name Composite extends BeehaveNode
45

5-
## A Composite node controls the flow of execution of its children in a specific manner.
66

77
var running_child: BeehaveNode = null
88

@@ -30,7 +30,7 @@ func after_run(actor: Node, blackboard: Blackboard) -> void:
3030

3131

3232
func get_class_name() -> Array[StringName]:
33-
var classes := super()
33+
var classes := super ()
3434
classes.push_back(&"Composite")
3535
return classes
3636

addons/beehave/nodes/composites/randomized_composite.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Base class for composite nodes that execute their children in randomized order.
2+
## Provides functionality for shuffling children with optional weight-based distribution.
3+
## When weights are enabled, children with higher weights have a higher chance of being
4+
## selected first in the random ordering.
15
@tool
26
class_name RandomizedComposite extends Composite
37

addons/beehave/nodes/composites/selector.gd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
## A Selector runs its children in order until one succeeds or is running.
2+
## On failure, skips already-processed children across ticks.
13
@tool
24
@icon("../../icons/selector.svg")
35
class_name SelectorComposite extends Composite
46

57

6-
# A Selector runs its children in order until one succeeds or is running.
7-
# On failure, skips already-processed children across ticks.
8-
9-
108
var last_execution_index: int = 0
119
var previous_success_or_running_index: int = -1
1210
var ready_to_interrupt_all: bool = false

addons/beehave/nodes/composites/selector_random.gd

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
@tool
2-
@icon("../../icons/selector_random.svg")
3-
class_name SelectorRandomComposite extends RandomizedComposite
4-
51
## This node will attempt to execute all of its children just like a
62
## [code]SelectorStar[/code] would, with the exception that the children
73
## will be executed in a random order.
4+
@tool
5+
@icon("../../icons/selector_random.svg")
6+
class_name SelectorRandomComposite extends RandomizedComposite
87

98
## A shuffled list of the children that will be executed in reverse order.
109
var _children_bag: Array[Node] = []

addons/beehave/nodes/composites/selector_reactive.gd

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
@tool
2-
@icon("../../icons/selector_reactive.svg")
3-
class_name SelectorReactiveComposite extends Composite
4-
51
## Selector Reactive nodes will attempt to execute each of its children until one of
62
## them return `SUCCESS`. If all children return `FAILURE`, this node will also
73
## return `FAILURE`.
84
## If a child returns `RUNNING` it will restart.
5+
@tool
6+
@icon("../../icons/selector_reactive.svg")
7+
class_name SelectorReactiveComposite extends Composite
98

109

1110

addons/beehave/nodes/composites/sequence.gd

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
@tool
2-
@icon("../../icons/sequence.svg")
3-
class_name SequenceComposite extends Composite
4-
51
## Sequence nodes will attempt to execute all of its children and report
62
## `SUCCESS` in case all of the children report a `SUCCESS` status code.
73
## If at least one child reports a `FAILURE` status code, this node will also
84
## return `FAILURE` and restart.
95
## In case a child returns `RUNNING` this node will tick again.
6+
@tool
7+
@icon("../../icons/sequence.svg")
8+
class_name SequenceComposite extends Composite
109

1110
var successful_index: int = 0
1211
# Track where we last failed – so we detect a backward jump

addons/beehave/nodes/composites/sequence_random.gd

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
@tool
2-
@icon("../../icons/sequence_random.svg")
3-
class_name SequenceRandomComposite extends RandomizedComposite
4-
51
## This node will attempt to execute all of its children just like a
62
## [code]SequenceStar[/code] would, with the exception that the children
73
## will be executed in a random order.
4+
@tool
5+
@icon("../../icons/sequence_random.svg")
6+
class_name SequenceRandomComposite extends RandomizedComposite
87

98
# Emitted whenever the children are shuffled.
109
signal reset(new_order: Array[Node])

addons/beehave/nodes/composites/sequence_reactive.gd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
@tool
2-
@icon("../../icons/sequence_reactive.svg")
3-
class_name SequenceReactiveComposite extends Composite
4-
51
## Reactive Sequence nodes will attempt to execute all of its children and report
62
## `SUCCESS` in case all of the children report a `SUCCESS` status code.
73
## If at least one child reports a `FAILURE` status code, this node will also
84
## return `FAILURE` and restart.
95
## In case a child returns `RUNNING` this node will restart.
6+
@tool
7+
@icon("../../icons/sequence_reactive.svg")
8+
class_name SequenceReactiveComposite extends Composite
9+
1010

1111
# Track where we last failed – so we detect a backward jump
1212
var previous_failure_index: int = -1
@@ -67,7 +67,7 @@ func interrupt(actor: Node, blackboard: Blackboard) -> void:
6767
running_child.interrupt(actor, blackboard)
6868
_cleanup_running(running_child, actor, blackboard)
6969
_reset()
70-
super(actor, blackboard)
70+
super (actor, blackboard)
7171

7272

7373
func _reset() -> void:
@@ -76,6 +76,6 @@ func _reset() -> void:
7676

7777

7878
func get_class_name() -> Array[StringName]:
79-
var classes := super()
79+
var classes := super ()
8080
classes.push_back(&"SequenceReactiveComposite")
8181
return classes

0 commit comments

Comments
 (0)