public override void Perform() { CallOnBegan(); Debug.LogError("AM I AN INTERACTION uunnnnnnEQUOPISD???!! " + IsInteraction); EquipmentSlotTypeOption slotopt = ActionOptions [0] as EquipmentSlotTypeOption; EquipmentSlotTypeChoice slotchoice = slotopt.chosenChoice as EquipmentSlotTypeChoice; EquipmentSlotType targetSlot = slotchoice.slotType; //if there's already an item on the slot, remove it, and get the slot it's currently on, and the item. Equipment unequipped = actor.CharSheet.PaperDoll.EquippedOn(targetSlot); if (unequipped != null) { Debug.LogError("unequipps"); actor.CharSheet.Unequip(unequipped); } actor.CharSheet.inventory.AddItem(unequipped); CallOnFinished(); }
public override void Perform() { CallOnBegan(); // Debug.LogError ("AM I AN INTERACTION EQUOPISD???!! " + IsInteraction); ItemsOnPersonOption itemopt = ActionOptions [0] as ItemsOnPersonOption; InventoryItemChoice itemchoice = itemopt.chosenChoice as InventoryItemChoice; Equipment equipment = itemchoice.item as Equipment; EquipmentSlotTypeOption slotopt = ActionOptions [1] as EquipmentSlotTypeOption; EquipmentSlotTypeChoice slotchoice = slotopt.chosenChoice as EquipmentSlotTypeChoice; EquipmentSlotType targetSlot = slotchoice.slotType; //if there's already an item on the slot, remove it, and get the slot it's currently on, and the item. Equipment unequipped = actor.CharSheet.PaperDoll.EquippedOn(targetSlot); if (unequipped != null) { actor.CharSheet.Unequip(unequipped); } if (actor.CharSheet.inventory.ListOfItems().Contains(itemchoice.item as Equipment)) { //then remove the item from inventory actor.CharSheet.inventory.RemoveItem(itemchoice.item); if (unequipped != null) { actor.CharSheet.inventory.AddItem(unequipped); } } else { //Assume the item is on the paper doll. EquipmentSlotType fromSlot = actor.CharSheet.PaperDoll.SlotFor(itemchoice.item as Equipment); actor.CharSheet.Unequip(itemchoice.item as Equipment); //try to equip the item unequipped on the fromSlot if (unequipped.FittingSlotTypes.Contains(fromSlot)) { actor.CharSheet.Equip(fromSlot, unequipped); } else { actor.CharSheet.inventory.AddItem(unequipped); } } actor.CharSheet.Equip(targetSlot, itemchoice.item as Equipment); CallOnFinished(); }