‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
behavior_tree_utility.gsc
Go to the documentation of this file.
1 #insert scripts\shared\ai\systems\behavior_tree.gsh;
2 
3 #namespace BehaviorTreeNetwork;
4 
5 // ------------- BehaviorTreeScript ----------- //
6 function ‪RegisterBehaviorTreeScriptAPIInternal( functionName, functionPtr )
7 {
8  if ( !IsDefined( level._BehaviorTreeScriptFunctions ) )
9  {
10  level._BehaviorTreeScriptFunctions = [];
11  }
12 
13  // SUMEET TODO - remove the need of ToLower and have the functionNames defined in .gsh
14  functionName = ToLower( functionName );
15 
16  Assert( IsDefined( functionName ) && IsDefined( functionPtr ), "BT - (RegisterBehaviorTreeScriptAPI) No functionPtr defined or no functionName defined for BehaviorTreeScript." );
17  Assert( !IsDefined( level._BehaviorTreeScriptFunctions[functionName] ), "BT - (RegisterBehaviorTreeScriptAPI) functionName is already defined for BehaviorTreeScript." );
18 
19  level._BehaviorTreeScriptFunctions[functionName] = functionPtr;
20 }
21 
22 // ------------- BehaviorTreeAction ----------- //
23 function ‪RegisterBehaviorTreeActionInternal( actionName, startFuncPtr, updateFuncPtr, terminateFuncPtr )
24 {
25  if ( !IsDefined( level._BehaviorTreeActions ) )
26  {
27  level._BehaviorTreeActions = [];
28  }
29 
30  actionName = ToLower( actionName );
31 
32  Assert( IsString( actionName ), "BT - actionName for RegisterBehaviorTreeActionInternal is not a string." );
33  Assert( !IsDefined(level._BehaviorTreeActions[actionName]), "BT - (RegisterBehaviorTreeActionInternal) actionName " + actionName + " is already registered." );
34 
35  level._BehaviorTreeActions[actionName] = ‪array();
36 
37  // BHTN_ACTION_START
38  if( IsDefined( startFuncPtr ) )
39  {
40  Assert( IsFunctionPtr( startFuncPtr ), "BT - BehaviorTreeAction startFuncPtr must be of type functionPtr." );
41  level._BehaviorTreeActions[actionName][‪BHTN_ACTION_START] = startFuncPtr;
42  }
43 
44  // BHTN_ACTION_UPDATE
45  if( IsDefined( updateFuncPtr ) )
46  {
47  Assert( IsFunctionPtr( updateFuncPtr ), "BT - BehaviorTreeAction updateFuncPtr must be of type functionPtr." );
48  level._BehaviorTreeActions[actionName][‪BHTN_ACTION_UPDATE] = updateFuncPtr;
49  }
50 
51  // BHTN_ACTION_TERMINATE
52  if( IsDefined( terminateFuncPtr ) )
53  {
54  Assert( IsFunctionPtr( terminateFuncPtr ), "BT - BehaviorTreeAction terminateFuncPtr must be of type functionPtr." );
55  level._BehaviorTreeActions[actionName][‪BHTN_ACTION_TERMINATE] = terminateFuncPtr;
56  }
57 }
58 
59 // ------------- utility----------- //
60 #namespace BehaviorTreeNetworkUtility;
61 
62 function ‪RegisterBehaviorTreeScriptAPI( functionName, functionPtr )
63 {
65 }
66 
67 function ‪RegisterBehaviorTreeAction( actionName, startFuncPtr, updateFuncPtr, terminateFuncPtr )
68 {
69  ‪BehaviorTreeNetwork::RegisterBehaviorTreeActionInternal( actionName, startFuncPtr, updateFuncPtr, terminateFuncPtr );
70 }
71 
‪RegisterBehaviorTreeAction
‪function RegisterBehaviorTreeAction(actionName, startFuncPtr, updateFuncPtr, terminateFuncPtr)
Definition: behavior_tree_utility.gsc:67
‪BHTN_ACTION_TERMINATE
‪#define BHTN_ACTION_TERMINATE
Definition: behavior_tree.gsh:15
‪RegisterBehaviorTreeScriptAPIInternal
‪function RegisterBehaviorTreeScriptAPIInternal(functionName, functionPtr)
Definition: behavior_tree_utility.gsc:6
‪BHTN_ACTION_START
‪#define BHTN_ACTION_START
Definition: behavior_tree.gsh:13
‪RegisterBehaviorTreeActionInternal
‪function RegisterBehaviorTreeActionInternal(actionName, startFuncPtr, updateFuncPtr, terminateFuncPtr)
Definition: behavior_tree_utility.gsc:23
‪array
‪function filter array
Definition: array_shared.csc:16
‪RegisterBehaviorTreeScriptAPI
‪function RegisterBehaviorTreeScriptAPI(functionName, functionPtr)
Definition: behavior_tree_utility.gsc:62
‪BHTN_ACTION_UPDATE
‪#define BHTN_ACTION_UPDATE
Definition: behavior_tree.gsh:14