forked from 2121578/gai-ca2
Started to introduce RUNNING concept
parent
9d9f29dbcf
commit
db933cd620
|
@ -26,4 +26,4 @@ func populate_blackboard():
|
|||
|
||||
func game_tick() -> void:
|
||||
populate_blackboard()
|
||||
behavior_tree.run(blackboard)
|
||||
behavior_tree.internal_run(blackboard)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue