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:
|
func game_tick() -> void:
|
||||||
populate_blackboard()
|
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
|
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:
|
func run(p_blackboard: Dictionary) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,7 @@ extends Task
|
||||||
|
|
||||||
func run(blackboard: Dictionary) -> void:
|
func run(blackboard: Dictionary) -> void:
|
||||||
for c in self.get_children():
|
for c in self.get_children():
|
||||||
if status == RUNNING and not c.status == RUNNING:
|
c.internal_run(blackboard)
|
||||||
continue
|
|
||||||
c.run(blackboard)
|
|
||||||
if c.status != FAILURE:
|
if c.status != FAILURE:
|
||||||
status = c.status
|
status = c.status
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,7 @@ extends Task
|
||||||
|
|
||||||
func run(blackboard: Dictionary) -> void:
|
func run(blackboard: Dictionary) -> void:
|
||||||
for c in self.get_children():
|
for c in self.get_children():
|
||||||
if status == RUNNING and not c.status == RUNNING:
|
c.internal_run(blackboard)
|
||||||
continue
|
|
||||||
c.run(blackboard)
|
|
||||||
if c.status != SUCCESS:
|
if c.status != SUCCESS:
|
||||||
status = c.status
|
status = c.status
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue