Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BTParam.c
Go to the documentation of this file.
1 /*
2 Class for storing variables in key(string)-value pairs.
3 It is meant to be used with BT nodes.
4 */
5 
7 class SCR_BTParamBase : Managed
8 {
9  string m_sPortName;
10 
11  void SetVariableOut(Node node);
12  void GetVariableIn(Node node);
13  string ValueToString();
14 
15  void SCR_BTParamBase(string portName)
16  {
17  m_sPortName = portName;
18  }
19 };
20 
22 class SCR_BTParam<Class T> : SCR_BTParamBase
23 {
24  T m_Value;
25 
26  //----------------------------------------------------------------
27  override void SetVariableOut(Node node)
28  {
29  node.SetVariableOut(m_sPortName, m_Value);
30  }
31 
32  //----------------------------------------------------------------
33  override void GetVariableIn(Node node)
34  {
35  T tempVar;
36  if (node.GetVariableIn(m_sPortName, tempVar))
37  m_Value = tempVar;
38  }
39 
40  //----------------------------------------------------------------
41  void Init(array<SCR_BTParamBase> paramsArray, T value)
42  {
43  paramsArray.Insert(this);
44  m_Value = value;
45  }
46 
47  //----------------------------------------------------------------
49  void Init(SCR_AIActionBase action, T value)
50  {
51  action.m_aParams.Insert(this);
52  m_Value = value;
53  }
54 
55  //----------------------------------------------------------------
56  override string ValueToString()
57  {
58  return m_Value.ToString();
59  }
60 };
61 
62 // Same as SCR_BTParam, but has a strong reference to T
63 class SCR_BTParamRef<Class T> : SCR_BTParamBase
64 {
65  ref T m_Value;
66 
67  //----------------------------------------------------------------
68  override void SetVariableOut(Node node)
69  {
70  node.SetVariableOut(m_sPortName, m_Value);
71  }
72 
73  //----------------------------------------------------------------
74  override void GetVariableIn(Node node)
75  {
76  T tempVar;
77  if (node.GetVariableIn(m_sPortName, tempVar))
78  m_Value = tempVar;
79  }
80 
81  //----------------------------------------------------------------
82  void Init(array<SCR_BTParamBase> paramsArray, T value)
83  {
84  paramsArray.Insert(this);
85  m_Value = value;
86  }
87 
88  //----------------------------------------------------------------
90  void Init(SCR_AIActionBase action, T value)
91  {
92  action.m_aParams.Insert(this);
93  m_Value = value;
94  }
95 
96  //----------------------------------------------------------------
97  override string ValueToString()
98  {
99  return m_Value.ToString();
100  }
101 };
102 
103 
107 class SCR_BTParamAssignable<Class T> : SCR_BTParamBase
108 {
109  T m_Value;
110 
111  // When true, it does SetVariableOut. When false, it does CleaarVariable
112  bool m_AssignedOut;
113 
114  // It is set to true when data is read from node input ports into this object and data at input port is assigned
115  bool m_AssignedIn;
116 
117  //----------------------------------------------------------------
118  override void SetVariableOut(Node node)
119  {
120  if (m_AssignedOut)
121  node.SetVariableOut(m_sPortName, m_Value);
122  else
123  node.ClearVariable(m_sPortName);
124  }
125 
126  //----------------------------------------------------------------
127  override void GetVariableIn(Node node)
128  {
129  T tempVar;
130  m_AssignedIn = node.GetVariableIn(m_sPortName, tempVar);
131  if (m_AssignedIn)
132  m_Value = tempVar;
133  }
134 
135  //----------------------------------------------------------------
136  void Init(array<SCR_BTParamBase> paramsArray, T value, bool assignedOut = true)
137  {
138  paramsArray.Insert(this);
139  m_Value = value;
140  m_AssignedOut = assignedOut;
141  }
142 
143  //----------------------------------------------------------------
145  void Init(SCR_AIActionBase action, T value, bool assignedOut = true)
146  {
147  action.m_aParams.Insert(this);
148  m_Value = value;
149  m_AssignedOut = assignedOut;
150  }
151 
152  //----------------------------------------------------------------
153  override string ValueToString()
154  {
155  return m_Value.ToString();
156  }
157 };
158 
159 
SCR_AIActionBase
Definition: SCR_AIAction.c:1
SCR_BTParamBase
Base BT parameter class to be used in SCR_AIActionParams.
Definition: SCR_BTParam.c:7
Init
void Init(IEntity entity=null, vector worldPos=vector.Zero, float timestamp=0.0, EAITargetInfoCategory category=0)
Definition: SCR_AITargetInfo.c:27
m_Value
class SCR_ScenarioFrameworkParamBase m_Value
Definition: SCR_ScenarioFrameworkActionsGetters.c:20