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

◆ SplitIntoStackMaxEx()

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

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

1744 {
1745 float split_quantity_new;
1746 ItemBase new_item;
1747 float quantity = GetQuantity();
1748 float stack_max = GetTargetQuantityMax(slot_id);
1749 InventoryLocation loc = new InventoryLocation;
1750
1751 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1752 {
1753 if (stack_max <= GetQuantity())
1754 split_quantity_new = stack_max;
1755 else
1756 split_quantity_new = GetQuantity();
1757
1758 if (ShouldSplitQuantity(split_quantity_new))
1759 {
1760 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1761 if (new_item)
1762 {
1763 new_item.SetResultOfSplit(true);
1764 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1765 AddQuantity(-split_quantity_new, false, true);
1766 new_item.SetQuantity(split_quantity_new, false, true);
1767 }
1768 }
1769 }
1770 else if (destination_entity && slot_id == -1)
1771 {
1772 if (quantity > stack_max)
1773 split_quantity_new = stack_max;
1774 else
1775 split_quantity_new = quantity;
1776
1777 if (ShouldSplitQuantity(split_quantity_new))
1778 {
1779 GameInventory destinationInventory = destination_entity.GetInventory();
1780 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1781 {
1782 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1783 new_item = ItemBase.Cast(o);
1784 }
1785
1786 if (new_item)
1787 {
1788 new_item.SetResultOfSplit(true);
1789 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1790 AddQuantity(-split_quantity_new, false, true);
1791 new_item.SetQuantity(split_quantity_new, false, true);
1792 }
1793 }
1794 }
1795 else
1796 {
1797 if (stack_max != 0)
1798 {
1799 if (stack_max < GetQuantity())
1800 {
1801 split_quantity_new = GetQuantity() - stack_max;
1802 }
1803
1804 if (ShouldSplitQuantity(split_quantity_new))
1805 {
1806 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1807
1808 if (new_item)
1809 {
1810 new_item.SetResultOfSplit(true);
1811 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1812 SetQuantity(split_quantity_new, false, true);
1813 new_item.SetQuantity(stack_max, false, true);
1814 new_item.PlaceOnSurface();
1815 }
1816 }
1817 }
1818 }
1819 }
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
DayZGame g_Game
Определения DayZGame.c:3942
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
override float GetQuantity()
Определения ItemBase.c:3508
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:3413
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:3340
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:3473
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:1613
void ItemBase()
Определения ItemBase.c:148
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

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