DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ InventoryReservation()

override bool FirearmActionAttachMagazineQuick::InventoryReservation ( ActionData action_data)
inlineprivate

См. определение в файле FirearmActionAttachMagazine.c строка 338

339 {
340 if( (IsLocal() || !UseAcknowledgment()) && IsInstant() )
341 return true;
342
343 bool success = true;
344 InventoryLocation oldMagTargetInventoryLocation = NULL;
345 InventoryLocation targetInventoryLocation = NULL;
346 InventoryLocation handInventoryLocation = NULL;
347
348 PlayerBase player = action_data.m_Player;
349 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
350
351 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
352 int muzzle_index = wpn.GetCurrentMuzzle();
353
354 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
355
356 if (am_action_data.m_oldMagazine)
357 {
358 oldMagTargetInventoryLocation = new InventoryLocation;
359 if ( action_data.m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
360 {
361 success = false;
362 }
363 else
364 {
365 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine,GameInventory.c_InventoryReservationTimeoutMS);
366 }
367 }
368
369 if (success)
370 {
371 targetInventoryLocation = new InventoryLocation;
372 targetInventoryLocation.SetAttachment( wpn, new_mag, InventorySlots.MAGAZINE);
373 if ( action_data.m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
374 {
375 success = false;
376 if (am_action_data.m_oldMagazine)
377 {
378 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
379 }
380 }
381 else
382 {
383 action_data.m_Player.GetInventory().AddInventoryReservationEx( new_mag, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
384 }
385 }
386
387 if (success)
388 {
389 handInventoryLocation = new InventoryLocation;
390 handInventoryLocation.SetHands(action_data.m_Player, wpn);
391
392 if ( action_data.m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
393 {
394 if (am_action_data.m_oldMagazine)
395 {
396 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
397 }
398 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
399 success = false;
400 }
401 else
402 {
403 action_data.m_Player.GetInventory().AddInventoryReservationEx( wpn, handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
404 }
405 }
406
407 if ( success )
408 {
409 if (am_action_data.m_ilOldMagazine)
410 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
411
412 if (targetInventoryLocation)
413 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
414
415 if (handInventoryLocation)
416 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
417 }
418
419 return success;
420 }
bool UseAcknowledgment()
Определения ActionBase.c:1162
bool IsInstant()
Определения ActionBase.c:262
bool IsLocal()
Определения ActionBase.c:256
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>

Перекрестные ссылки ActionData, GameInventory::c_InventoryReservationTimeoutMS, ActionBase::IsInstant(), ActionBase::IsLocal(), InventoryLocation::SetAttachment(), InventoryLocation::SetHands() и ActionBase::UseAcknowledgment().

Используется в Start().