Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pperequesterbank.c
Go to the documentation of this file.
1 
4 class PPERequesterBank extends Managed
5 {
6  private static ref map<int,ref PPERequesterBase> m_Instances;
7  private static bool m_Initialized = false;
8 
9  static int m_lastID = -1;
10 
11  static const int INVALID = -1;
12  static const int REQ_INVENTORYBLUR = RegisterRequester(PPERequester_InventoryBlur);
13  static const int REQ_CONTROLLERDISCONNECT = RegisterRequester(PPERequester_ControllerDisconnectBlur);
14  static const int REQ_GLASSESSPORTBLACK = RegisterRequester(PPERequester_GlassesSportBlack);
15  static const int REQ_GLASSESSPORTBLUE = RegisterRequester(PPERequester_GlassesSportBlue);
16  static const int REQ_GLASSESSPORTGREEN = RegisterRequester(PPERequester_GlassesSportGreen);
17  static const int REQ_GLASSESSPORTORANGE = RegisterRequester(PPERequester_GlassesSportOrange);
18  static const int REQ_GLASSESAVIATOR = RegisterRequester(PPERequester_GlassesAviator);
19  static const int REQ_GLASSESDESIGNER = RegisterRequester(PPERequester_GlassesDesignerBlack);
20  static const int REQ_GLASSESTACTICAL = RegisterRequester(PPERequester_TacticalGoggles);
21  static const int REQ_MOTOHELMETBLACK = RegisterRequester(PPERequester_MotoHelmetBlack);
22  static const int REQ_GLASSESWELDING = RegisterRequester(PPERequester_WeldingMask);
23  static const int REQ_CAMERANV = RegisterRequester(PPERequester_CameraNV);
24  static const int REQ_CAMERAADS = RegisterRequester(PPERequester_CameraADS);
25  static const int REQ_BLOODLOSS = RegisterRequester(PPERequester_BloodLoss);
26  static const int REQ_DEATHEFFECTS = RegisterRequester(PPERequester_DeathDarkening);
27  static const int REQ_UNCONEFFECTS = RegisterRequester(PPERequester_UnconEffects);
28  static const int REQ_TUNELVISSION = RegisterRequester(PPERequester_TunnelVisionEffects);
29  static const int REQ_BURLAPSACK = RegisterRequester(PPERequester_BurlapSackEffects);
30  static const int REQ_INTROCHROMABB = RegisterRequester(PPERequester_IntroChromAbb);
31  static const int REQ_FEVEREFFECTS = RegisterRequester(PPERequester_FeverEffects);
32  static const int REQ_FLASHBANGEFFECTS = RegisterRequester(PPERequester_FlashbangEffects);
33  static const int REQ_SHOCKHITEFFECTS = RegisterRequester(PPERequester_ShockHitReaction);
34  static const int REQ_HEALTHHITEFFECTS = RegisterRequester(PPERequester_HealthHitReaction);
35  static const int REQ_MENUEFFECTS = RegisterRequester(PPERequester_MenuEffects);
36  static const int REQ_CONTROLLERBLUR = RegisterRequester(PPERequester_ControlsBlur);
37  static const int REQ_SERVERBROWSEREFFECTS = RegisterRequester(PPERequester_ServerBrowserBlur);
38  static const int REQ_TUTORIALEFFECTS = RegisterRequester(PPERequester_TutorialMenu);
39  static const int REQ_CONTAMINATEDAREA = RegisterRequester(PPERequester_ContaminatedAreaTint);
40  static const int REQ_SPOOKYAREA = RegisterRequester(PPERequester_SpookyAreaTint);
41  static const int REQ_PAINBLUR = RegisterRequester(PPERequester_PainBlur);
42  static const int REQ_UNDERGROUND = RegisterRequester(PPERUndergroundAcco);
43  static const int REQ_DROWNING = RegisterRequester(PPERequester_Drowning);
44 
45  private static ref PPERequesterRegistrations m_Registrations; //more registrations to be placed here
46 
47  static void Init()
48  {
49  m_Registrations = new PPERequesterRegistrations;
50 
51  if (!m_Instances)
52  m_Instances = new map<int,ref PPERequesterBase>;
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 
80  PPERequesterBase temp;
81  PPERequesterBase ret;
82  for (int i = 0; i < m_Instances.Count(); i++)
83  {
84  temp = m_Instances.GetElement(i);
85  if (temp.Type() == type)
86  {
87  Class.CastTo(ret,temp);
88  break;
89  }
90  }
91 
92  if (!ret)
93  {
94  Debug.Log("'" + type.ToString() + "' not found in bank! Register first in 'RegisterRequester' method.");
95  }
96  return ret;
97  }
98 
105  static PPERequesterBase GetRequester(int index)
106  {
107  PPERequesterBase ret = m_Instances.Get(index);
108 
109  if (!ret)
110  {
111  Debug.Log("Requester idx '" + index + "' not found in bank! Register first in 'RegisterRequester' method.");
112  }
113  return ret;
114  }
115 
122  static int GetRequesterID(typename type)
123  {
124  int ret = -1;
125  PPERequesterBase temp;
126 
127  for (int i = 0; i < m_Instances.Count(); i++)
128  {
129  temp = m_Instances.GetElement(i);
130  if (temp.Type() == type)
131  {
132  ret = m_Instances.GetKey(i);
133  }
134  }
135 
136  if ( ret == -1 )
137  {
138  Debug.Log("Requester instance of the '" + type.ToString() + "' type not found in bank! Register first in 'RegisterRequester' method.");
139  }
140  return ret;
141  }
142 
148  static typename GetRequesterTypename(int index)
149  {
150  typename ret;
151  PPERequesterBase temp = m_Instances.Get(index);
152  if ( !temp )
153  {
154  Debug.Log("No requester exists under idx '" + index + "' in bank! Register first in 'RegisterRequester' method.");
155  }
156  else
157  {
158  ret = temp.Type();
159  }
160 
161  return ret;
162  }
163 
168  static int RegisterRequester(typename type)
169  {
170  if (!m_Instances)
171  m_Instances = new map<int,ref PPERequesterBase>;
172 
173  if ( GetRequester(type) != null )
174  {
175  //Error("Trying to register an already existing requester type: " + type);
176  Debug.Log("Trying to register an already existing requester type: " + type);
177  return -1;
178  }
179 
180  m_lastID++;
181 
182  PPERequesterBase req;
183  req = PPERequesterBase.Cast(type.Spawn());
184  req.SetRequesterIDX(m_lastID);
185  m_Instances.Set(m_lastID,req);
186 
187  return m_lastID;
188  }
189 
191  static bool VerifyRequester(PPERequesterBase req)
192  {
193  if (!m_Initialized) //initial registrations are fair game
194  {
195  return true;
196  }
197 
198  PPERequesterBase temp;
199  for (int i = 0; i < m_Instances.Count(); i++)
200  {
201  temp = m_Instances.GetElement(i);
202  if (temp == req)
203  {
204  return true;
205  }
206  }
207 
208  //Error("Requester instance " + req + " not valid! Please use registered instances from PPERequesterBank.");
209  Debug.Log("Requester instance '" + req + "' not valid! Please use registered instances from PPERequesterBank.");
210  return false;
211  }
212 
213  /*static void DumpInstances()
214  {
215  Print("DumpInstances");
216  for (int i = 0; i < m_Instances.Count(); i++)
217  {
218  Print(m_Instances.GetKey(i));
219  Print(m_Instances.GetElement(i));
220  }
221  }*/
222 }
223 
226 {
228  {
229  //PPERequesterBank.RegisterRequester(TestReq);
230  }
231 }
232 
233 /*modded class PPERequesterRegistrations extends Managed
234 {
235  void PPERequesterRegistrations()
236  {
237  PPERequesterBank.RegisterRequester(TestReq2);
238  }
239 }*/
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
Managed
TODO doc.
Definition: enscript.c:117
INVALID
@ INVALID
Invalid file.
Definition: ensystem.c:510
map
map
Definition: controlsxboxnew.c:3
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
PPERequesterBase
Definition: pperequestplatformsbase.c:2
Cleanup
void Cleanup()
Definition: ppemanager.c:70
Debug
Definition: debug.c:13
PPERequesterRegistrations
class PPERequesterBank extends Managed PPERequesterRegistrations()
Mod this, if you wish to register custom requesters.
Definition: pperequesterbank.c:227
m_Initialized
protected bool m_Initialized
Definition: uihintpanel.c:23
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
GetRequester
protected PPERUndergroundAcco GetRequester()
Definition: undergroundhandlerclient.c:54