using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using RPGCreationKit; using RPGCreationKit.AI; namespace RPGCreationKit { public class ArmorItemInLootingUI_DrawDeposit : ArmorItemInInventoryUI { public override void OnClick(bool takeAll = false) { if (LootingInventoryUI.instance.curIsPickPocket) { // Player is attempting to pickpocket // This is a VERY simple rule, if the weight of the item is over 1 the player will never be able to successfully pickpocket it // You may want to change/alter this for your own projects float chanceForFailure = armorItemInInventory.item.Weight; // Could use Vector3.Dot to make less likely to succeed when infront of the AI if (chanceForFailure > Random.value) { // Failed chance check RckAI ai = LootingInventoryUI.instance.curLootingPoint.GetComponent(); ai.TryEngageWithPlayer(); // Engage with player LootingInventoryUI.instance.CloseUI(); return; } } // Some palce in the codebase seems to be calling this method after the CloseUI randomly, not sure why or where yet // this is a backup in that case if (LootingInventoryUI.instance.curIsPickPocket && LootingInventoryUI.instance.curLootingPoint == null) { return; } if (LootingInventoryUI.instance.isDrawing) { // if the amount is 1, add it one time if (base.armorItemInInventory.Amount <= 1) { Inventory.PlayerInventory.AddItem(base.armorItemInInventory.item, base.armorItemInInventory.metadata, 1, !takeAll); if(base.armorItemInInventory.isEquipped) LootingInventoryUI.instance.curLootingPoint.equipment.Unequip(base.armorItemInInventory); // Remove the item from the current loot inventory LootingInventoryUI.instance.curLootingPoint.inventory.RemoveItem(base.armorItemInInventory, 1); LootingInventoryUI.instance.SelectNextButton(); // Disable this object pool.usedObjects.Remove(this); pool.ArmorsPool.usedObjects.Remove(this); gameObject.GetComponent