mirror of
https://github.com/tonytins/citylimits
synced 2025-06-26 17:54:43 -04:00
Behavior Tree addon
This commit is contained in:
parent
5de5a0c315
commit
5fa863114a
50 changed files with 1762 additions and 3 deletions
33
addons/beehave/nodes/composites/selector_star.gd
Normal file
33
addons/beehave/nodes/composites/selector_star.gd
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Special implementation of a selector that will
|
||||
# "wait" for running nodes and will not re-attempt
|
||||
# to execute previous nodes until that node is either
|
||||
# FAILED or SUCCEEDED
|
||||
extends Composite
|
||||
|
||||
class_name SelectorStarComposite, "../../icons/selector_star.svg"
|
||||
|
||||
|
||||
var last_execution_index = 0
|
||||
|
||||
func tick(actor, blackboard):
|
||||
for c in get_children():
|
||||
if c.get_index() < last_execution_index:
|
||||
continue
|
||||
|
||||
var response = c.tick(actor, blackboard)
|
||||
|
||||
if c is ConditionLeaf:
|
||||
blackboard.set("last_condition", c)
|
||||
blackboard.set("last_condition_status", response)
|
||||
|
||||
if response != FAILURE:
|
||||
if c is ActionLeaf and response == RUNNING:
|
||||
blackboard.set("running_action", c)
|
||||
if response == SUCCESS:
|
||||
last_execution_index = 0
|
||||
return response
|
||||
else:
|
||||
last_execution_index += 1
|
||||
|
||||
last_execution_index = 0
|
||||
return FAILURE
|
Loading…
Add table
Add a link
Reference in a new issue