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

◆ SplitItem()

void InventoryItem::SplitItem ( PlayerBase player)
inlineprotected

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

1992 {
1993 float quantity = GetQuantity();
1994 float split_quantity_new = Math.Floor(quantity / 2);
1995
1996 if (!ShouldSplitQuantity(split_quantity_new))
1997 return;
1998
1999 InventoryLocation invloc = new InventoryLocation;
2000 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
2001
2002 ItemBase new_item;
2003 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
2004
2005 if (new_item)
2006 {
2007 if (new_item.GetQuantityMax() < split_quantity_new)
2008 {
2009 split_quantity_new = new_item.GetQuantityMax();
2010 }
2011 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
2012 {
2013 AddQuantity(-1, false, true);
2014 new_item.SetQuantity(1, false, true);
2015 }
2016 else if (split_quantity_new > 1)
2017 {
2018 AddQuantity(-split_quantity_new, false, true);
2019 new_item.SetQuantity(split_quantity_new, false, true);
2020 }
2021 }
2022 }
eBleedingSourceType GetType()
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
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
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:1588
void ItemBase()
Определения ItemBase.c:140
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().