behavior3行为树
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

19 lines
473 B

-module(priority).
-include("eBhv3.hrl").
-export([tick/2]).
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(#{children := Children} = _BTNode, BTState) ->
tick_1(Children, BTState).
tick_1([ChildID | T], BTState) ->
case base_node:execute(ChildID, BTState) of
{?BT_FAILURE, BTState1} ->
tick_1(T, BTState1);
{BTStatus, BTState1} ->
{BTStatus, BTState1}
end;
tick_1([], BTState) ->
{?BT_FAILURE, BTState}.