public static void OnEquipRequest(GameClient client, ClientHeroUseItemPacket packet) { var hero = client.HeroEntity; var itemFromSlot = hero.Backpack.GetItemInfoAt(packet.SlotId).Item; if (itemFromSlot != null) { //todo: remove this special case, make it part of the 'use' section if (itemFromSlot is Equipment) { EquipFromSlotIdInInventory(packet, hero); } // Attempt to perform the use of the item on self itemFromSlot.UseItemOn(hero, hero); if(itemFromSlot.Consumable) hero.Backpack.RemoveItemAt((int) packet.SlotId); } }
private static void EquipFromSlotIdInInventory(ClientHeroUseItemPacket packet, Player hero) { // Attempt to equip the item var success = hero.TryEquipItem(packet.SlotId); }