DayZ 1.27
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 )
inlineprivate

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 строка 3238

3239 {
3240 if (!IsServerCheck(allow_client))
3241 return false;
3242
3243 if (!HasQuantity())
3244 return false;
3245
3246 float min = GetQuantityMin();
3247 float max = GetQuantityMax();
3248
3249 if (value <= (min + 0.001))
3250 value = min;
3251
3252 if (value == min)
3253 {
3254 if (destroy_config)
3255 {
3256 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
3257 if (dstr)
3258 {
3259 m_VarQuantity = Math.Clamp(value, min, max);
3260 this.Delete();
3261 return true;
3262 }
3263 }
3264 else if (destroy_forced)
3265 {
3266 m_VarQuantity = Math.Clamp(value, min, max);
3267 this.Delete();
3268 return true;
3269 }
3270 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
3271 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
3272 }
3273
3274 float delta = m_VarQuantity;
3275 m_VarQuantity = Math.Clamp(value, min, max);
3276
3277 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
3278 {
3279 delta = m_VarQuantity - delta;
3280
3281 if (delta)
3282 OnQuantityChanged(delta);
3283 }
3284
3285 SetVariableMask(VARIABLE_QUANTITY);
3286
3287 return false;
3288 }
@ LOWEST
Определения PPEConstants.c:54
override bool HasQuantity()
Определения ItemBase.c:3381
override void RemoveAllAgents()
Определения ItemBase.c:3875
override int GetQuantityMax()
Определения ItemBase.c:3338
float m_VarQuantity
Определения ItemBase.c:29
override float GetStoreLoadedQuantity()
Определения ItemBase.c:3663
override int GetQuantityMin()
Определения ItemBase.c:3370
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:2005
const int VARIABLE_QUANTITY
Определения constants.c:626

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