// Handle selection effect and grid updates private void ItemSwitched(ItemEquippable item) { DividedBarShaderController UIBar = null; foreach (DividedBarShaderController d in UIMappings.Values) { d.SetUnselected(); } UIMappings.TryGetValue(item.ItemDataBlock.inventorySlot, out UIBar); if (UIBar) { UIBar.SetSelected(); } if (ItemEquippableEvents.IsCurrentItemShootableWeapon()) { //Debug.Log("Item changed event: " + "MaxAmmo: " + item.GetMaxClip() + " Current ammo: " + item.GetCurrentClip() + " Inventory slot: " + item.ItemDataBlock.inventorySlot); BulletsInMag.maxAmmo = item.GetMaxClip(); BulletsInMag.currentAmmo = item.GetCurrentClip(); BulletsInMag.UpdateAmmoGridDivisions(); BulletsInMag.inventorySlot = item.ItemDataBlock.inventorySlot; } else { BulletsInMag.currentAmmo = 0; BulletsInMag.UpdateShaderVals(1, 1); } }
private void UpdateBulletGridDivisions(ItemEquippable item) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon()) { if (!VRConfig.configUseNumbersForAmmoDisplay.Value) { m_bulletsInMagDisplay.MaxValue = item.GetMaxClip(); m_bulletsInMagDisplay.CurrentValue = item.GetCurrentClip(); m_bulletsInMagDisplay.UpdateAmmoGridDivisions(); } } else { m_bulletsInMagDisplay.CurrentValue = 0; m_bulletsInMagDisplay.UpdateShaderVals(1, 1); m_numberBulletsInMagDisplay.text = ""; m_numberBulletsInMagDisplay.ForceMeshUpdate(false); } }