/// <summary> /// The specified consumable ItemIdentifier has been used. /// </summary> /// <param name="item">The Item that has been used.</param> /// <param name="itemIdentifier">The ItemIdentifier that has been used.</param> /// <param name="amount">The remaining amount of the specified IItemIdentifier.</param> protected virtual void OnUseConsumableItemIdentifier(Item item, IItemIdentifier itemIdentifier, int amount) { }
/// <summary> /// Tries the reload the item with the specified ItemIdentifier. /// </summary> /// <param name="slotID">The SlotID of the item trying to reload.</param> /// <param name="itemIdentifier">The ItemIdentifier which should be reloaded.</param> /// <param name="immediateReload">Should the item be reloaded immediately?</param> /// <param name="equipCheck">Should the equipped items be checked.</param> private void OnTryReload(int slotID, IItemIdentifier itemIdentifier, bool immediateReload, bool equipCheck) { if (m_SlotID != -1 && slotID != -1 && m_SlotID != slotID) { return; } var allItems = m_Inventory.GetAllItems(); var canReloadCount = 0; for (int i = 0; i < allItems.Count; ++i) { var item = allItems[i]; if (slotID != -1 && item.SlotID != slotID) { continue; } IReloadableItem reloadableItem; if ((reloadableItem = ShouldReload(item, itemIdentifier, slotID == -1)) != null) // -1 indicates that the item is being picked up. { if (m_CanReloadItems == null || m_CanReloadItems.Length == canReloadCount) { System.Array.Resize(ref m_CanReloadItems, canReloadCount + 1); } m_CanReloadItems[canReloadCount] = reloadableItem; canReloadCount++; } } if (canReloadCount > 0) { var startAbility = false; for (int i = 0; i < canReloadCount; ++i) { var reloadableItem = m_CanReloadItems[i]; // The item should automatically be reloaded if: // - The item is being reloaded automatically. // - The item isn't currently equipped. Non-equipped items don't need to play an animation. if (immediateReload || (equipCheck && !m_EquippedItems.Contains(reloadableItem.Item))) { reloadableItem.ReloadItem(true); reloadableItem.ItemReloadComplete(true); } else { startAbility = true; if (m_SlotID == -1) { m_ReloadableItems[reloadableItem.Item.SlotID] = reloadableItem; } else { m_ReloadableItems[0] = reloadableItem; } } } if (startAbility) { StartAbility(); } } }
/// <summary> /// An ItemIdentifier has been picked up within the inventory. /// </summary> /// <param name="itemIdentifier">The ItemIdentifier that has been picked up.</param> /// <param name="amount">The amount of item picked up.</param> /// <param name="immediatePickup">Was the item be picked up immediately?</param> /// <param name="forceEquip">Should the item be force equipped?</param> protected virtual void OnPickupItemIdentifier(IItemIdentifier itemIdentifier, int amount, bool immediatePickup, bool forceEquip) { }
/// <summary> /// An ItemIdentifier has been picked up within the inventory. /// </summary> /// <param name="itemIdentifier">The ItemIdentifier that has been equipped.</param> /// <param name="amount">The amount of ItemIdentifier picked up.</param> /// <param name="immediatePickup">Was the item be picked up immediately?</param> /// <param name="forceEquip">Should the item be force equipped?</param> private void OnPickupItemIdentifier(IItemIdentifier itemIdentifier, int amount, bool immediatePickup, bool forceEquip) { // Determine if the equipped item should be reloaded. OnTryReload(-1, itemIdentifier, immediatePickup, true); }