DayZ 1.28
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 строка 3308

3309 {
3310 if (!IsServerCheck(allow_client))
3311 return false;
3312
3313 if (!HasQuantity())
3314 return false;
3315
3316 float min = GetQuantityMin();
3317 float max = GetQuantityMax();
3318
3319 if (value <= (min + 0.001))
3320 value = min;
3321
3322 if (value == min)
3323 {
3324 if (destroy_config)
3325 {
3326 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
3327 if (dstr)
3328 {
3329 m_VarQuantity = Math.Clamp(value, min, max);
3330 this.Delete();
3331 return true;
3332 }
3333 }
3334 else if (destroy_forced)
3335 {
3336 m_VarQuantity = Math.Clamp(value, min, max);
3337 this.Delete();
3338 return true;
3339 }
3340 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
3341 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
3342 }
3343
3344 float delta = m_VarQuantity;
3345 m_VarQuantity = Math.Clamp(value, min, max);
3346
3347 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
3348 {
3349 delta = m_VarQuantity - delta;
3350
3351 if (delta)
3352 OnQuantityChanged(delta);
3353 }
3354
3355 SetVariableMask(VARIABLE_QUANTITY);
3356
3357 return false;
3358 }
@ LOWEST
Определения PPEConstants.c:54
override bool HasQuantity()
Определения ItemBase.c:3451
override void RemoveAllAgents()
Определения ItemBase.c:3945
override int GetQuantityMax()
Определения ItemBase.c:3408
float m_VarQuantity
Определения ItemBase.c:29
override float GetStoreLoadedQuantity()
Определения ItemBase.c:3733
override int GetQuantityMin()
Определения ItemBase.c:3440
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:2025
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628

Перекрестные ссылки Math::Clamp(), GetQuantityMax(), GetQuantityMin(), GetStoreLoadedQuantity(), HasQuantity(), LOWEST, m_VarQuantity, OnQuantityChanged(), RemoveAllAgents() и VARIABLE_QUANTITY.