DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
BleedingSourcesManagerBase.c
См. документацию.
2{
6 static ref map<int, int> m_BleedingSourcesZonesMaskByLocation = new map<int, int>;//for each inventory location, keep a bitmask where a bit is set to 1 for each bleeding source zone that belongs to that location
7 static ref set<int> m_BleedingSourcesLocationsList = new set<int>;
8 ItemBase m_Item;//item used to remove the bleeding source
10 //ref map<string, int> m_FireGeomToBit = new map<string, int>;
12 protected int m_Bit;
13 int m_BitOffset = 0;
14
16 {
17 m_Player = player;
18 Init();
19 }
20
21 protected void Init()
22 {
23 //dmgZone_head
25 //dmgZone_torso
26 RegisterBleedingZoneEx("Neck", PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL,"", "-130 70 0" , "0.02 -0.05 0.05", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_HIGH, "BleedingSourceEffect",InventorySlots.HEADGEAR);
32 //dmgZone_leftArm
37 //dmgZone_rightArm
42 //dmgZone_leftHand
43 RegisterBleedingZoneEx("LeftForeArmRoll",PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 90 0" , "0.1 0 0", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.GLOVES);
44 //dmgZone_rightHand
45 RegisterBleedingZoneEx("RightForeArmRoll",PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 90 0" , "-0.1 0 0", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.GLOVES);
46 //dmgZone_leftLeg
51 //dmgZone_rightLeg
56 //dmgZone_leftFoot
57 RegisterBleedingZoneEx("LeftFoot",PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 180 0" , "0 0 0.035", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.LEGS);
59 //dmgZone_rightFoot
60 RegisterBleedingZoneEx("RightFoot",PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 0 0" , "0 0 -0.035", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.LEGS);
62 }
63
64 protected void SetItem(ItemBase item)
65 {
66 m_Item = item;
67 }
68
69
74
75
76 //for inventory location, get the active bits
78 {
79 if (m_BleedingSourcesByLocation.Contains(inv_location))
80 {
81 return m_BleedingSourcesByLocation.Get(inv_location);
82 }
83
84 return 0;
85 }
86
87 //for inventory location, get the active bits
89 {
90 if (m_BleedingSourcesZonesMaskByLocation.Contains(inv_location))
91 {
92 return (~m_BleedingSourcesZonesMaskByLocation.Get(inv_location) & GetBleedingSourceBitsByInvLocation(inv_location)) | (m_BleedingSourcesZonesMaskByLocation.Get(inv_location) & ~GetBleedingSourceBitsByInvLocation(inv_location));//xor
93 }
94
95 return 0;
96 }
97
99 {
100 name.ToLower();
101 int bit = GetBitFromSelectionName(name);
102
103 return m_Player.GetBleedingBits() & bit;
104 }
105
106
107 protected int GetBitFromSelectionID(int id)
108 {
110 m_Player.GetActionComponentNameList(id, CachedObjectsArrays.ARRAY_STRING, "fire");
111
112 for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
113 {
114 /*
115 string name = CachedObjectsArrays.ARRAY_STRING.Get(i);
116 PrintString(name);
117 */
119 if ( bit !=0 )
120 {
121 return bit;
122 }
123 }
124 return 0;
125 }
126
128 {
130 }
131
133 {
134 return m_BitOffset;
135 }
136
137 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)
138 {
140 {
141 Error("Too many bleeding sources, max is "+BIT_INT_SIZE.ToString());
142 }
143 else
144 {
145 name.ToLower();
146 //PrintString(name);
147 //int bit = Math.Pow(2, m_BitOffset);
148 m_Bit = 1 << m_BitOffset;
149 //PrintString(bit.ToString());
150 string bone_name = bone;
151
152 if (bone_name == "")
153 {
154 bone_name = name;
155 }
156
157 m_BleedingSourceZone.Insert(name, new BleedingSourceZone(name, m_Bit, offset, orientation, bone_name, max_time, flow_modifier, particle_name));
158 m_BleedingSourceZone.Get(name).SetInvLocation(inv_location);
159 m_BitToFireGeom.Insert(m_Bit, name);
160 m_BleedingSourcesZonesMaskByLocation.Set( inv_location, m_BleedingSourcesZonesMaskByLocation.Get(inv_location) | m_Bit);//set a bit to 1 to already existing bitmask for that location
161 m_BleedingSourcesLocationsList.Insert(inv_location);
162 m_BitOffset++;
163 }
164 }
165 protected void RegisterBleedingZone(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")
166 {
167 RegisterBleedingZoneEx(name, max_time, bone, orientation, offset, flow_modifier, particle_name);
168 }
169
171 {
172 //int count = m_BleedingSources.Count();
173 while (m_BleedingSources.Count() > 0 )
174 {
175 int bit = m_BleedingSources.GetKey(0);
177 }
178 }
179
180 protected int GetBitFromSelectionName(string name)
181 {
182 if (!m_BleedingSourceZone.Get(name))
183 {
184 return 0;
185 }
186 return m_BleedingSourceZone.Get(name).GetBit();
187 }
188
189 protected string GetSelectionNameFromBit(int bit)
190 {
191 return m_BitToFireGeom.Get(bit);
192 }
193
195 {
197
198 if ( bit == 0 )
199 {
200 return false;
201 }
202
203 if ( CanAddBleedingSource(bit) )
204 {
206 return true;
207 }
208 return false;
209 }
210
211 bool AttemptAddBleedingSourceBySelection(string selection_name)
212 {
213 selection_name.ToLower();
214 int bit = GetBitFromSelectionName(selection_name);
215
216 if ( bit == 0 )
217 {
218 return false;
219 }
220
221 if ( CanAddBleedingSource(bit) )
222 {
224 return true;
225 }
226 return false;
227 }
228
229
231 {
232 if(CanAddBleedingSource(bit))
233 {
234 AddBleedingSourceEx(bit, type, context);
235 return true;
236 }
237 return false;
238 }
239
240
241 protected bool CanAddBleedingSource(int bit)
242 {
243 if (!GetBleedingSourceMeta(bit))
244 {
245 return false;
246 }
247 if ((m_Player.GetBleedingBits() & bit) == 0)
248 {
249 return true;
250 }
251 return false;
252 }
253
254 protected void AddBleedingSourceEx(int bit, eBleedingSourceType type = eBleedingSourceType.NORMAL, int context = 0)
255 {
257 m_BleedingSources.Get(bit).SetType(type);
258 }
259
260 protected void AddBleedingSource(int bit)
261 {
263 vector orientation = bsz.GetOrientation();
264 vector offset = bsz.GetOffset();
265 string bone_name = bsz.GetBoneName();
266 float flow_modifier = bsz.GetFlowModifier();
267 int max_time = bsz.GetMaxTime();
268 string particle_name = bsz.GetParticleName();
269 int inventory_loc = bsz.GetInvLocation();
270 m_BleedingSourcesByLocation.Set(inventory_loc, (m_BleedingSourcesByLocation.Get(inventory_loc) | bit));
271 m_BleedingSources.Insert(bit, new BleedingSource(m_Player, bit,bone_name, orientation, offset, max_time, flow_modifier, particle_name) );
272 }
273
275 {
276 int time = -1;
277 if (m_BleedingSources.Contains(bit))
278 {
279 time = m_BleedingSources.Get(bit).GetActiveTime();
280 }
281 return time;
282 }
283
284 void SetBleedingSourceActiveTime(int bit, int time)
285 {
286 if (m_BleedingSources.Contains(bit))
287 {
288 m_BleedingSources.Get(bit).SetActiveTime(time);
289 }
290 }
291
293 {
294 if (m_BleedingSources.Contains(bit))
295 {
296 m_BleedingSources.Get(bit).SetType(type);
297 }
298 }
300 {
301 if (m_BleedingSources.Contains(bit))
302 {
303 return m_BleedingSources.Get(bit).GetType();
304 }
305 return -1;
306 }
307
308 protected bool RemoveBleedingSource(int bit)
309 {
310 if (m_BleedingSources.Contains(bit))
311 {
313 int inventory_loc = bsz.GetInvLocation();
314 m_BleedingSourcesByLocation.Set(inventory_loc, (m_BleedingSourcesByLocation.Get(inventory_loc) & ~bit));//deactivate the bit
315 m_BleedingSources.Remove(bit);
316 return true;
317 }
318 return false;
319 }
320
322 {
323 return m_BleedingSources.Count();
324 }
325
326 /*void ChangeBleedingIndicatorVisibility(bool visible)
327 {
328 int count = m_BleedingSources.Count();
329 for (int i = 0; i < count; i++)
330 {
331 m_BleedingSources.GetElement(i).ToggleSourceBleedingIndication(visible);
332 }
333 }*/
334}
void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset, int max_time, float flow_modifier, string particle_name)
Определения BleedingSource.c:27
eBleedingSourceType
Определения BleedingSource.c:2
const int BIT_INT_SIZE
Определения BitArray.c:4
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
vector GetOrientation()
Определения BleedingSourceZone.c:66
string GetBoneName()
Определения BleedingSourceZone.c:76
string GetParticleName()
Определения BleedingSourceZone.c:51
int GetInvLocation()
Определения BleedingSourceZone.c:31
vector GetOffset()
Определения BleedingSourceZone.c:71
int GetMaxTime()
Определения BleedingSourceZone.c:46
float GetFlowModifier()
Определения BleedingSourceZone.c:61
bool IsBleedingSourceActive(string name)
Определения BleedingSourcesManagerBase.c:98
int GetBleedingSourceBitsByInvLocation(int inv_location)
Определения BleedingSourcesManagerBase.c:77
int GetBleedingSourceActiveTime(int bit)
Определения BleedingSourcesManagerBase.c:274
void AddBleedingSourceEx(int bit, eBleedingSourceType type=eBleedingSourceType.NORMAL, int context=0)
Определения BleedingSourcesManagerBase.c:254
void RegisterBleedingZone(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")
Определения BleedingSourcesManagerBase.c:165
void SetItem(ItemBase item)
Определения BleedingSourcesManagerBase.c:64
static ref map< int, int > m_BleedingSourcesZonesMaskByLocation
Определения BleedingSourcesManagerBase.c:6
bool AttemptAddBleedingSourceDirectly(int bit, eBleedingSourceType type=eBleedingSourceType.NORMAL, int context=0)
Определения BleedingSourcesManagerBase.c:230
int GetFreeBleedingSourceBitsByInvLocation(int inv_location)
Определения BleedingSourcesManagerBase.c:88
void AddBleedingSource(int bit)
Определения BleedingSourcesManagerBase.c:260
bool AttemptAddBleedingSource(int component)
Определения BleedingSourcesManagerBase.c:194
eBleedingSourceType GetBleedingSourceType(int bit)
Определения BleedingSourcesManagerBase.c:299
BleedingSourceZone GetBleedingSourceMeta(int bit)
Определения BleedingSourcesManagerBase.c:127
string GetSelectionNameFromBit(int bit)
Определения BleedingSourcesManagerBase.c:189
ref map< int, ref BleedingSource > m_BleedingSources
Определения BleedingSourcesManagerBase.c:3
void SetBleedingSourceActiveTime(int bit, int time)
Определения BleedingSourcesManagerBase.c:284
int GetBitFromSelectionName(string name)
Определения BleedingSourcesManagerBase.c:180
ref map< int, int > m_BleedingSourcesByLocation
Определения BleedingSourcesManagerBase.c:5
static ref set< int > m_BleedingSourcesLocationsList
Определения BleedingSourcesManagerBase.c:7
bool AttemptAddBleedingSourceBySelection(string selection_name)
Определения BleedingSourcesManagerBase.c:211
int GetBitFromSelectionID(int id)
Определения BleedingSourcesManagerBase.c:107
void BleedingSourcesManagerBase(PlayerBase player)
Определения BleedingSourcesManagerBase.c:15
bool RemoveBleedingSource(int bit)
Определения BleedingSourcesManagerBase.c:308
bool CanAddBleedingSource(int bit)
Определения BleedingSourcesManagerBase.c:241
ref map< int, string > m_BitToFireGeom
Определения BleedingSourcesManagerBase.c:11
set< int > GetBleedingSourcesLocations()
Определения BleedingSourcesManagerBase.c:70
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)
Определения BleedingSourcesManagerBase.c:137
ref map< string, ref BleedingSourceZone > m_BleedingSourceZone
Определения BleedingSourcesManagerBase.c:4
void SetBleedingSourceType(int bit, eBleedingSourceType type)
Определения BleedingSourcesManagerBase.c:292
static ref TStringArray ARRAY_STRING
Определения UtilityClasses.c:49
provides access to slot configuration
Определения InventorySlots.c:6
Определения InventoryItem.c:731
Определения PlayerBaseClient.c:2
static const float BLEEDING_SOURCE_FLOW_MODIFIER_LOW
Определения PlayerConstants.c:173
static const float BLEEDING_SOURCE_FLOW_MODIFIER_HIGH
Определения PlayerConstants.c:174
static const float BLEEDING_SOURCE_FLOW_MODIFIER_MEDIUM
Определения PlayerConstants.c:172
static const int BLEEDING_SOURCE_DURATION_NORMAL
Определения PlayerConstants.c:175
Определения PlayerConstants.c:2
Определения EnConvert.c:106
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
proto int ToLower()
Changes string to lowercase. Returns length.