I am trying to set up an ability system within the inventory system by using separate item categories/definitions and filling these with all the relevant attributes I need to trigger the animations, particle effects etc. In general I see absolutely no reason, why I should not end up with a satisfying solution but I am a bit stuck in regards to fetching the item in a hotbar.
In regards to equipped items I use the namespaces
using Opsive.UltimateInventorySystem.Core;
using Opsive.UltimateInventorySystem.Equipping;
using Opsive.Shared.Game;
and then something along the line of (only referencing the relevant code here now):
This works nicely so I tried to somehow replicate the approach by adding the namespaces
using Opsive.UltimateInventorySystem.Core.DataStructures;
using Opsive.UltimateInventorySystem.UI.Panels.Hotbar;
and then doing the following:
I didn't find a solution to directly fetch the Item, since GetEquipped() wasn't available here, so I went through the ItemInfo with GetItemAt() but the problem is that I'm not getting the itemHotbar in the first place because playerInventory.gameObject.GetCachedComponent<ItemHotbar>(); is always returning null.
In the end, I simply want to be able to get the items slotted in the hotbar during runtime and then retrieve the desired attributes in order to use them in custom scripts, just like I do with the items fetched via the equipper already.
Thanks a lot for any help here.
In regards to equipped items I use the namespaces
using Opsive.UltimateInventorySystem.Core;
using Opsive.UltimateInventorySystem.Equipping;
using Opsive.Shared.Game;
and then something along the line of (only referencing the relevant code here now):
C#:
private Equipper equipper;
private Item equippedWeapon;
private int weaponDamage;
var playerInventory = InventorySystemManager.GetInventoryIdentifier(1).Inventory;
equipper = playerInventory.gameObject.GetCachedComponent<Equipper>();
equippedWeapon = equipper.GetEquippedItem("MainHand");
equippedWeapon.TryGetAttributeValue("Damage", out weaponDamage);
This works nicely so I tried to somehow replicate the approach by adding the namespaces
using Opsive.UltimateInventorySystem.Core.DataStructures;
using Opsive.UltimateInventorySystem.UI.Panels.Hotbar;
and then doing the following:
C#:
private ItemHotbar itemHotbar;
private ItemInfo equippedAbility;
private string triggerName;
var playerInventory = InventorySystemManager.GetInventoryIdentifier(1).Inventory;
itemHotbar = playerInventory.gameObject.GetCachedComponent<ItemHotbar>();
equippedAbility = itemHotbar.GetItemAt(1);
equippedAbility.Item.TryGetAttributeValue("TriggerName", out triggerName);
I didn't find a solution to directly fetch the Item, since GetEquipped() wasn't available here, so I went through the ItemInfo with GetItemAt() but the problem is that I'm not getting the itemHotbar in the first place because playerInventory.gameObject.GetCachedComponent<ItemHotbar>(); is always returning null.
In the end, I simply want to be able to get the items slotted in the hotbar during runtime and then retrieve the desired attributes in order to use them in custom scripts, just like I do with the items fetched via the equipper already.
Thanks a lot for any help here.