DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
TimeAccel.c
См. документацию.
1#ifdef DIAG_DEVELOPER
2typedef Param3<bool, float, int> TimeAccelParam;//enabled, timeAccel,category mask
3
4enum 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 DYNAMIC_MUSIC_PLAYER = 0x00000020,
13 //SYSTEM6 = 0x00000040,
14 //SYSTEM6 = 0x00000080,
15}
16
17class 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
32 Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_DYNAMIC_MUSIC_PLAYER, ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER);
33
34 return true;
35 }
36
37 //-------------------------------
38
39 static void Bind(DiagMenuIDs id, ETimeAccelCategories catBit)
40 {
41 m_Mapping.Insert(id, catBit);
42 m_IDs.Insert(id);
43 }
44
45 //-------------------------------
46
47 static int GetCategoryByDiagID(DiagMenuIDs id)
48 {
49 return m_Mapping.Get(id);
50 }
51
52 //-------------------------------
53
54 static int GetDiagIDByCategory(ETimeAccelCategories category)
55 {
56 for (int i = 0; i < m_Mapping.Count();i++)
57 {
58 if (m_Mapping.GetElement(i) == category)
59 {
60 return m_Mapping.GetKey(i);
61 }
62 }
63 return -1;
64 }
65
66 //-------------------------------
67
68 static bool GetFeatureTimeAccelEnabled(ETimeAccelCategories categoryBit)
69 {
70 return (m_CurrentTimeAccel && m_CurrentTimeAccel.param1 && (categoryBit & m_CurrentTimeAccel.param3) != 0);
71 }
72
73 //-------------------------------
74
75 static float GetFeatureTimeAccelValue()
76 {
77 if (m_CurrentTimeAccel)
78 return m_CurrentTimeAccel.param2;
79 else return 1;
80 }
81
82 //-------------------------------
83
84 static void CopyTimeAccelClipboard(bool enable, int timeAccelBig, float timeAccelSmall, int bitMask)
85 {
86 string output = "-timeAccel=";
87 int val = enable;
88 output += val.ToString()+","+timeAccelBig.ToString()+","+timeAccelSmall.ToString()+","+bitMask.ToString();
89 GetGame().CopyToClipboard(output);
90 }
91
92 //-------------------------------
93
94 static int GetTimeAccelBitmask()
95 {
96 int bitmask = 0;
97
98 foreach (int id : m_IDs)
99 {
100 WriteCategoryBit(bitmask, id);
101 }
102
103 return bitmask;
104 }
105
106 //-------------------------------
107
108 static void WriteCategoryBit(out int bitmask, int diagMenuID)
109 {
110 int bit = GetCategoryByDiagID(diagMenuID);
111 if (DiagMenu.GetValue(diagMenuID))
112 {
113 bitmask = bitmask | bit;
114 }
115 }
116
117 //-------------------------------
118
119 static bool AreTimeAccelParamsSame(TimeAccelParam p1, TimeAccelParam p2)
120 {
121 if (!p1 || !p2)
122 return false;
123 if (p1.param1 != p2.param1)
124 return false;
125 if (p1.param2 != p2.param2)
126 return false;
127 if (p1.param3 != p2.param3)
128 return false;
129 return true;
130 }
131
132 //-------------------------------
133
134 static void SendTimeAccel(Man player, TimeAccelParam param)
135 {
136 GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL, param, true, player.GetIdentity());
137 }
138}
139#endif
const string Bind
Определения CentralEconomy.c:9
map
Определения ControlsXboxNew.c:4
override Widget Init()
Определения DayZGame.c:127
DiagMenuIDs
Определения EDiagMenuIDs.c:2
ERPCs
Определения ERPCs.c:2
proto native void CopyToClipboard(string text)
proto native void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
Определения EntityAI.c:95
proto string ToString(bool simple=true)
proto native CGame GetGame()
proto void Insert(int index, string input)
Inserts a string into the n-th index, increasing the string length by the size of the input.