‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
blackboard.gsc
Go to the documentation of this file.
1 #insert scripts\shared\shared.gsh;
2 
3 #insert scripts\shared\ai\systems\blackboard.gsh;
4 
5 #namespace Blackboard;
6 
7 function ‪RegisterBlackBoardAttribute( entity, attributeName, defaultAttributeValue, getterFunction )
8 {
9  Assert( IsDefined( entity.__blackboard ), "Blackboard - No blackboard has been created for this entity." );
10  Assert( !IsDefined( entity.__blackboard[attributeName] ), "BlackBoard - Attribute " + attributeName + " already registered." );
11 
12  if( IsDefined( getterFunction ) )
13  {
14  // When a blackboard is registered with getterFunction, then every single time its requested, it will
15  // execure getterFunction and return the value.
16  Assert( IsFunctionPtr( getterFunction ) );
17 
18  entity.__blackboard[attributeName] = getterFunction;
19  }
20  else
21  {
22  // If there is no getterFunction, then it will just store the default value
23  if( !IsDefined( defaultAttributeValue ) )
24  {
25  defaultAttributeValue = undefined;
26  }
27 
28  entity.__blackboard[attributeName] = defaultAttributeValue;
29  }
30 }
31 
32 function ‪GetBlackBoardAttribute( entity, attributeName )
33 {
34  if( IsFunctionPtr( entity.__blackboard[attributeName] ) )
35  {
36  getterFunction = entity.__blackboard[attributeName];
37  attributeValue = entity [[getterFunction]]();
38 
39  /#
40  if( IsActor( entity ) )
41  entity updatetrackedblackboardattribute( attributeName );
42  #/
43 
44  return attributeValue;
45  }
46  else
47  {
48  /#
49  if( IsActor( entity ) )
50  entity updatetrackedblackboardattribute( attributeName );
51  #/
52  return entity.__blackboard[attributeName];
53  }
54 }
55 
56 function ‪SetBlackBoardAttribute( entity, attributeName, attributeValue )
57 {
58  if ( IsDefined( entity.__blackboard[attributeName] ) )
59  {
60  if ( !IsDefined( attributeValue ) && IsFunctionPtr( entity.__blackboard[attributeName] ) )
61  {
62  // Attempts to clear attributes with getter functions is meaningless.
63  return;
64  }
65 
66  Assert( !IsFunctionPtr( entity.__blackboard[attributeName] ), "Blackboard - Attribute value can not be set explicitly, as it has a getterFunction." );
67  }
68 
69  entity.__blackboard[attributeName] = attributeValue;
70 
71  /#
72  if ( IsActor( entity ) )
73  entity updatetrackedblackboardattribute( attributeName );
74  #/
75 }
76 
77 function ‪CreateBlackBoardForEntity( entity )
78 {
79  if( !IsDefined( entity.__blackboard ) )
80  {
81  entity.__blackboard = [];
82  }
83 
84  if( !IsDefined( level._setBlackboardAttributeFunc ) )
85  {
86  level._setBlackboardAttributeFunc = &‪SetBlackBoardAttribute;
87  }
88 }
89 
‪SetBlackBoardAttribute
‪function SetBlackBoardAttribute(entity, attributeName, attributeValue)
Definition: blackboard.gsc:56
‪GetBlackBoardAttribute
‪function GetBlackBoardAttribute(entity, attributeName)
Definition: blackboard.gsc:32
‪RegisterBlackBoardAttribute
‪function RegisterBlackBoardAttribute(entity, attributeName, defaultAttributeValue, getterFunction)
Definition: blackboard.gsc:7
‪CreateBlackBoardForEntity
‪function CreateBlackBoardForEntity(entity)
Definition: blackboard.gsc:77