diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
| commit | c6bbb834f7758027c0df338f1520f34fad3befea (patch) | |
| tree | 1818cd23c24be16fbe19b16dd0a510874d440d83 /scripts/Entities/Actions/PickUpAction.cs | |
| parent | f1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff) | |
Organização
Diffstat (limited to 'scripts/Entities/Actions/PickUpAction.cs')
| -rw-r--r-- | scripts/Entities/Actions/PickUpAction.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/Entities/Actions/PickUpAction.cs b/scripts/Entities/Actions/PickUpAction.cs new file mode 100644 index 0000000..0dbd672 --- /dev/null +++ b/scripts/Entities/Actions/PickUpAction.cs @@ -0,0 +1,51 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Utils; +using TheLegendOfGustav.Entities.Items; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actions; + +public partial class PickupAction : DirectionalAction +{ + private Player player; + + public PickupAction(Player player, Vector2I offset) : base(player, offset) + { + Player = player; + // Pegar itens requer um tempo menor. + Cost = 2; + } + + protected Player Player + { + get => player; + private set + { + player = value; + } + } + + public override bool Perform() + { + ConsumableItem item = MapData.GetFirstItemAtPosition(Destination); + + if (item == null) + { + MessageLogData.Instance.AddMessage("Não tem item aqui."); + return false; + } + + if (player.Inventory.Items.Count >= player.Inventory.Capacity) + { + MessageLogData.Instance.AddMessage("Seu inventário está cheio"); + return false; + } + + MapData.RemoveEntity(item); + player.Inventory.Add(item); + + player.Energy -= Cost; + return true; + } +}
\ No newline at end of file |
