private static void Postfix(PlayerAmmoStorage __instance, InventorySlotAmmo ammo, int clip) { if (__instance.m_playerBackpack.IsLocal) { InventoryAmmoEvents.AmmoUpdate(ammo, clip); } }
public static void AmmoUpdate(InventorySlotAmmo item, int clipleft) { if (OnInventoryAmmoUpdate != null) { OnInventoryAmmoUpdate.Invoke(item, clipleft); } }
static void Postfix(InventorySlotAmmo ammo, int clip, PlayerBackpack ___m_playerBackpack) { if (___m_playerBackpack.IsLocal) { InventoryAmmoEvents.AmmoUpdate(ammo, clip); } }
private static void UpdateItemInfoText(InventorySlotAmmo item, int clipLeft, RadialItem radialItem) { if (item == null) { return; } if (item.Slot == InventorySlot.GearStandard || item.Slot == InventorySlot.GearSpecial) { string ammoStatus = clipLeft + "\n----\n" + ((int)(item.BulletsMaxCap * item.RelInPack)).ToString(); radialItem.SetInfoText(ammoStatus); } if (item.Slot == InventorySlot.GearClass) { if (!radialItem.Active) { return; } radialItem.SetInfoText($"{(int)(item.RelInPack * 100f)}%"); } if (item.Slot == InventorySlot.Consumable || item.Slot == InventorySlot.ResourcePack) { int CurrentValue = (int)(item.BulletsMaxCap * item.RelInPack) + clipLeft; radialItem.SetInfoText(CurrentValue.ToString()); radialItem.Active = CurrentValue > 0; if (!radialItem.Active) { radialItem.SetInfoText(""); } } }
private void OnAmmoUpdate(InventorySlotAmmo item, int clipleft) { if (!VRConfig.configUseBhaptics.Value) { return; } if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot)) { AmmoType ammoType = item.AmmoType; if (ammoType == AmmoType.Standard || ammoType == AmmoType.Special) { if (clipleft == 0) { if (Controllers.mainControllerType == HandType.Left || Controllers.aimingTwoHanded) { m_hapticPlayer.SubmitRegistered(ARMS_OUT_OF_AMMO_L_KEY); } if (Controllers.mainControllerType == HandType.Right || Controllers.aimingTwoHanded) { m_hapticPlayer.SubmitRegistered(ARMS_OUT_OF_AMMO_R_KEY); } } } } }
// Listen for values in respective classes ( PUI_Inventory ) private void UiUpdate(InventorySlotAmmo item, int clipLeft) { DividedBarShaderController bar = null; UIMappings.TryGetValue(item.Slot, out bar); if (ItemEquippableEvents.currentItem != null && ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot) && ItemEquippableEvents.IsCurrentItemShootableWeapon()) { //Debug.Log("Ammo update event (main or sub weapon): " + "MaxAmmo: " + item.BulletClipSize + " Current ammo: " + clipLeft + " Inventory slot: " + item.Slot); BulletsInMag.maxAmmo = item.BulletClipSize; BulletsInMag.UpdateCurrentAmmo(clipLeft); BulletsInMag.UpdateAmmoGridDivisions(); BulletsInMag.inventorySlot = item.Slot; } if (bar) { //Debug.Log("Ammo update event: " + "MaxAmmo: " + item.BulletClipSize + " Current ammo: " + clipLeft + " maxCap: " + item.BulletsMaxCap + " RelInPack " + item.RelInPack + " Inventory slot: " + item.Slot); bar.maxAmmo = item.BulletsMaxCap; bar.currentAmmo = (int)(bar.maxAmmo * item.RelInPack); bar.SetFill(item.RelInPack); if (item.Slot.Equals(InventorySlot.Consumable) || item.Slot.Equals(InventorySlot.ResourcePack) || item.Slot.Equals(InventorySlot.ConsumableHeavy)) { bar.UpdatePackOrConsumableDivisions(); } } }
private void AmmoUpdate(InventorySlotAmmo item, int clipLeft) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot)) { SetText(clipLeft.ToString()); } }
private void AmmoUpdate(InventorySlotAmmo item, int clipLeft) { if (item == null) { Log.Warning("Got null item!"); return; } if (m_radialItems.TryGetValue(item.Slot, out RadialItem radialItem)) { UpdateItemInfoText(item, clipLeft, radialItem); TryGetIcon(item, radialItem); } }
private void UpdateBulletDisplayAmount(InventorySlotAmmo item, int clipLeft) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot)) { m_numberBulletsInMagDisplay.text = clipLeft + "\n----\n" + ((int)(item.BulletsMaxCap * item.RelInPack)).ToString(); m_numberBulletsInMagDisplay.ForceMeshUpdate(false); m_bulletsInMagDisplay.MaxValue = Mathf.Max(item.BulletClipSize, 1); m_bulletsInMagDisplay.UpdateCurrentAmmo(clipLeft); m_bulletsInMagDisplay.UpdateAmmoGridDivisions(); } }
private void TryGetIcon(InventorySlotAmmo item, RadialItem radialItem) { if (m_retrievedIcons.ContainsKey(item.Slot)) { return; } if (item.Slot == InventorySlot.GearMelee || item.Slot == InventorySlot.GearSpecial || item.Slot == InventorySlot.GearStandard || item.Slot == InventorySlot.GearClass) { if (PlayerBackpackManager.LocalBackpack.TryGetBackpackItem(item.Slot, out BackpackItem bp)) { if (bp == null || bp.Instance == null) { Log.Debug($"Got null BP or instance for {item.Slot}"); return; } ItemEquippable equippable = bp.Instance.Cast <ItemEquippable>(); if (equippable == null || equippable.GearIDRange == null) { Log.Debug("Equippable was null or GearIDRange was null when retrieving icon!"); return; } if (GearIconRendering.TryGetGearIconSprite(equippable.GearIDRange.GetChecksum(), out Sprite icon)) { if (icon == null) { m_retrievedIcons[item.Slot] = null; Log.Debug($"Failed to retrieve icon for {equippable.ArchetypeName}"); return; } m_retrievedIcons[item.Slot] = icon; if (item.Slot == InventorySlot.GearMelee) { radialItem.SetIcon(icon, 1.5f); } else { radialItem.SetIcon(icon); } Log.Debug($"Retrieved icon for {equippable.ArchetypeName}!"); } else { m_retrievedIcons[item.Slot] = null; Log.Debug($"Failed to retrieve icon for {equippable.ArchetypeName}"); } } } }
private void UpdateInventoryAmmoGrids(InventorySlotAmmo item, int clipLeft) { m_inventoryToAmmoDisplayMapping.TryGetValue(item.Slot, out DividedBarShaderController bar); if (bar) { bar.MaxValue = item.BulletsMaxCap; bar.CurrentValue = (int)(bar.MaxValue * item.RelInPack) + clipLeft; bar.SetFill(item.RelInPack); if (item.Slot.Equals(InventorySlot.GearStandard) || item.Slot.Equals(InventorySlot.GearSpecial)) { bar.UpdateWeaponMagDivisions(item.BulletClipSize, item.BulletsMaxCap); } if (item.Slot.Equals(InventorySlot.Consumable) || item.Slot.Equals(InventorySlot.ResourcePack) || item.Slot.Equals(InventorySlot.ConsumableHeavy)) { bar.UpdatePackOrConsumableDivisions(); } } }
private void AmmoUpdate(InventorySlotAmmo item, int clipLeft) { UpdateBulletDisplayAmount(item, clipLeft); UpdateInventoryAmmoGrids(item, clipLeft); }