/// <summary> /// Event for when the player uses the held item /// </summary> public void UseItem() { bool itemUsedUp; // Check if the item is "used up" / has no more uses // If the item type is a Turret GameObject instantiatedItem; if (selectedItem.itemType == ItemType.Turret) { // Instantiate the turret // This Utilises "SpawnTurret" prefabs // These are empty GameObjects with the SpawnTurret script attached // They instantiate the turret, and are destroyed after instantiatedItem = Instantiate(selectedItem.usableObject); Destroy(instantiatedItem); } // Broadcast event if (ItemUseEvent != null) { ItemUseEvent.Invoke(this, new InventoryEventArgs(InventoryEventType.Use, selectedItem)); } // If the item duration is 0, remove the item itemUsedUp = selectedItem.UseItem(); if (itemUsedUp && enableItemDuration) { RemoveItem(); } }
public ItemUseEvent ToBoltItemUseEventEvent(BoltEntity reciever) { ItemUseEvent evnt = ItemUseEvent.Create(reciever); evnt.Slot = SlotId; return(evnt); }
public void activateItem() { if (HeldItem != null && !HeldItem.isOnCooldown) { HeldItem.activateItem(); onItemUse?.Invoke(HeldItem); ItemUseEvent?.Invoke(); } }
public Item(ItemData itemData) { this.itemData = itemData; OnLeftClick = new ItemUseEvent(); OnRightClick = new ItemUseEvent(); ReleaseLeftClick = new ItemUseEvent(); ReleaseRightClick = new ItemUseEvent(); InitializeModifiers(); }
/// <summary> /// Uses the item, inflicting the EntityEffect on the designated entities /// </summary> /// <param name="User">The BattleEntity that used the Item</param> /// <param name="Entities">The BattleEntities affected by the Item</param> public void OnUse(BattleEntity User, params BattleEntity[] Entities) { //Call use event ItemUseEvent?.Invoke(this, User); if (Entityeffect == null) { Debug.LogError($"Item {Name}'s EntityEffect is null!"); return; } Entityeffect.UseEffect(new Globals.AffectableInfo(User, this), Entities); }
// Not merged with EquipmentItem as this'll contain data on how to physically equip a weapon // Equipment items won't be physically equippable though, they'll just add to stats public override void Equip() { ItemUseEvent.Raise(this); }
public static ItemUseData FromBoltEvent(ItemUseEvent evnt) { return(new ItemUseData(evnt.Slot)); }
public override void OnEvent(ItemUseEvent evnt) { ItemUseData data = ItemUseData.FromBoltEvent(evnt); Character.Inventory.SpawnPrimaryEffects(data); }