extends RefCounted class_name ItemSoaking const grapeScript = preload("res://Items/Foods/Fruits/Grape.gd") const mudScript = preload("res://Items/Natural/Mud.gd") const paperItemNames = ["Love Novel", "Love Tome", "Empty Sugar Packet", "Taxes"] const sugaryPaperItemNames = ["Sugar Packet", "Sugar Stick"] const paperMushScript = preload("res://Items/Paper/PaperMush.gd") static func soak_inventory(inventory:Inventory): var totalWetted = 0 var originalInventorySize = inventory.items.size() for i in range(originalInventorySize): var currentItemIndex = originalInventorySize - i - 1 var currentItem:Item = inventory.items[currentItemIndex] var newItem = wet_item(currentItem) if !newItem.equals(currentItem): totalWetted += inventory.quantities[currentItemIndex] inventory.items[currentItemIndex] = newItem for j in range(inventory.items.size()): if inventory.items[j].equals(newItem) and j != currentItemIndex: inventory.quantities[j] += inventory.quantities[currentItemIndex] inventory.items.remove_at(currentItemIndex) inventory.quantities.remove_at(currentItemIndex) break if totalWetted >= 100: AchievementManager.complete_achievement("Leaky Basket") static func wet_item(item:Item): var newItem:Item = item.duplicate() var itemName = item.get_name(false) var copyModifications = false if Item.modifications.Concentrated in newItem.itemModifications: newItem.remove_modification(Item.modifications.Concentrated) elif itemName == "Raisin": newItem = grapeScript.new() copyModifications = true elif itemName == "Dirt": newItem = mudScript.new() copyModifications = true elif itemName in paperItemNames: newItem = paperMushScript.new() copyModifications = true elif itemName in sugaryPaperItemNames: newItem = paperMushScript.new() newItem.set_modification(Item.modifications.Sugared) copyModifications = true elif !Item.modifications.Wet in newItem.itemModifications: newItem.set_modification(Item.modifications.Wet) if Item.modifications.Grubby in newItem.itemModifications: newItem.remove_modification(Item.modifications.Grubby) if copyModifications: for modification in item.itemModifications: newItem.set_modification(modification) return newItem