DayZ 1.24
Loading...
Searching...
No Matches
PPERequesterBank.c
Go to the documentation of this file.
1
5{
7 private static bool m_Initialized = false;
8
9 static int m_lastID = -1;
10
11 static const int INVALID = -1;
44
45 private static ref PPERequesterRegistrations m_Registrations; //more registrations to be placed here
46
47 static void Init()
48 {
50
51 if (!m_Instances)
53
54 m_Initialized = true;
55 }
56
57 static void Cleanup()
58 {
59 if (m_Initialized)
60 {
61 delete m_Registrations;
62 m_Instances.Clear();
63 }
64 }
65
72 static PPERequesterBase GetRequester(typename type)
73 {
74 if (!type)
75 {
76 Error("Requested type is NULL!");
77 return null;
78 }
79
82 for (int i = 0; i < m_Instances.Count(); i++)
83 {
84 temp = m_Instances.GetElement(i);
85 if (temp.Type() == type)
86 {
88 break;
89 }
90 }
91
92 if (!ret)
93 Debug.Log("'" + type.ToString() + "' not found in bank! Register first in 'RegisterRequester' method.");
94 return ret;
95 }
96
104 {
106
107 if (!ret)
108 Debug.Log("Requester idx '" + index + "' not found in bank! Register first in 'RegisterRequester' method.");
109 return ret;
110 }
111
118 static int GetRequesterID(typename type)
119 {
120 int ret = -1;
122
123 for (int i = 0; i < m_Instances.Count(); i++)
124 {
125 temp = m_Instances.GetElement(i);
126 if (temp.Type() == type)
127 ret = m_Instances.GetKey(i);
128 }
129
130 if (ret == -1)
131 Debug.Log("Requester instance of the '" + type.ToString() + "' type not found in bank! Register first in 'RegisterRequester' method.");
132 return ret;
133 }
134
140 static typename GetRequesterTypename(int index)
141 {
142 typename ret;
144 if (!temp)
145 Debug.Log("No requester exists under idx '" + index + "' in bank! Register first in 'RegisterRequester' method.");
146 else
147 ret = temp.Type();
148
149 return ret;
150 }
151
156 static int RegisterRequester(typename type)
157 {
158 if (!m_Instances)
160
161 if (GetRequester(type) != null)
162 {
163 //Error("Trying to register an already existing requester type: " + type);
164 Debug.Log("Trying to register an already existing requester type: " + type);
165 return -1;
166 }
167
168 m_lastID++;
169
171 req = PPERequesterBase.Cast(type.Spawn());
172 req.SetRequesterIDX(m_lastID);
174
175 return m_lastID;
176 }
177
180 {
181 if (!m_Initialized) //initial registrations are fair game
182 return true;
183
185 for (int i = 0; i < m_Instances.Count(); i++)
186 {
187 temp = m_Instances.GetElement(i);
188 if (temp == req)
189 return true;
190 }
191
192 //Error("Requester instance " + req + " not valid! Please use registered instances from PPERequesterBank.");
193 Debug.Log("Requester instance '" + req + "' not valid! Please use registered instances from PPERequesterBank.");
194 return false;
195 }
196
197 /*static void DumpInstances()
198 {
199 Print("DumpInstances");
200 for (int i = 0; i < m_Instances.Count(); i++)
201 {
202 Print(m_Instances.GetKey(i));
203 Print(m_Instances.GetElement(i));
204 }
205 }*/
206}
207
210{
213 //PPERequesterBank.RegisterRequester(TestReq);
214 }
216
217/*modded class PPERequesterRegistrations extends Managed
219 void PPERequesterRegistrations()
221 PPERequesterBank.RegisterRequester(TestReq2);
223 }*/
static const int REQ_HEALTHHITEFFECTS
static ref map< int, ref PPERequesterBase > m_Instances
static const int REQ_GLASSESTACTICAL
static const int REQ_CONTROLLERDISCONNECT
static const int REQ_GLASSESSPORTBLACK
static const int REQ_INTROCHROMABB
static const int REQ_CONTROLLERBLUR
static const int REQ_GLASSESDESIGNER
class PPERequesterBank extends Managed PPERequesterRegistrations()
Mod this, if you wish to register custom requesters.
static const int REQ_BURLAPSACK
static const int REQ_INVENTORYBLUR
static const int REQ_CONTAMINATEDAREA
static const int REQ_GLASSESAVIATOR
static const int REQ_MOTOHELMETBLACK
static int m_lastID
static const int REQ_GLASSESSPORTORANGE
static const int REQ_CAMERANV
static const int REQ_SHOCKHITEFFECTS
static const int REQ_FEVEREFFECTS
static int RegisterRequester(typename type)
Registers new requester type.
static const int REQ_DROWNING
static const int REQ_TUTORIALEFFECTS
static ref PPERequesterRegistrations m_Registrations
static const int REQ_DEATHEFFECTS
static const int REQ_UNCONEFFECTS
static const int REQ_TUNELVISSION
static const int REQ_BLOODLOSS
static const int REQ_GLASSESWELDING
static const int REQ_PAINBLUR
static const int REQ_FLASHBANGEFFECTS
static const int REQ_CAMERAADS
static const int REQ_MENUEFFECTS
static const int REQ_UNDERGROUND
static const int REQ_GLASSESSPORTBLUE
static const int REQ_SERVERBROWSEREFFECTS
static const int REQ_GLASSESSPORTGREEN
static const int REQ_SPOOKYAREA
bool m_Initialized
PPERUndergroundAcco GetRequester()
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
TODO doc.
Definition EnScript.c:118
static void Init()
static GetRequesterTypename(int index)
Returns a typename from a requester ID.
static ref PPERequesterRegistrations m_Registrations
static PPERequesterBase GetRequester(int index)
Returns an instance (singleton) of a requester based on index.
static int GetRequesterID(typename type)
Returns an ID of a requester type.
static ref map< int, ref PPERequesterBase > m_Instances
static void Cleanup()
static PPERequesterBase GetRequester(typename type)
Returns an instance (singleton) of a requester based on typename.
static int RegisterRequester(typename type)
Registers new requester type.
static bool VerifyRequester(PPERequesterBase req)
Verifies the instance.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
@ INVALID
Invalid file.
Definition EnSystem.c:510