Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BTParam.c
Go to the documentation of this file.
1/*
2Class for storing variables in key(string)-value pairs.
3It is meant to be used with BT nodes.
4*/
5
7class SCR_BTParamBase : Managed
8{
9 string m_sPortName;
10
11 void SetVariableOut(Node node);
12 void GetVariableIn(Node node);
13
14 void SCR_BTParamBase(string portName)
15 {
16 m_sPortName = portName;
17 }
18};
19
21class SCR_BTParam<Class T> : SCR_BTParamBase
22{
23 T m_Value;
24
25 //----------------------------------------------------------------
26 override void SetVariableOut(Node node)
27 {
28 node.SetVariableOut(m_sPortName, m_Value);
29 }
30
31 //----------------------------------------------------------------
32 override void GetVariableIn(Node node)
33 {
34 T tempVar;
35 if (node.GetVariableIn(m_sPortName, tempVar))
36 m_Value = tempVar;
37 }
38
39 //----------------------------------------------------------------
40 void Init(array<SCR_BTParamBase> paramsArray, T value)
41 {
42 paramsArray.Insert(this);
43 m_Value = value;
44 }
45
46 //----------------------------------------------------------------
48 void Init(SCR_AIActionBase action, T value)
49 {
50 action.m_aParams.Insert(this);
51 m_Value = value;
52 }
53};
54
55// Same as SCR_BTParam, but has a strong reference to T
56class SCR_BTParamRef<Class T> : SCR_BTParamBase
57{
58 ref T m_Value;
59
60 //----------------------------------------------------------------
61 override void SetVariableOut(Node node)
62 {
63 node.SetVariableOut(m_sPortName, m_Value);
64 }
65
66 //----------------------------------------------------------------
67 override void GetVariableIn(Node node)
68 {
69 T tempVar;
70 if (node.GetVariableIn(m_sPortName, tempVar))
71 m_Value = tempVar;
72 }
73
74 //----------------------------------------------------------------
75 void Init(array<SCR_BTParamBase> paramsArray, T value)
76 {
77 paramsArray.Insert(this);
78 m_Value = value;
79 }
80
81 //----------------------------------------------------------------
83 void Init(SCR_AIActionBase action, T value)
84 {
85 action.m_aParams.Insert(this);
86 m_Value = value;
87 }
88};
89
90
94class SCR_BTParamAssignable<Class T> : SCR_BTParamBase
95{
96 T m_Value;
97
98 // When true, it does SetVariableOut. When false, it does CleaarVariable
99 bool m_AssignedOut;
100
101 // It is set to true when data is read from node input ports into this object and data at input port is assigned
102 bool m_AssignedIn;
103
104 //----------------------------------------------------------------
105 override void SetVariableOut(Node node)
106 {
107 if (m_AssignedOut)
108 node.SetVariableOut(m_sPortName, m_Value);
109 else
110 node.ClearVariable(m_sPortName);
111 }
112
113 //----------------------------------------------------------------
114 override void GetVariableIn(Node node)
115 {
116 T tempVar;
117 m_AssignedIn = node.GetVariableIn(m_sPortName, tempVar);
118 if (m_AssignedIn)
119 m_Value = tempVar;
120 }
121
122 //----------------------------------------------------------------
123 void Init(array<SCR_BTParamBase> paramsArray, T value, bool assignedOut = true)
124 {
125 paramsArray.Insert(this);
126 m_Value = value;
127 m_AssignedOut = assignedOut;
128 }
129
130 //----------------------------------------------------------------
132 void Init(SCR_AIActionBase action, T value, bool assignedOut = true)
133 {
134 action.m_aParams.Insert(this);
135 m_Value = value;
136 m_AssignedOut = assignedOut;
137 }
138};
139
140
override void Init()
class SCR_MapHelperT< Class T, Class U > T
Super root of all classes in Enforce script.
Definition Types.c:35
Definition Node.c:13
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
proto void ClearVariable(string name)