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

◆ SetQuantity()

override bool InventoryItem::SetQuantity ( float value,
bool destroy_config = true,
bool destroy_forced = false,
bool allow_client = false,
bool clamp_to_stack_max = true )
inlineprotected

Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity reaches varQuantityMin or lower and the item config contains the varQuantityDestroyOnMin = true entry, the item gets destroyed. destroy_forced = true means item gets destroyed when quantity reaches varQuantityMin or lower regardless of config setting, returns true if the item gets deleted.

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

3341 {
3342 if (!IsServerCheck(allow_client))
3343 return false;
3344
3345 if (!HasQuantity())
3346 return false;
3347
3348 float min = GetQuantityMin();
3349 float max = GetQuantityMax();
3350
3351 if (value <= (min + 0.001))
3352 value = min;
3353
3354 if (value == min)
3355 {
3356 if (destroy_config)
3357 {
3358 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
3359 if (dstr)
3360 {
3361 m_VarQuantity = Math.Clamp(value, min, max);
3362 this.Delete();
3363 return true;
3364 }
3365 }
3366 else if (destroy_forced)
3367 {
3368 m_VarQuantity = Math.Clamp(value, min, max);
3369 this.Delete();
3370 return true;
3371 }
3372 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
3373 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
3374 }
3375
3376 float delta = m_VarQuantity;
3377 m_VarQuantity = Math.Clamp(value, min, max);
3378
3379 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
3380 {
3381 EntityAI parent = GetHierarchyRoot();
3382 InventoryLocation iLoc = new InventoryLocation();
3383 GetInventory().GetCurrentInventoryLocation(iLoc);
3384 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
3385 {
3386 int iLocSlot = iLoc.GetSlot();
3387 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
3388 {
3389 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
3390 }
3391 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
3392 {
3393 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
3394 }
3395 }
3396 }
3397
3398 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
3399 {
3400 delta = m_VarQuantity - delta;
3401
3402 if (delta)
3403 OnQuantityChanged(delta);
3404 }
3405
3406 SetVariableMask(VARIABLE_QUANTITY);
3407
3408 return false;
3409 }
class LogManager EntityAI
DayZGame g_Game
Определения DayZGame.c:3942
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
@ LOWEST
Определения PPEConstants.c:54
override bool HasQuantity()
Определения ItemBase.c:3503
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:4468
override void RemoveAllAgents()
Определения ItemBase.c:3995
override int GetQuantityMax()
Определения ItemBase.c:3459
float m_VarQuantity
Определения ItemBase.c:35
override float GetStoreLoadedQuantity()
Определения ItemBase.c:3788
override int GetQuantityMin()
Определения ItemBase.c:3492
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:2052
proto native bool IsValid()
verify current set inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetType()
returns type of InventoryLocation
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631

Перекрестные ссылки Math::Clamp(), g_Game, GetQuantityMax(), GetQuantityMin(), InventoryLocation::GetSlot(), GetStoreLoadedQuantity(), InventoryLocation::GetType(), HasQuantity(), IsPrepareToDelete(), InventoryLocation::IsValid(), LOWEST, m_VarQuantity, OnQuantityChanged(), RemoveAllAgents(), StartItemSoundServer() и VARIABLE_QUANTITY.