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

◆ SplitIntoStackMax()

void InventoryItem::SplitIntoStackMax ( EntityAI destination_entity,
int slot_id,
PlayerBase player )
inlineprotected

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

1632 {
1633 float split_quantity_new;
1634 ItemBase new_item;
1635 float quantity = GetQuantity();
1636 float stack_max = GetTargetQuantityMax(slot_id);
1637 InventoryLocation loc = new InventoryLocation;
1638
1639 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1640 {
1641 if (stack_max <= GetQuantity())
1642 split_quantity_new = stack_max;
1643 else
1644 split_quantity_new = GetQuantity();
1645
1646 if (ShouldSplitQuantity(split_quantity_new))
1647 {
1648 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1649 if (new_item)
1650 {
1651 new_item.SetResultOfSplit(true);
1652 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1653 AddQuantity(-split_quantity_new, false, true);
1654 new_item.SetQuantity(split_quantity_new, false, true);
1655 }
1656 }
1657 }
1658 else if (destination_entity && slot_id == -1)
1659 {
1660 if (quantity > stack_max)
1661 split_quantity_new = stack_max;
1662 else
1663 split_quantity_new = quantity;
1664
1665 if (ShouldSplitQuantity(split_quantity_new))
1666 {
1667 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1668 {
1669 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1670 new_item = ItemBase.Cast(o);
1671 }
1672
1673 if (new_item)
1674 {
1675 new_item.SetResultOfSplit(true);
1676 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1677 AddQuantity(-split_quantity_new, false, true);
1678 new_item.SetQuantity(split_quantity_new, false, true);
1679 }
1680 }
1681 }
1682 else
1683 {
1684 if (stack_max != 0)
1685 {
1686 if (stack_max < GetQuantity())
1687 {
1688 split_quantity_new = GetQuantity() - stack_max;
1689 }
1690
1691 if (split_quantity_new == 0)
1692 {
1693 if (!GetGame().IsMultiplayer())
1694 player.PhysicalPredictiveDropItem(this);
1695 else
1696 player.ServerDropEntity(this);
1697 return;
1698 }
1699
1700 if (ShouldSplitQuantity(split_quantity_new))
1701 {
1702 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1703
1704 if (new_item)
1705 {
1706 new_item.SetResultOfSplit(true);
1707 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1708 SetQuantity(split_quantity_new, false, true);
1709 new_item.SetQuantity(stack_max, false, true);
1710 new_item.PlaceOnSurface();
1711 }
1712 }
1713 }
1714 }
1715 }
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().