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

◆ SplitItem()

void InventoryItem::SplitItem ( PlayerBase player)
inlineprotected

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

2019 {
2020 float quantity = GetQuantity();
2021 float split_quantity_new = Math.Floor(quantity / 2);
2022
2023 if (!ShouldSplitQuantity(split_quantity_new))
2024 return;
2025
2026 InventoryLocation invloc = new InventoryLocation;
2027 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
2028
2029 ItemBase new_item;
2030 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
2031
2032 if (new_item)
2033 {
2034 if (new_item.GetQuantityMax() < split_quantity_new)
2035 {
2036 split_quantity_new = new_item.GetQuantityMax();
2037 }
2038 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
2039 {
2040 AddQuantity(-1, false, true);
2041 new_item.SetQuantity(1, false, true);
2042 }
2043 else if (split_quantity_new > 1)
2044 {
2045 AddQuantity(-split_quantity_new, false, true);
2046 new_item.SetQuantity(split_quantity_new, false, true);
2047 }
2048 }
2049 }
eBleedingSourceType GetType()
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
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
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:1613
void ItemBase()
Определения ItemBase.c:148
proto native bool IsValid()
verify current set inventory location
proto native int GetType()
returns type of InventoryLocation
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

Перекрестные ссылки AddQuantity(), Math::Floor(), GetQuantity(), GetType(), InventoryLocation::GetType(), InventoryLocation::IsValid(), ItemBase(), ItemBase::SetQuantity() и ShouldSplitQuantity().