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

◆ InventoryReservation()

override bool FirearmActionAttachMagazineQuick::InventoryReservation ( ActionData action_data)
inlineprivate

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

342 {
343 if (g_Game.IsServer())
344 return true;
345
346 if( (IsLocal() || !UseAcknowledgment()) && IsInstant() )
347 return true;
348
349 bool success = true;
350 InventoryLocation oldMagTargetInventoryLocation = NULL;
351 InventoryLocation targetInventoryLocation = NULL;
352 InventoryLocation handInventoryLocation = NULL;
353
354 PlayerBase player = action_data.m_Player;
355 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
356
357 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
358 int muzzle_index = wpn.GetCurrentMuzzle();
359
360 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
361
362 if (am_action_data.m_oldMagazine)
363 {
364 oldMagTargetInventoryLocation = new InventoryLocation;
365 if ( action_data.m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
366 {
367 success = false;
368 }
369 else
370 {
371 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine,GameInventory.c_InventoryReservationTimeoutMS);
372 }
373 }
374
375 if (success)
376 {
377 targetInventoryLocation = new InventoryLocation;
378 targetInventoryLocation.SetAttachment( wpn, new_mag, InventorySlots.MAGAZINE);
379 if ( action_data.m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
380 {
381 success = false;
382 if (am_action_data.m_oldMagazine)
383 {
384 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
385 }
386 }
387 else
388 {
389 action_data.m_Player.GetInventory().AddInventoryReservationEx( new_mag, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
390 }
391 }
392
393 if (success)
394 {
395 handInventoryLocation = new InventoryLocation;
396 handInventoryLocation.SetHands(action_data.m_Player, wpn);
397
398 if ( action_data.m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
399 {
400 if (am_action_data.m_oldMagazine)
401 {
402 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
403 }
404 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
405 success = false;
406 }
407 else
408 {
409 action_data.m_Player.GetInventory().AddInventoryReservationEx( wpn, handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
410 }
411 }
412
413 if ( success )
414 {
415 if (am_action_data.m_ilOldMagazine)
416 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
417
418 if (targetInventoryLocation)
419 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
420
421 if (handInventoryLocation)
422 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
423 }
424
425 return success;
426 }
bool UseAcknowledgment()
Определения ActionBase.c:1255
bool IsLocal()
Определения ActionBase.c:271
bool IsInstant()
Определения ActionBase.c:294
DayZGame g_Game
Определения DayZGame.c:4074
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ref array< ref InventoryLocation > m_ReservedInventoryLocations
Определения ActionBase.c:42
ItemBase m_MainItem
Определения ActionBase.c:35
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>

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

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