Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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
2 class 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  {
63  RemoveBleedingSource(bit);
64  AddBleedingSource(bit);
65  }
66  }
67  }
68 
69 
70  override protected void AddBleedingSource(int bit)
71  {
72  super.AddBleedingSource(bit);
73  if (GetGame().IsMultiplayer())
74  m_Player.OnBleedingSourceAdded();
75  }
76 
77  override protected bool RemoveBleedingSource(int bit)
78  {
79  if (super.RemoveBleedingSource(bit))
80  {
81  if (GetGame().IsMultiplayer())
82  m_Player.OnBleedingSourceRemovedEx(m_Item);
83  return true;
84  }
85  return false;
86  }
87 
88  void OnBleedingBitsUpdate(int old_mask, int new_mask)
89  {
90  for (int i = 0; i < 32; i++)
91  {
92  int compare_bit = 1 << i;
93  int new_compare_result_bit = compare_bit & new_mask;
94  int old_compare_result_bit = compare_bit & old_mask;
95 
96  if ( new_compare_result_bit )
97  {
98  if ( !(new_compare_result_bit & old_mask))
99  {
100  //a different active bit in the new mask
101  AddBleedingSource(new_compare_result_bit);
102  }
103  }
104  else
105  {
106  if ( new_compare_result_bit != old_compare_result_bit )
107  {
108  RemoveBleedingSource(old_compare_result_bit);
109  }
110  }
111  }
112  }
113 
114  int GetBleedingSourceCountRemote()
115  {
116  int bleeding_source_count = 0;
117  int pow = 0;
118 
119  for (int i = 0; i < BIT_INT_SIZE ; i++)
120  {
121  int bit = Math.Pow(2, pow);
122  pow++;
123  if ( (m_BleedingBits & bit) != 0)
124  {
125  bleeding_source_count++;
126  }
127  }
128 
129  return bleeding_source_count;
130  }
131 
132  void SetDiag(bool value)
133  {
134  m_ShowDiag = value;
135  return;
136 
137  int boneIdx = m_Player.GetBoneIndexByName("RightArmExtra");
138 
139  if ( boneIdx != -1 )
140  {
141  Object linkedObject = GetGame().CreateObject("Ammo_ArrowBolt", "0 0 0");
142 
143  //linkedObject.SetPosition("0 1 0");
144  //linkedObject.SetOrientation("0 90 0");
145  /*
146 
147  Set local space transform for linked object
148 
149  */
150 
152  eff.SetAutodestroy(true);
153  SEffectManager.PlayInWorld( eff, "0 0 0" );
154  Particle p = eff.GetParticle();
155  //p.SetOrientation("0 90 0");
156  m_Player.AddChild(p, boneIdx);
157 
158  m_Player.AddChild(linkedObject, boneIdx);
159  }
160 
161  }
162 
163  void OnUpdate()
164  {
165  #ifndef NO_GUI
166  if (m_ShowDiag)
167  {
168  DisplayDebug();
169  DisplayVisualDebug();
170  }
171  else if ( m_ShowingDiag || m_ShowingDiagDraw )
172  {
173  if (m_ShowingDiag)
174  CleanDebug();
175  if (m_ShowingDiagDraw)
176  CleanVisualDebug();
177  }
178  #endif
179  }
180 
181  void DisplayDebug()
182  {
183  m_ShowingDiag = true;
184 
185  DbgUI.BeginCleanupScope();
186  DbgUI.Begin("Bleeding Sources", 50, 50);
187 
188  int pow = 0;
189 
190  bool anyBleedingSourceActive = false;
191 
192  for (int i = 0; i < BIT_INT_SIZE ; i++)
193  {
194  int bit = Math.Pow(2, pow);
195  pow++;
196  if ( (m_BleedingBits & bit) != 0)
197  {
198  BleedingSourceZone bsz = GetBleedingSourceMeta(bit);
199 
200  string name = GetSelectionNameFromBit(bit);
201  string slot_name = InventorySlots.GetSlotName(bsz.GetInvLocation());
202  DbgUI.Text(name + "| slot name: "+ slot_name);
203  anyBleedingSourceActive = true;
204  }
205  }
206 
207  if (!anyBleedingSourceActive)
208  {
209  DbgUI.Text("Currently no bleeding sources are active.");
210  }
211 
212  DbgUI.End();
213  DbgUI.EndCleanupScope();
214  }
215 
216  void CleanDebug()
217  {
218  m_ShowingDiag = false;
219 
220  DbgUI.BeginCleanupScope();
221  DbgUI.Begin("Bleeding Sources", 50, 50);
222  DbgUI.End();
223  DbgUI.EndCleanupScope();
224  }
225 
226  void DisplayVisualDebug()
227  {
228  /*
229  if(m_Point)
230  {
231  Debug.RemoveShape(m_Point);
232  }
233 
234  int boneIdx = m_Player.GetBoneIndexByName("LeftKneeExtra");
235  int pointIdx = m_Player.GetMemoryPointIndex("lknee");
236 
237  vector posLS = DayZPlayerUtils.GetMemoryPointPositionBoneRelative(m_Player, boneIdx, pointIdx);
238 
239  vector pTm[4];
240  m_Player.GetBoneTransformMS(boneIdx, pTm);
241  vector posMS = posLS.Multiply4(pTm);
242 
243  vector pos = m_Player.ModelToWorld(posMS);
244  m_Point = Debug.DrawSphere(pos, 0.1, COLOR_RED);
245  */
246 
247  m_ShowingDiagDraw = true;
248 
249  int bsCount = m_BleedingSources.Count();
250  for (int i = 0; i < bsCount; ++i)
251  {
252  m_BleedingSources.GetElement(i).DrawDebugShape();
253  }
254  }
255 
256  void CleanVisualDebug()
257  {
258  m_ShowingDiagDraw = false;
259 
260  int bsCount = m_BleedingSources.Count();
261  for (int i = 0; i < bsCount; ++i)
262  {
263  m_BleedingSources.GetElement(i).RemoveDebugShape();
264  }
265  }
266 }
BleedingSourceEffect
Definition: bleedingsource.c:1
GetGame
proto native CGame GetGame()
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
DbgUI
Definition: dbgui.c:59
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
BleedingSourcesManagerBase
Definition: bleedingsourcesmanagerbase.c:1
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
BleedingSourceZone
Definition: bleedingsourcezone.c:1
m_Item
protected EntityAI m_Item
Definition: radialquickbarmenu.c:14
Param3
Definition: entityai.c:95
vector
Definition: enconvert.c:105
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
Object
Definition: objecttyped.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
BleedingSourceEffect
void BleedingSourceEffect()
Definition: bleedingsource.c:2
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
m_Bit
int m_Bit
Definition: bleedingsource.c:12
Math
Definition: enmath.c:6
BIT_INT_SIZE
const int BIT_INT_SIZE
Definition: bitarray.c:4
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead