protected void UseItem(string id, AimPosition aimPosition) { int itemIndex; BaseItem item; int dataId = BaseGameData.MakeDataId(id); if (GameInstance.Items.ContainsKey(dataId)) { item = GameInstance.Items[dataId]; itemIndex = OwningCharacter.IndexOfNonEquipItem(dataId); } else { InventoryType inventoryType; byte equipWeaponSet; CharacterItem characterItem; if (PlayerCharacterEntity.IsEquipped( id, out inventoryType, out itemIndex, out equipWeaponSet, out characterItem)) { GameInstance.ClientInventoryHandlers.RequestUnEquipItem( inventoryType, (short)itemIndex, equipWeaponSet, -1, ClientInventoryActions.ResponseUnEquipArmor, ClientInventoryActions.ResponseUnEquipWeapon); return; } item = characterItem.GetItem(); } if (itemIndex < 0) { return; } if (item == null) { return; } if (item.IsEquipment()) { GameInstance.ClientInventoryHandlers.RequestEquipItem( PlayerCharacterEntity, (short)itemIndex, ClientInventoryActions.ResponseEquipArmor, ClientInventoryActions.ResponseEquipWeapon); } else if (item.IsSkill()) { bool isAttackSkill = (item as ISkillItem).UsingSkill.IsAttack(); if (PlayerCharacterEntity.UseSkillItem((short)itemIndex, isLeftHandAttacking, SelectedEntityObjectId, aimPosition) && isAttackSkill) { isLeftHandAttacking = !isLeftHandAttacking; } } else if (item.IsBuilding()) { buildingItemIndex = itemIndex; ShowConstructBuildingDialog(); } else if (item.IsUsable()) { PlayerCharacterEntity.CallServerUseItem((short)itemIndex); } }