protected void UseSkill(string id, Vector3?aimPosition) { BaseSkill skill = null; short skillLevel = 0; if (!GameInstance.Skills.TryGetValue(BaseGameData.MakeDataId(id), out skill) || skill == null || !PlayerCharacterEntity.GetCaches().Skills.TryGetValue(skill, out skillLevel)) { return; } bool isAttackSkill = skill.IsAttack(); if (!aimPosition.HasValue) { if (PlayerCharacterEntity.RequestUseSkill(skill.DataId, isLeftHandAttacking) && isAttackSkill) { // Requested to use attack skill then change attacking hand isLeftHandAttacking = !isLeftHandAttacking; } } else { if (PlayerCharacterEntity.RequestUseSkill(skill.DataId, isLeftHandAttacking, aimPosition.Value) && isAttackSkill) { // Requested to use attack skill then change attacking hand isLeftHandAttacking = !isLeftHandAttacking; } } }
protected void UseSkill(string id, AimPosition aimPosition) { BaseSkill skill; if (!GameInstance.Skills.TryGetValue(BaseGameData.MakeDataId(id), out skill) || skill == null || !PlayerCharacterEntity.GetCaches().Skills.TryGetValue(skill, out _)) { return; } bool isAttackSkill = skill.IsAttack(); if (PlayerCharacterEntity.UseSkill(skill.DataId, isLeftHandAttacking, SelectedEntityObjectId, aimPosition) && isAttackSkill) { isLeftHandAttacking = !isLeftHandAttacking; } }
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); } }