private void UseItem(ItemUsage usage) { var item = Util.GetCurrentItem(); if (!ItemUsable(item, usage)) { return; } var usableItem = EntityManager.GetComponent <UsableItemComponent>(item); ItemUsedEvent?.Invoke(ControlledEntity, item, usage); }
public float GetValue() { if (additiveModifiers == null) { return(0); } float value = 0; for (int i = 0; i < additiveModifiers.Length; i++) { if (additiveModifiers[i].stat == Stat.Heal) { value = additiveModifiers[i].value; effectUsed = true; } } if (percentageModifiers == null) { return(0); } float percentageValue = 0; for (int i = 0; i < percentageModifiers.Length; i++) { if (percentageModifiers[i].stat == Stat.Heal) { percentageValue = percentageModifiers[i].value; effectUsed = true; } } float percentage = (percentageValue * user.GetComponent <BaseStats>().GetStat(Stat.Health)) / 100; float total = value + percentage; health.Invoke(total, user); return(total); }
/// <summary> /// Use the item. Override the method in inherited types /// or use <see cref="onItemUsed"/> event for item-specific effects. /// </summary> /// <param name="slotIndex">Index of the slot the item was used from.</param> public virtual void Use(int slotIndex) { onItemUsed?.Invoke(slotIndex); }