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

◆ SplitIntoStackMax()

void SplitIntoStackMax ( EntityAI destination_entity,
int slot_id,
PlayerBase player )
protected

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

1585 {
1586 float split_quantity_new;
1587 ItemBase new_item;
1588 float quantity = GetQuantity();
1589 float stack_max = GetTargetQuantityMax(slot_id);
1591
1592 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1593 {
1594 if (stack_max <= GetQuantity())
1595 split_quantity_new = stack_max;
1596 else
1597 split_quantity_new = GetQuantity();
1598
1599 if (ShouldSplitQuantity(split_quantity_new))
1600 {
1601 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1602 if (new_item)
1603 {
1604 new_item.SetResultOfSplit(true);
1605 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1606 AddQuantity(-split_quantity_new, false, true);
1607 new_item.SetQuantity(split_quantity_new, false, true);
1608 }
1609 }
1610 }
1611 else if (destination_entity && slot_id == -1)
1612 {
1613 if (quantity > stack_max)
1614 split_quantity_new = stack_max;
1615 else
1616 split_quantity_new = quantity;
1617
1618 if (ShouldSplitQuantity(split_quantity_new))
1619 {
1620 GameInventory destinationInventory = destination_entity.GetInventory();
1621 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1622 {
1623 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1624 new_item = ItemBase.Cast(o);
1625 }
1626
1627 if (new_item)
1628 {
1629 new_item.SetResultOfSplit(true);
1630 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1631 AddQuantity(-split_quantity_new, false, true);
1632 new_item.SetQuantity(split_quantity_new, false, true);
1633 }
1634 }
1635 }
1636 else
1637 {
1638 if (stack_max != 0)
1639 {
1640 if (stack_max < GetQuantity())
1641 {
1642 split_quantity_new = GetQuantity() - stack_max;
1643 }
1644
1645 if (split_quantity_new == 0)
1646 {
1647 if (!g_Game.IsMultiplayer())
1648 player.PhysicalPredictiveDropItem(this);
1649 else
1650 player.ServerDropEntity(this);
1651 return;
1652 }
1653
1654 if (ShouldSplitQuantity(split_quantity_new))
1655 {
1656 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1657
1658 if (new_item)
1659 {
1660 new_item.SetResultOfSplit(true);
1661 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1662 SetQuantity(split_quantity_new, false, true);
1663 new_item.SetQuantity(stack_max, false, true);
1664 new_item.PlaceOnSurface();
1665 }
1666 }
1667 }
1668 }
1669 }
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().

Используется в SplitIntoStackMaxClient().