1
0
Fork 0

Started to introduce RUNNING concept

Yan Wittmann 2025-01-04 16:42:32 +01:00
parent 9d9f29dbcf
commit db933cd620
4 changed files with 18 additions and 7 deletions

View File

@ -26,4 +26,4 @@ func populate_blackboard():
func game_tick() -> void:
populate_blackboard()
behavior_tree.run(blackboard)
behavior_tree.internal_run(blackboard)

View File

@ -5,6 +5,21 @@ enum {FAILURE = -1, SUCCESS = 1, RUNNING = 0}
var status: int = FAILURE
func internal_run(p_blackboard: Dictionary) -> void:
p_blackboard["current_task"] = self
if status == RUNNING:
for c in self.get_children():
if not c.status == RUNNING:
continue
c.internal_run(p_blackboard)
if c.status != SUCCESS:
status = c.status
return
run(p_blackboard)
func run(p_blackboard: Dictionary) -> void:
pass

View File

@ -3,9 +3,7 @@ extends Task
func run(blackboard: Dictionary) -> void:
for c in self.get_children():
if status == RUNNING and not c.status == RUNNING:
continue
c.run(blackboard)
c.internal_run(blackboard)
if c.status != FAILURE:
status = c.status
return

View File

@ -3,9 +3,7 @@ extends Task
func run(blackboard: Dictionary) -> void:
for c in self.get_children():
if status == RUNNING and not c.status == RUNNING:
continue
c.run(blackboard)
c.internal_run(blackboard)
if c.status != SUCCESS:
status = c.status
return