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

◆ SwappingToPreviousLocation()

bool HumanInventory::SwappingToPreviousLocation ( EntityAI item1,
EntityAI item2,
out InventoryLocation dst )
inlineprotected

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

491 {
492 bool SwapToPrevious = true;
493 InventoryLocation src1 = new InventoryLocation();
494 InventoryLocation src2 = new InventoryLocation();
495 dst = new InventoryLocation();
496 GameInventory item1Inventory = item1.GetInventory();
497 if (item1Inventory.GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
498 {
499 if (item1.m_OldLocation && item1.m_OldLocation.IsValid() && !item1.m_OldLocation.CollidesWith(src2) && item1.m_OldLocation.GetParent() && item1.m_OldLocation.GetParent().GetHierarchyRootPlayer())
500 {
501 dst.Copy(item1.m_OldLocation);
502
503 if (src2.GetType() == InventoryLocationType.ATTACHMENT) //item2 is currently attached somewhere
504 {
505 int count = item1Inventory.GetSlotIdCount();
506 for (int i = 0; i < count; ++i)
507 {
508 int slotID = item1Inventory.GetSlotId(i);
509 if (src2.GetSlot() == slotID) //can be attached into the same slot. And will be.
510 return false;
511 }
512 }
513
514 if (!item1.m_OldLocation.GetParent().GetInventory().LocationCanAddEntity(item1.m_OldLocation))
515 SwapToPrevious = false;
516
517 if (CanSwapEntitiesEx(item1,item2))
518 SwapToPrevious = false;
519
520 if (SwapToPrevious)
521 return true;
522 }
523 }
524
525 return false;
526 }
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
proto native int GetSlotId(int index)
attachments
proto native int GetSlotIdCount()
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetType()
returns type of InventoryLocation

Перекрестные ссылки GameInventory::CanSwapEntitiesEx(), GameInventory::GetCurrentInventoryLocation(), InventoryLocation::GetSlot(), GameInventory::GetSlotId(), GameInventory::GetSlotIdCount() и InventoryLocation::GetType().

Используется в ForceSwapEntities() и SwapEntities().