From f1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 8 Sep 2025 22:10:45 -0300 Subject: inventário acessivel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/input/InventoryInputHandler.cs | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 scripts/input/InventoryInputHandler.cs (limited to 'scripts/input/InventoryInputHandler.cs') diff --git a/scripts/input/InventoryInputHandler.cs b/scripts/input/InventoryInputHandler.cs new file mode 100644 index 0000000..98f8576 --- /dev/null +++ b/scripts/input/InventoryInputHandler.cs @@ -0,0 +1,65 @@ +using Godot; + +public partial class InventoryInputHandler : BaseInputHandler +{ + private static readonly PackedScene inventoryScene = GD.Load("res://scenes/GUI/invetory_menu.tscn"); + + private InventoryMenu inventoryMenu; + + ConsumableItem activationItem = null; + ConsumableItem dropItem = null; + + [Export] + private Map map; + + public override void Enter() { + inventoryMenu = inventoryScene.Instantiate(); + map.Map_Data.Player.AddChild(inventoryMenu); + inventoryMenu.Initialize(map.Map_Data.Player.inventory); + inventoryMenu.ItemSelected += OnItemActivate; + inventoryMenu.ItemDrop += OnItemDrop; + } + + public override void Exit() { + activationItem = null; + dropItem = null; + inventoryMenu.QueueFree(); + } + + public override Action GetAction(Player player) + { + Action action = null; + + if (activationItem != null) { + action = new ItemAction(player, activationItem); + Close(); + } + + if (dropItem != null) { + action = new DropAction(player, dropItem); + Close(); + } + + if (Input.IsActionJustPressed("quit")) { + Close(); + } + + return action; + } + + private void Close() { + GetParent().SetInputHandler(InputHandlers.MainGame); + } + + private void ActivateItem() { + + } + + private void OnItemActivate(ConsumableItem item) { + activationItem = item; + } + + private void OnItemDrop(ConsumableItem item) { + dropItem = item; + } +} \ No newline at end of file -- cgit v1.2.3