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

◆ SplitIntoStackMaxEx()

override void SplitIntoStackMaxEx ( EntityAI destination_entity,
int slot_id )
protected

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

1672 {
1673 float split_quantity_new;
1674 ItemBase new_item;
1675 float quantity = GetQuantity();
1676 float stack_max = GetTargetQuantityMax(slot_id);
1678
1679 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1680 {
1681 if (stack_max <= GetQuantity())
1682 split_quantity_new = stack_max;
1683 else
1684 split_quantity_new = GetQuantity();
1685
1686 if (ShouldSplitQuantity(split_quantity_new))
1687 {
1688 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1689 if (new_item)
1690 {
1691 new_item.SetResultOfSplit(true);
1692 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1693 AddQuantity(-split_quantity_new, false, true);
1694 new_item.SetQuantity(split_quantity_new, false, true);
1695 }
1696 }
1697 }
1698 else if (destination_entity && slot_id == -1)
1699 {
1700 if (quantity > stack_max)
1701 split_quantity_new = stack_max;
1702 else
1703 split_quantity_new = quantity;
1704
1705 if (ShouldSplitQuantity(split_quantity_new))
1706 {
1707 GameInventory destinationInventory = destination_entity.GetInventory();
1708 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1709 {
1710 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1711 new_item = ItemBase.Cast(o);
1712 }
1713
1714 if (new_item)
1715 {
1716 new_item.SetResultOfSplit(true);
1717 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1718 AddQuantity(-split_quantity_new, false, true);
1719 new_item.SetQuantity(split_quantity_new, false, true);
1720 }
1721 }
1722 }
1723 else
1724 {
1725 if (stack_max != 0)
1726 {
1727 if (stack_max < GetQuantity())
1728 {
1729 split_quantity_new = GetQuantity() - stack_max;
1730 }
1731
1732 if (ShouldSplitQuantity(split_quantity_new))
1733 {
1734 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1735
1736 if (new_item)
1737 {
1738 new_item.SetResultOfSplit(true);
1739 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1740 SetQuantity(split_quantity_new, false, true);
1741 new_item.SetQuantity(stack_max, false, true);
1742 new_item.PlaceOnSurface();
1743 }
1744 }
1745 }
1746 }
1747 }
eBleedingSourceType GetType()
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:38
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:37
const int RF_DEFAULT
Определения CentralEconomy.c:66
override void SetQuantity()
Определения ConstructionInfoIcons.c:298
DayZGame g_Game
Определения DayZGame.c:4074
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
override float GetQuantity()
Определения ItemBase.c:3486
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:1541
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:3449
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:3389
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.
script counterpart to engine's class Inventory
InventoryLocation.
Определения InventoryLocation.c:30
static proto native bool IsSlotIdValid(int slotId)
verifies existence of the slot id
provides access to slot configuration
Определения InventorySlots.c:6
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfBricks.c:64
Определения ObjectTyped.c:2

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