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

◆ SplitIntoStackMaxEx()

override void InventoryItem::SplitIntoStackMaxEx ( EntityAI destination_entity,
int slot_id )
inlineprivate

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

1695 {
1696 if (!CanBeSplit())
1697 return;
1698
1699 float split_quantity_new;
1700 ref ItemBase new_item;
1701 float quantity = GetQuantity();
1702 float stack_max = GetTargetQuantityMax(slot_id);
1703 InventoryLocation loc = new InventoryLocation;
1704
1705 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1706 {
1707 if (stack_max <= GetQuantity())
1708 split_quantity_new = stack_max;
1709 else
1710 split_quantity_new = GetQuantity();
1711
1712 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1713 if (new_item)
1714 {
1715 new_item.SetResultOfSplit(true);
1716 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1717 AddQuantity(-split_quantity_new);
1718 new_item.SetQuantity(split_quantity_new);
1719 }
1720 }
1721 else if (destination_entity && slot_id == -1)
1722 {
1723 if (quantity > stack_max)
1724 split_quantity_new = stack_max;
1725 else
1726 split_quantity_new = quantity;
1727
1728 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1729 {
1730 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1731 new_item = ItemBase.Cast(o);
1732 }
1733
1734 if (new_item)
1735 {
1736 new_item.SetResultOfSplit(true);
1737 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1738 AddQuantity(-split_quantity_new);
1739 new_item.SetQuantity(split_quantity_new);
1740 }
1741 }
1742 else
1743 {
1744 if (stack_max != 0)
1745 {
1746 if (stack_max < GetQuantity())
1747 {
1748 split_quantity_new = GetQuantity() - stack_max;
1749 }
1750
1751 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1752
1753 if (new_item)
1754 {
1755 new_item.SetResultOfSplit(true);
1756 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1757 SetQuantity(split_quantity_new);
1758 new_item.SetQuantity(stack_max);
1759 new_item.PlaceOnSurface();
1760 }
1761 }
1762 }
1763 }
eBleedingSourceType GetType()
Определения BleedingSource.c:63
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
override float GetQuantity()
Определения ItemBase.c:3386
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:3292
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:3238
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:3351
void ItemBase()
Определения ItemBase.c:140
override bool CanBeSplit()
Определения ItemBase.c:1580
class LOD Object
proto native CGame GetGame()

Перекрестные ссылки AddQuantity(), ItemBase::CanBeSplit(), ECE_IN_INVENTORY, ECE_PLACE_ON_SURFACE, GetGame(), GetQuantity(), GetTargetQuantityMax(), GetType(), InventorySlots::IsSlotIdValid(), ItemBase(), RF_DEFAULT и ItemBase::SetQuantity().