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

◆ SetQuantity()

override bool SetQuantity ( float value,
bool destroy_config = true,
bool destroy_forced = false,
bool allow_client = false,
bool clamp_to_stack_max = true )
protected

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

3316 {
3317 if (!IsServerCheck(allow_client))
3318 return false;
3319
3320 if (!HasQuantity())
3321 return false;
3322
3323 float min = GetQuantityMin();
3324 float max = GetQuantityMax();
3325
3326 if (value <= (min + 0.001))
3327 value = min;
3328
3329 if (value == min)
3330 {
3331 if (destroy_config)
3332 {
3333 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
3334 if (dstr)
3335 {
3336 m_VarQuantity = Math.Clamp(value, min, max);
3337 this.Delete();
3338 return true;
3339 }
3340 }
3341 else if (destroy_forced)
3342 {
3343 m_VarQuantity = Math.Clamp(value, min, max);
3344 this.Delete();
3345 return true;
3346 }
3347 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
3348 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
3349 }
3350
3351 float delta = m_VarQuantity;
3352 m_VarQuantity = Math.Clamp(value, min, max);
3353
3354 EntityAI parent = GetHierarchyRoot();
3356 GameInventory gameInventory = GetInventory();
3357 if (gameInventory)
3358 {
3359 gameInventory.GetCurrentInventoryLocation(iLoc);
3360 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
3361 {
3362 int iLocSlot = iLoc.GetSlot();
3363 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
3364 {
3365 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
3366 }
3367 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
3368 {
3369 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
3370 }
3371 }
3372 }
3373
3374 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
3375 {
3376 delta = m_VarQuantity - delta;
3377
3378 if (delta)
3379 OnQuantityChanged(delta);
3380 }
3381
3382 SetVariableMask(VARIABLE_QUANTITY);
3383
3384 return false;
3385 }
override bool IsPrepareToDelete()
Определения FireplaceBase.c:657
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
float m_VarQuantity
Определения ItemBase.c:37
override int GetQuantityMin()
Определения ItemBase.c:3470
override void RemoveAllAgents()
Определения ItemBase.c:3974
override bool HasQuantity()
Определения ItemBase.c:3481
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:1987
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:4436
override float GetStoreLoadedQuantity()
Определения ItemBase.c:3774
override int GetQuantityMax()
Определения ItemBase.c:3435
@ LOWEST
Определения PPEConstants.c:54
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
script counterpart to engine's class Inventory
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
InventoryLocation.
Определения InventoryLocation.c:30
Определения EnMath.c:7
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:665
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

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