Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
bleedingsourcesmanagerremote.c
Go to the documentation of this file.
1//this is instantiated on the client for both the controlled character, as well as the remote characters
2class BleedingSourcesManagerRemote extends BleedingSourcesManagerBase
3{
4 int m_BleedingBits;
5 bool m_ShowDiag;
6 bool m_ShowingDiag;
7 bool m_ShowingDiagDraw;
8 Shape m_Point;
9 bool m_EnableHitIndication = false;
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 }
41 OnBleedingBitsUpdate(m_BleedingBits, current_bits);
42 m_BleedingBits = current_bits;
43 if (m_BleedingBits == 0)
44 {
45 m_Player.OnBleedingEnd();
46 }
47 }
48 }
49
50 void Reload()
51 {
52 m_BleedingSourceZone.Clear();
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 }
148 else if (m_ShowingDiag || m_ShowingDiagDraw)
149 {
150 if (m_ShowingDiag)
151 CleanDebug();
152 if (m_ShowingDiagDraw)
154 }
155 #endif
156 }
157
159 {
160 m_ShowingDiag = true;
161 DbgUI.BeginCleanupScope();
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();
200 DbgUI.EndCleanupScope();
201 }
202
204 {
205 m_ShowingDiag = false;
206
207 DbgUI.BeginCleanupScope();
208 DbgUI.Begin("Bleeding Sources", 50, 50);
209 DbgUI.End();
210 DbgUI.EndCleanupScope();
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)
int m_Bit
ItemBase m_Item
Definition actioninput.c:16
const int BIT_INT_SIZE
Definition bitarray.c:4
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void OnVariablesSynchronized(int current_bits)
BleedingSourceZone GetBleedingSourceMeta(int bit)
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)
void OnBleedingBitsUpdate(int old_mask, int new_mask)
Definition dbgui.c:60
override void RegisterGameplayEffectData(int id, Param p)
provides access to slot configuration
Definition enmath.c:7
proto native CGame GetGame()
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
DayZPlayer m_Player
Definition hand_events.c:42