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

◆ SplitIntoStackMaxEx()

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

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

1718 {
1719 float split_quantity_new;
1720 ItemBase new_item;
1721 float quantity = GetQuantity();
1722 float stack_max = GetTargetQuantityMax(slot_id);
1723 InventoryLocation loc = new InventoryLocation;
1724
1725 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1726 {
1727 if (stack_max <= GetQuantity())
1728 split_quantity_new = stack_max;
1729 else
1730 split_quantity_new = GetQuantity();
1731
1732 if (ShouldSplitQuantity(split_quantity_new))
1733 {
1734 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1735 if (new_item)
1736 {
1737 new_item.SetResultOfSplit(true);
1738 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1739 AddQuantity(-split_quantity_new, false, true);
1740 new_item.SetQuantity(split_quantity_new, false, true);
1741 }
1742 }
1743 }
1744 else if (destination_entity && slot_id == -1)
1745 {
1746 if (quantity > stack_max)
1747 split_quantity_new = stack_max;
1748 else
1749 split_quantity_new = quantity;
1750
1751 if (ShouldSplitQuantity(split_quantity_new))
1752 {
1753 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1754 {
1755 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1756 new_item = ItemBase.Cast(o);
1757 }
1758
1759 if (new_item)
1760 {
1761 new_item.SetResultOfSplit(true);
1762 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1763 AddQuantity(-split_quantity_new, false, true);
1764 new_item.SetQuantity(split_quantity_new, false, true);
1765 }
1766 }
1767 }
1768 else
1769 {
1770 if (stack_max != 0)
1771 {
1772 if (stack_max < GetQuantity())
1773 {
1774 split_quantity_new = GetQuantity() - stack_max;
1775 }
1776
1777 if (ShouldSplitQuantity(split_quantity_new))
1778 {
1779 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1780
1781 if (new_item)
1782 {
1783 new_item.SetResultOfSplit(true);
1784 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1785 SetQuantity(split_quantity_new, false, true);
1786 new_item.SetQuantity(stack_max, false, true);
1787 new_item.PlaceOnSurface();
1788 }
1789 }
1790 }
1791 }
1792 }
eBleedingSourceType GetType()
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:3456
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:3362
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:3308
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:3421
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:1588
void ItemBase()
Определения ItemBase.c:140
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
class LOD Object
proto native CGame GetGame()

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