Overview
We could have enter() and exit() methods for when its necessary to do some setup or cleanup before or after the first and last ticks.
The enter() and exit() methods would be called before the first tick() and after the last, respectively.
For more information, checkout #117
Possible implementation
We create an execute() method inside BeehaveNode to be called by parent nodes only. This method will call enter(), tick() and exit() when needed as well as return the result of tick().
func execute(actor: Node, blackboard: Blackboard) -> int:
if not _has_entered:
enter(actor, blackboard)
_has_entered = true
var result = tick(actor, blackboard)
if result != RUNNING:
exit(actor, blackboard)
_has_entered = false
return result
This way, we only need to change composite nodes to call execute() instead of tick(). Composites and leaf nodes should never override the execute() method, only tick().
Overview
We could have
enter()andexit()methods for when its necessary to do some setup or cleanup before or after the first and last ticks.The
enter()andexit()methods would be called before the firsttick()and after the last, respectively.For more information, checkout #117
Possible implementation
We create an
execute()method insideBeehaveNodeto be called by parent nodes only. This method will callenter(),tick()andexit()when needed as well as return the result oftick().This way, we only need to change composite nodes to call
execute()instead oftick(). Composites and leaf nodes should never override theexecute()method, onlytick().