private void InteractWithItemObject(ItemObject itemObject) { Debug.Assert(itemObject.Item != null); IUsable usable = itemObject.Item as IUsable; IPickupable pickupable = itemObject.Item as IPickupable; IEquipable equipable = itemObject.Item as IEquipable; IStackable stackable = itemObject.Item as IStackable; if (usable != null) { usable.OnUse(_stats, itemObject); } else if (pickupable != null) { if (equipable != null && equipable.IsDurable && _equipment.EquipmentTable[equipable.EquipmentType].IsEmpty) { equipable.OnEquip(_equipment, _stats); } else if (stackable != null) { stackable.OnStack(_inventory); } else { pickupable.OnPutInInventory(_inventory); } pickupable.OnRemoveFromGround(itemObject); } }
private void ReturnAirItem(object[] eventParams) { if (_airItem.IsEmpty) { return; } SlotPosition originalPosition = _airItem.OriginalPosition; Item itemAir = _airItem.Item; IPickupable pickupableAir = itemAir as IPickupable; IEquipable equipableAir = itemAir as IEquipable; IStackable stackableAir = itemAir as IStackable; pickupableAir.OnRemoveFromAir(_airItem); if (originalPosition.RowIndex == EquipmentSlot.EQUIPMENT_SLOT_ROW_INDEX) { Equipment.EquipmentType equipmentType = (Equipment.EquipmentType)originalPosition.SlotIndex; if (_equipment.EquipmentTable[equipmentType].IsEmpty) { equipableAir.OnEquip(_equipment, _stats); } else { pickupableAir.OnPutInInventory(_inventory); } } else { if (stackableAir != null) { stackableAir.OnStack(_inventory, originalPosition); } else if (_inventory.IsItemEmpty(originalPosition)) { pickupableAir.OnPutInInventory(_inventory, originalPosition); } else { pickupableAir.OnPutInInventory(_inventory); } } }