/// <summary> /// Attempts to use an item on the inventory /// </summary> /// <param name="index">The index to use</param> public void UseItem(int index) { if (index >= entities.Count || index < 0) { throw new System.ArgumentOutOfRangeException("Index is out of range!"); } entities[index].Call("onItemUse"); OnItemUse?.Invoke(entities[index]); }
private static int OnUseItem(void *pCreature, uint oidItem, byte nActivePropertyIndex, byte nSubPropertyIndex, uint oidTarget, Vector3 vTargetPosition, uint oidArea, int bUseCharges) { OnItemUse eventData = ProcessEvent(new OnItemUse { UsedBy = CNWSCreature.FromPointer(pCreature).ToNwObject <NwCreature>() !, Item = oidItem.ToNwObject <NwItem>() !, TargetObject = oidTarget.ToNwObject <NwGameObject>() !, ItemPropertyIndex = nActivePropertyIndex, ItemSubPropertyIndex = nSubPropertyIndex, TargetPosition = vTargetPosition, TargetArea = oidArea.ToNwObject <NwArea>() !, UseCharges = bUseCharges.ToBool(), });
public void Init() { equipmentManager = GameController.instance.playerManager.equipmentManager; equipmentManager.onItemUnequip += AddAfterUnequip; equipmentManager.onItemEquip += Remove; onItemUse = null; onLoot = null; onItemsChangedCallback = null; onLootEnd = null; defaultItemGameObject = Resources.Load <GameObject>("Equipments/EmptyItem"); }
public PlayerInventory(int slotCount, int maxWeight) { CurrentSelected = -1; Slots = new Dictionary <int, InventorySlot>(); for (int i = 0; i < slotCount; ++i) { InventorySlot inventorySlot = new InventorySlot(i, maxWeight); inventorySlot.OnSet = (id, item) => { OnSet.Invoke(id, item); }; inventorySlot.OnSetCount = (id, count) => { OnSetCount.Invoke(id, count); }; inventorySlot.OnUse = (item) => { OnItemUse.Invoke(item); }; inventorySlot.OnEmptyHighlight += (id) => { OnEmptyHighlight.Invoke(id); }; inventorySlot.OnAvailableHighlight += (id) => { OnAvailableHighlight.Invoke(id); }; inventorySlot.OnInaccessibleHighlight += (id) => { OnInaccessibleHighlight.Invoke(id); }; inventorySlot.OnOffHighlight += (id) => { OnOffHighlight.Invoke(id); }; HighlightSlot += inventorySlot.Highlight; OffHighlightSlot += inventorySlot.OffHighlight; Slots.Add(i, inventorySlot); } }
protected void Used() { OnItemUse.Invoke(this); }
public static void InvokeOnItemUse(Mobile from, Item item) { OnItemUse?.Invoke(from, item); }
public static void InvokeOnItemUse(OnItemUseEventArgs e) { OnItemUse?.Invoke(e); }