From 6842ccfd372601db6b5d3f678ab5ebf03ad2b206 Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 2 Sep 2025 12:50:09 -0300 Subject: Adicionado entidade Inspetor. --- scripts/input/InspectInputHandler.cs | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 scripts/input/InspectInputHandler.cs (limited to 'scripts/input/InspectInputHandler.cs') diff --git a/scripts/input/InspectInputHandler.cs b/scripts/input/InspectInputHandler.cs new file mode 100644 index 0000000..60c10e4 --- /dev/null +++ b/scripts/input/InspectInputHandler.cs @@ -0,0 +1,59 @@ +using Godot; + +/// +/// TODO: Esta solução é nojenta e precisa ser retrabalhada. +/// +public partial class InspectInputHandler : BaseInputHandler +{ + private readonly Godot.Collections.Dictionary directions = new() + { + {"walk-up", Vector2I.Up}, + {"walk-down", Vector2I.Down}, + {"walk-left", Vector2I.Left}, + {"walk-right", Vector2I.Right}, + {"walk-up-right", Vector2I.Up + Vector2I.Right}, + {"walk-up-left", Vector2I.Up + Vector2I.Left}, + {"walk-down-right", Vector2I.Down + Vector2I.Right}, + {"walk-down-left", Vector2I.Down + Vector2I.Left}, + }; + /// + /// Preciso disso + /// + [Export] + private Map map; + + private Inspector inspector; + + public override void Enter() { + inspector = new(map.Map_Data.Player.GridPosition) + { + ZIndex = 4 + }; + // Copiamos a câmera do jogador com todas as suas configurações + Camera2D camera = (Camera2D) map.Map_Data.Player.GetNode("Camera2D").Duplicate(); + inspector.AddChild(camera); + + map.AddChild(inspector); + camera.Enabled = true; + camera.MakeCurrent(); + } + + public override void Exit() { + inspector.QueueFree(); + } + public override Action GetAction(Player player) + { + Action action = null; + foreach (var direction in directions) { + if (Input.IsActionJustPressed(direction.Key)) { + inspector.Walk(direction.Value); + } + } + + if (Input.IsActionJustPressed("quit")) { + GetParent().SetInputHandler(InputHandlers.MainGame); + } + + return action; + } +} \ No newline at end of file -- cgit v1.2.3