summaryrefslogtreecommitdiff
path: root/scripts/input/InventoryInputHandler.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-08 22:10:45 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-08 22:10:45 -0300
commitf1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (patch)
treed607142daee4948765a97008bdef21fa6efa2d2b /scripts/input/InventoryInputHandler.cs
parent4b2afd3e2144e42bfa7f11a870584b9255052cf7 (diff)
inventário acessivel
Diffstat (limited to 'scripts/input/InventoryInputHandler.cs')
-rw-r--r--scripts/input/InventoryInputHandler.cs65
1 files changed, 65 insertions, 0 deletions
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<PackedScene>("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<InventoryMenu>();
+ 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<InputHandler>().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