extends Node class_name PlayerInventory @export var action : PlayerAction @export var machette_pivot : Node2D @export var bow : Node2D @export var bow_cooldown : float = 0.35 @export var machette : Node2D @export var machette_cooldown : float = 0.2 @export var masks : Array[Node2D] enum MaskType { Dash = 0, Grapple = 1, Freeze = 3, Minions = 2, } var prev_inv : Array[int] = [-1, -1, -1, -1, -1, -1] @export var mask_inventory : Array[int] = [-1, -1, -1, -1, -1, -1] var has_machette : bool = false var using_bow : bool = true func _ready(): UIConnector.update_masks(mask_inventory) func _input(_event: InputEvent) -> void: if Input.is_action_just_pressed("switch_tool") && has_machette: UIConnector.switch_tool() if using_bow: action.curr_weapon = machette machette_pivot.visible = true bow.visible = false machette.process_mode = Node.PROCESS_MODE_INHERIT bow.process_mode = Node.PROCESS_MODE_DISABLED action.get_node("Cooldown").wait_time = machette_cooldown else: action.curr_weapon = bow machette_pivot.visible = false bow.visible = true machette.process_mode = Node.PROCESS_MODE_DISABLED bow.process_mode = Node.PROCESS_MODE_INHERIT action.get_node("Cooldown").wait_time = bow_cooldown using_bow = !using_bow if Input.is_action_just_pressed("switch_mask"): var curr_mask = mask_inventory[0] mask_inventory[0] = mask_inventory[1] mask_inventory[1] = curr_mask UIConnector.update_masks(mask_inventory) $"../PlayerMovement".grapple_velocity = Vector2.ZERO func _process(_delta: float) -> void: if prev_inv.hash() != mask_inventory.hash(): print("changed") for mask in masks: mask.visible = false mask.process_mode = Node.PROCESS_MODE_DISABLED if mask_inventory[0] != -1: print("YEAH") masks[mask_inventory[0]].visible = true masks[mask_inventory[0]].process_mode = Node.PROCESS_MODE_INHERIT prev_inv = mask_inventory.duplicate() func give_machette() -> void: has_machette = true UIConnector.add_machette() func ungive_machette() -> void: has_machette = false UIConnector.remove_machette() func add_mask(mask : MaskType): print("the mask is ", mask) if !(mask in mask_inventory): for i in range(2, 6): if mask_inventory[i] == -1: mask_inventory[i] = mask break UIConnector.update_masks(mask_inventory) UIConnector.show_mask_bubble()