extends Window @onready var inventoryItemDisplayer = %Inventory var itemTransitionScene = preload("res://UI/Sugaring/ItemFadeTransition.tscn") var risingAnimPosition = Vector2(160, 360) var holeInventory:Inventory func _ready(): inventoryItemDisplayer.fiveButtons = true inventoryItemDisplayer.allButtons = true inventoryItemDisplayer.buttonPressed.connect(grab_item) inventoryItemDisplayer.fiveButtonPressed.connect(grab_item.bind(5)) inventoryItemDisplayer.allButtonPressed.connect(grab_item.bind(999999)) func opened(): get_tree().paused = true holeInventory = InventoryManager.get_inventory("HoleInventory") inventoryItemDisplayer.inventory = filter_inventory(holeInventory) inventoryItemDisplayer.update_display() func grab_item(item:Item, quantity:int = 1): var itemsInInv = InventoryManager.get_item_count(item, "HoleInventory") if itemsInInv < quantity: quantity = itemsInInv if quantity <= 0: return InventoryManager.remove_item_from_inventory(item, quantity, "HoleInventory") InventoryManager.add_item_to_inventory(item, quantity) grab_item_animation(item) inventoryItemDisplayer.inventory = filter_inventory(holeInventory) inventoryItemDisplayer.update_display() func grab_item_animation(item): var riseAnimation = preload("res://UI/BeachHole/ItemRisingTransition.tscn").instantiate() riseAnimation.start_transition(item.get_sprite()) riseAnimation.position = risingAnimPosition add_child(riseAnimation) func filter_inventory(inventory): var filteredInv:Inventory = inventory.duplicate() return filteredInv func _on_leave_button_pressed(): get_tree().paused = false hide()