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

◆ SplitIntoStackMax()

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

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

1615 {
1616 if (!CanBeSplit())
1617 return;
1618
1619 float split_quantity_new;
1620 ref ItemBase new_item;
1621 float quantity = GetQuantity();
1622 float stack_max = GetTargetQuantityMax(slot_id);
1623 InventoryLocation loc = new InventoryLocation;
1624
1625 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1626 {
1627 if (stack_max <= GetQuantity())
1628 split_quantity_new = stack_max;
1629 else
1630 split_quantity_new = GetQuantity();
1631
1632 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1633 if (new_item)
1634 {
1635 new_item.SetResultOfSplit(true);
1636 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1637 AddQuantity(-split_quantity_new);
1638 new_item.SetQuantity(split_quantity_new);
1639 }
1640 }
1641 else if (destination_entity && slot_id == -1)
1642 {
1643 if (quantity > stack_max)
1644 split_quantity_new = stack_max;
1645 else
1646 split_quantity_new = quantity;
1647
1648 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1649 {
1650 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1651 new_item = ItemBase.Cast(o);
1652 }
1653
1654 if (new_item)
1655 {
1656 new_item.SetResultOfSplit(true);
1657 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1658 AddQuantity(-split_quantity_new);
1659 new_item.SetQuantity(split_quantity_new);
1660 }
1661 }
1662 else
1663 {
1664 if (stack_max != 0)
1665 {
1666 if (stack_max < GetQuantity())
1667 {
1668 split_quantity_new = GetQuantity() - stack_max;
1669 }
1670
1671 if (split_quantity_new == 0)
1672 {
1673 if (!GetGame().IsMultiplayer())
1674 player.PhysicalPredictiveDropItem(this);
1675 else
1676 player.ServerDropEntity(this);
1677 return;
1678 }
1679
1680 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1681
1682 if (new_item)
1683 {
1684 new_item.SetResultOfSplit(true);
1685 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1686 SetQuantity(split_quantity_new);
1687 new_item.SetQuantity(stack_max);
1688 new_item.PlaceOnSurface();
1689 }
1690 }
1691 }
1692 }
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().