Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
timeaccel.c
Go to the documentation of this file.
1 #ifdef DIAG_DEVELOPER
2 typedef Param3<bool, float, int> TimeAccelParam;//enabled, timeAccel,category mask
3 
4 enum ETimeAccelCategories
5 {
6  //DO NOT FORGET TO INCLUDE IN THE MAPPING 'Init()' FUNCTION
7  UNDERGROUND_ENTRANCE = 0x00000001,
8  UNDERGROUND_RESERVOIR = 0x00000002,
9  ENERGY_CONSUMPTION = 0x00000004,
10  ENERGY_RECHARGE = 0x00000008,
11  FOOD_DECAY = 0x00000010,
12  //SYSTEM5 = 0x00000020,
13  //SYSTEM6 = 0x00000040,
14  //SYSTEM6 = 0x00000080,
15 }
16 
17 class FeatureTimeAccel
18 {
19  static ref TimeAccelParam m_CurrentTimeAccel;// = new TimeAccelParam(false, 0, 0);
20  static ref map<int,int> m_Mapping = new map<int,int>();
21  static ref array<int> m_IDs = new array<int>();
22  static bool m_Initializeded = Init();
23 
24  static bool Init()
25  {
26  Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_UG_ENTRANCES, ETimeAccelCategories.UNDERGROUND_ENTRANCE);
27  Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_UG_RESERVOIR, ETimeAccelCategories.UNDERGROUND_RESERVOIR);
28  Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_ENERGY_CONSUME, ETimeAccelCategories.ENERGY_CONSUMPTION);
29  Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_ENERGY_RECHARGE, ETimeAccelCategories.ENERGY_RECHARGE);
30  Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_FOOD_DECAY, ETimeAccelCategories.FOOD_DECAY);
31  return true;
32  }
33 
34  //-------------------------------
35 
36  static void Bind(DiagMenuIDs id, ETimeAccelCategories catBit)
37  {
38  m_Mapping.Insert(id, catBit);
39  m_IDs.Insert(id);
40  }
41 
42  //-------------------------------
43 
44  static int GetCategoryByDiagID(DiagMenuIDs id)
45  {
46  return m_Mapping.Get(id);
47  }
48 
49  //-------------------------------
50 
51  static int GetDiagIDByCategory(ETimeAccelCategories category)
52  {
53  for (int i = 0; i < m_Mapping.Count();i++)
54  {
55  if (m_Mapping.GetElement(i) == category)
56  {
57  return m_Mapping.GetKey(i);
58  }
59  }
60  return -1;
61  }
62 
63  //-------------------------------
64 
65  static bool GetFeatureTimeAccelEnabled(ETimeAccelCategories categoryBit)
66  {
67  return (m_CurrentTimeAccel && m_CurrentTimeAccel.param1 && (categoryBit & m_CurrentTimeAccel.param3) != 0);
68  }
69 
70  //-------------------------------
71 
72  static float GetFeatureTimeAccelValue()
73  {
74  if (m_CurrentTimeAccel)
75  return m_CurrentTimeAccel.param2;
76  else return 1;
77  }
78 
79  //-------------------------------
80 
81  static void CopyTimeAccelClipboard(bool enable, int timeAccelBig, float timeAccelSmall, int bitMask)
82  {
83  string output = "-timeAccel=";
84  int val = enable;
85  output += val.ToString()+","+timeAccelBig.ToString()+","+timeAccelSmall.ToString()+","+bitMask.ToString();
86  GetGame().CopyToClipboard(output);
87  }
88 
89  //-------------------------------
90 
91  static int GetTimeAccelBitmask()
92  {
93  int bitmask = 0;
94 
95  foreach (int id : m_IDs)
96  {
97  WriteCategoryBit(bitmask, id);
98  }
99 
100  return bitmask;
101  }
102 
103  //-------------------------------
104 
105  static void WriteCategoryBit(out int bitmask, int diagMenuID)
106  {
107  int bit = GetCategoryByDiagID(diagMenuID);
108  if (DiagMenu.GetValue(diagMenuID))
109  {
110  bitmask = bitmask | bit;
111  }
112  }
113 
114  //-------------------------------
115 
116  static bool AreTimeAccelParamsSame(TimeAccelParam p1, TimeAccelParam p2)
117  {
118  if (!p1 || !p2)
119  return false;
120  if (p1.param1 != p2.param1)
121  return false;
122  if (p1.param2 != p2.param2)
123  return false;
124  if (p1.param3 != p2.param3)
125  return false;
126  return true;
127  }
128 
129  //-------------------------------
130 
131  static void SendTimeAccel(Man player, TimeAccelParam param)
132  {
133  GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL, param, true, player.GetIdentity());
134  }
135 }
136 #endif
GetGame
proto native CGame GetGame()
DiagMenu
Definition: endebug.c:232
Param3
Definition: entityai.c:95
DiagMenuIDs
DiagMenuIDs
Definition: ediagmenuids.c:1
map
map
Definition: controlsxboxnew.c:3
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
Bind
const string Bind
Definition: centraleconomy.c:75
ERPCs
ERPCs
Definition: erpcs.c:1