Dayz Explorer 1.29.162510
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 (g_Game.GetMission().GetEffectWidgets()/* && m_Player.IsControlledPlayer()*/)
16 {
18 g_Game.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 GameplayEffectWidgets_base widgets = g_Game.GetMission().GetEffectWidgets();
27 if (widgets/* && m_Player.IsControlledPlayer()*/)
28 {
29 Param3<bool,int,float> par = new Param3<bool,int,float>(false,m_Bit,flow_modifier);
30 widgets.RegisterGameplayEffectData(EffectWidgetsTypes.BLEEDING_LAYER,par);
31 }
32 }
33
34 void OnVariablesSynchronized(int current_bits)
35 {
36 if (current_bits != m_BleedingBits)
37 {
38 if (m_BleedingBits == 0)
39 {
40 m_Player.OnBleedingBegin();
41 }
42 OnBleedingBitsUpdate(m_BleedingBits, current_bits);
43 m_BleedingBits = current_bits;
44 if (m_BleedingBits == 0)
45 {
46 m_Player.OnBleedingEnd();
47 }
48 }
49 }
50
51 void Reload()
52 {
53 m_BleedingSourceZone.Clear();
54 m_BitOffset = 0;
55 Init();
56 int bit_offset = 0;
57
58 for (int i = 0; i < BIT_INT_SIZE; ++i)
59 {
60 int bit = 1 << bit_offset;
61 bit_offset++;
62 if ((bit & m_BleedingBits) != 0)
63 {
66 }
67 }
68 }
69
70
71 override protected void AddBleedingSource(int bit)
72 {
73 super.AddBleedingSource(bit);
74 #ifdef DIAG_DEVELOPER
75 m_BleedingSources.Get(bit).m_DiagTimeStart = g_Game.GetTickTime();
76 #endif
77 if (g_Game.IsMultiplayer())
78 m_Player.OnBleedingSourceAdded();
79 }
80
81 override protected bool RemoveBleedingSource(int bit)
82 {
83 if (super.RemoveBleedingSource(bit))
84 {
85 if (g_Game.IsMultiplayer())
86 m_Player.OnBleedingSourceRemovedEx(m_Item);
87 return true;
88 }
89 return false;
90 }
91
92 void OnBleedingBitsUpdate(int old_mask, int new_mask)
93 {
94 for (int i = 0; i < 32; ++i)
95 {
96 int compare_bit = 1 << i;
97 int new_compare_result_bit = compare_bit & new_mask;
98 int old_compare_result_bit = compare_bit & old_mask;
99
100 if (new_compare_result_bit)
101 {
102 if (!(new_compare_result_bit & old_mask))
103 {
104 //a different active bit in the new mask
105 AddBleedingSource(new_compare_result_bit);
106 }
107 }
108 else
109 {
110 if (new_compare_result_bit != old_compare_result_bit)
111 {
112 RemoveBleedingSource(old_compare_result_bit);
113 }
114 }
115 }
116 }
117
119 {
120 int bleeding_source_count = 0;
121 int pow = 0;
122
123 for (int i = 0; i < BIT_INT_SIZE ; ++i)
124 {
125 int bit = Math.Pow(2, pow);
126 pow++;
127 if ((m_BleedingBits & bit) != 0)
128 {
129 bleeding_source_count++;
130 }
131 }
132
133 return bleeding_source_count;
134 }
135
136 void SetDiag(bool value)
137 {
138 m_ShowDiag = value;
139 }
140
141 void OnUpdate()
142 {
143 #ifndef NO_GUI
144 if (m_ShowDiag)
145 {
146 DisplayDebug();
148 }
149 else if (m_ShowingDiag || m_ShowingDiagDraw)
150 {
151 if (m_ShowingDiag)
152 CleanDebug();
153 if (m_ShowingDiagDraw)
155 }
156 #endif
157 }
158
160 {
161 m_ShowingDiag = true;
162 DbgUI.BeginCleanupScope();
163 DbgUI.Begin("Bleeding Sources", 50, 50);
164
165 int pow = 0;
166 bool anyBleedingSourceActive = false;
167
168 for (int i = 0; i < BIT_INT_SIZE ; ++i)
169 {
170 int bit = Math.Pow(2, pow);
171 pow++;
172 if ((m_BleedingBits & bit) != 0)
173 {
175 string name = GetSelectionNameFromBit(bit);
176 string slot_name = InventorySlots.GetSlotName(bsz.GetInvLocation());
177 float timeRemaining = -1;
178
179 #ifdef DIAG_DEVELOPER
180 BleedingSource bsi = m_BleedingSources.Get(bit);
181 timeRemaining = bsz.GetMaxTime() + bsi.m_DiagTimeStart - g_Game.GetTickTime();
182 timeRemaining = Math.Round(timeRemaining);
183 #endif
184
185 DbgUI.Text(string.Format("zone: %1 | closest inv. slot: %2 | time remaining: %3", name, slot_name, timeRemaining.ToString()));
186 anyBleedingSourceActive = true;
187 }
188 }
189
190 if (!anyBleedingSourceActive)
191 {
192 DbgUI.Text("No bleeding sources are active.");
193 }
194 else
195 {
196 DbgUI.Text("");
197 DbgUI.Text("Note: BleedingSourcesManagerServer only updates active sources every 3s, displayed times are client estimates.");
198 }
199
200 DbgUI.End();
201 DbgUI.EndCleanupScope();
202 }
203
205 {
206 m_ShowingDiag = false;
207
208 DbgUI.BeginCleanupScope();
209 DbgUI.Begin("Bleeding Sources", 50, 50);
210 DbgUI.End();
211 DbgUI.EndCleanupScope();
212 }
213
215 {
216 /*
217 if (m_Point)
218 {
219 Debug.RemoveShape(m_Point);
220 }
221
222 int boneIdx = m_Player.GetBoneIndexByName("LeftKneeExtra");
223 int pointIdx = m_Player.GetMemoryPointIndex("lknee");
224
225 vector posLS = DayZPlayerUtils.GetMemoryPointPositionBoneRelative(m_Player, boneIdx, pointIdx);
226
227 vector pTm[4];
228 m_Player.GetBoneTransformMS(boneIdx, pTm);
229 vector posMS = posLS.Multiply4(pTm);
230
231 vector pos = m_Player.ModelToWorld(posMS);
232 m_Point = Debug.DrawSphere(pos, 0.1, COLOR_RED);
233 */
234
235 m_ShowingDiagDraw = true;
236
237 int bsCount = m_BleedingSources.Count();
238 for (int i = 0; i < bsCount; ++i)
239 {
240 m_BleedingSources.GetElement(i).DrawDebugShape();
241 }
242 }
243
245 {
246 m_ShowingDiagDraw = false;
247
248 int bsCount = m_BleedingSources.Count();
249 for (int i = 0; i < bsCount; ++i)
250 {
251 m_BleedingSources.GetElement(i).RemoveDebugShape();
252 }
253 }
254}
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
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
grouped gameplay effect widgets and their handling
override void RegisterGameplayEffectData(int id, Param p)
provides access to slot configuration
Definition enmath.c:7
DayZGame g_Game
Definition dayzgame.c:3942
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead