DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
BleedingSourcesManagerRemote.c
См. документацию.
1//this is instantiated on the client for both the controlled character, as well as the remote characters
2class BleedingSourcesManagerRemote extends BleedingSourcesManagerBase
3{
10
11 override protected void Init()
12 {
13 super.Init();
14
15 if (GetGame().GetMission().GetEffectWidgets()/* && m_Player.IsControlledPlayer()*/)
16 {
18 GetGame().GetMission().GetEffectWidgets().RegisterGameplayEffectData(EffectWidgetsTypes.BLEEDING_LAYER,par);
19 }
20 }
21
22 override protected void RegisterBleedingZoneEx(string name, int max_time, string bone = "", vector orientation = "0 0 0", vector offset = "0 0 0", float flow_modifier = 1, string particle_name = "BleedingSourceEffect", int inv_location = 0)
23 {
24 super.RegisterBleedingZoneEx(name,max_time,bone,orientation,offset,flow_modifier,particle_name,inv_location);
25
26 if (GetGame().GetMission().GetEffectWidgets()/* && m_Player.IsControlledPlayer()*/)
27 {
28 Param3<bool,int,float> par = new Param3<bool,int,float>(false,m_Bit,flow_modifier);
29 GetGame().GetMission().GetEffectWidgets().RegisterGameplayEffectData(EffectWidgetsTypes.BLEEDING_LAYER,par);
30 }
31 }
32
33 void OnVariablesSynchronized(int current_bits)
34 {
35 if (current_bits != m_BleedingBits)
36 {
37 if (m_BleedingBits == 0)
38 {
39 m_Player.OnBleedingBegin();
40 }
42 m_BleedingBits = current_bits;
43 if (m_BleedingBits == 0)
44 {
45 m_Player.OnBleedingEnd();
46 }
47 }
48 }
49
50 void Reload()
51 {
53 m_BitOffset = 0;
54 Init();
55 int bit_offset = 0;
56
57 for (int i = 0; i < BIT_INT_SIZE; ++i)
58 {
59 int bit = 1 << bit_offset;
60 bit_offset++;
61 if ((bit & m_BleedingBits) != 0)
62 {
65 }
66 }
67 }
68
69
70 override protected void AddBleedingSource(int bit)
71 {
72 super.AddBleedingSource(bit);
73 #ifdef DIAG_DEVELOPER
74 m_BleedingSources.Get(bit).m_DiagTimeStart = GetGame().GetTickTime();
75 #endif
76 if (GetGame().IsMultiplayer())
77 m_Player.OnBleedingSourceAdded();
78 }
79
80 override protected bool RemoveBleedingSource(int bit)
81 {
82 if (super.RemoveBleedingSource(bit))
83 {
84 if (GetGame().IsMultiplayer())
85 m_Player.OnBleedingSourceRemovedEx(m_Item);
86 return true;
87 }
88 return false;
89 }
90
91 void OnBleedingBitsUpdate(int old_mask, int new_mask)
92 {
93 for (int i = 0; i < 32; ++i)
94 {
95 int compare_bit = 1 << i;
96 int new_compare_result_bit = compare_bit & new_mask;
97 int old_compare_result_bit = compare_bit & old_mask;
98
99 if (new_compare_result_bit)
100 {
101 if (!(new_compare_result_bit & old_mask))
102 {
103 //a different active bit in the new mask
104 AddBleedingSource(new_compare_result_bit);
105 }
106 }
107 else
108 {
109 if (new_compare_result_bit != old_compare_result_bit)
110 {
111 RemoveBleedingSource(old_compare_result_bit);
112 }
113 }
114 }
115 }
116
118 {
119 int bleeding_source_count = 0;
120 int pow = 0;
121
122 for (int i = 0; i < BIT_INT_SIZE ; ++i)
123 {
124 int bit = Math.Pow(2, pow);
125 pow++;
126 if ((m_BleedingBits & bit) != 0)
127 {
128 bleeding_source_count++;
129 }
130 }
131
132 return bleeding_source_count;
133 }
134
135 void SetDiag(bool value)
136 {
137 m_ShowDiag = value;
138 }
139
140 void OnUpdate()
141 {
142 #ifndef NO_GUI
143 if (m_ShowDiag)
144 {
145 DisplayDebug();
147 }
149 {
150 if (m_ShowingDiag)
151 CleanDebug();
154 }
155 #endif
156 }
157
159 {
160 m_ShowingDiag = true;
162 DbgUI.Begin("Bleeding Sources", 50, 50);
163
164 int pow = 0;
165 bool anyBleedingSourceActive = false;
166
167 for (int i = 0; i < BIT_INT_SIZE ; ++i)
168 {
169 int bit = Math.Pow(2, pow);
170 pow++;
171 if ((m_BleedingBits & bit) != 0)
172 {
174 string name = GetSelectionNameFromBit(bit);
175 string slot_name = InventorySlots.GetSlotName(bsz.GetInvLocation());
176 float timeRemaining = -1;
177
178 #ifdef DIAG_DEVELOPER
179 BleedingSource bsi = m_BleedingSources.Get(bit);
180 timeRemaining = bsz.GetMaxTime() + bsi.m_DiagTimeStart - GetGame().GetTickTime();
181 timeRemaining = Math.Round(timeRemaining);
182 #endif
183
184 DbgUI.Text(string.Format("zone: %1 | closest inv. slot: %2 | time remaining: %3", name, slot_name, timeRemaining.ToString()));
185 anyBleedingSourceActive = true;
186 }
187 }
188
189 if (!anyBleedingSourceActive)
190 {
191 DbgUI.Text("No bleeding sources are active.");
192 }
193 else
194 {
195 DbgUI.Text("");
196 DbgUI.Text("Note: BleedingSourcesManagerServer only updates active sources every 3s, displayed times are client estimates.");
197 }
198
199 DbgUI.End();
201 }
202
204 {
205 m_ShowingDiag = false;
206
208 DbgUI.Begin("Bleeding Sources", 50, 50);
209 DbgUI.End();
211 }
212
214 {
215 /*
216 if (m_Point)
217 {
218 Debug.RemoveShape(m_Point);
219 }
220
221 int boneIdx = m_Player.GetBoneIndexByName("LeftKneeExtra");
222 int pointIdx = m_Player.GetMemoryPointIndex("lknee");
223
224 vector posLS = DayZPlayerUtils.GetMemoryPointPositionBoneRelative(m_Player, boneIdx, pointIdx);
225
226 vector pTm[4];
227 m_Player.GetBoneTransformMS(boneIdx, pTm);
228 vector posMS = posLS.Multiply4(pTm);
229
230 vector pos = m_Player.ModelToWorld(posMS);
231 m_Point = Debug.DrawSphere(pos, 0.1, COLOR_RED);
232 */
233
234 m_ShowingDiagDraw = true;
235
236 int bsCount = m_BleedingSources.Count();
237 for (int i = 0; i < bsCount; ++i)
238 {
239 m_BleedingSources.GetElement(i).DrawDebugShape();
240 }
241 }
242
244 {
245 m_ShowingDiagDraw = false;
246
247 int bsCount = m_BleedingSources.Count();
248 for (int i = 0; i < bsCount; ++i)
249 {
250 m_BleedingSources.GetElement(i).RemoveDebugShape();
251 }
252 }
253}
void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset, int max_time, float flow_modifier, string particle_name)
const int BIT_INT_SIZE
Определения BitArray.c:4
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
int GetInvLocation()
Определения BleedingSourceZone.c:31
int GetMaxTime()
Определения BleedingSourceZone.c:46
void OnVariablesSynchronized(int current_bits)
Определения BleedingSourcesManagerRemote.c:33
void AddBleedingSource(int bit)
Определения BleedingSourcesManagerBase.c:260
BleedingSourceZone GetBleedingSourceMeta(int bit)
Определения BleedingSourcesManagerBase.c:127
string GetSelectionNameFromBit(int bit)
Определения BleedingSourcesManagerBase.c:189
ref map< int, ref BleedingSource > m_BleedingSources
Определения BleedingSourcesManagerBase.c:3
bool RemoveBleedingSource(int bit)
Определения BleedingSourcesManagerBase.c:308
void SetDiag(bool value)
Определения BleedingSourcesManagerRemote.c:135
void RegisterBleedingZoneEx(string name, int max_time, string bone="", vector orientation="0 0 0", vector offset="0 0 0", float flow_modifier=1, string particle_name="BleedingSourceEffect", int inv_location=0)
Определения BleedingSourcesManagerRemote.c:22
ref map< string, ref BleedingSourceZone > m_BleedingSourceZone
Определения BleedingSourcesManagerBase.c:4
void OnBleedingBitsUpdate(int old_mask, int new_mask)
Определения BleedingSourcesManagerRemote.c:91
proto native float GetTickTime()
Returns current time from start of the game.
proto native Mission GetMission()
Определения DbgUI.c:60
override void RegisterGameplayEffectData(int id, Param p)
Определения GameplayEffectWidgets.c:126
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
Определения EnMath.c:7
GameplayEffectWidgets_base GetEffectWidgets()
proto string ToString(bool simple=true)
Определения EnConvert.c:106
proto native CGame GetGame()
static proto native void End()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
static proto void BeginCleanupScope()
static proto native void EndCleanupScope()
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto float Round(float f)
Returns mathematical round of value.
static proto float Pow(float v, float power)
Return power of v ^ power.