From c6bbb834f7758027c0df338f1520f34fad3befea Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 9 Sep 2025 19:09:34 -0300 Subject: Organização MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Entities/Items/ConsumableItem.cs | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/Entities/Items/ConsumableItem.cs (limited to 'scripts/Entities/Items/ConsumableItem.cs') diff --git a/scripts/Entities/Items/ConsumableItem.cs b/scripts/Entities/Items/ConsumableItem.cs new file mode 100644 index 0000000..f70983a --- /dev/null +++ b/scripts/Entities/Items/ConsumableItem.cs @@ -0,0 +1,40 @@ +using Godot; +using TheLegendOfGustav.Entities.Actions; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Items; + +/// +/// Classe para itens consumíveis. +/// Itens consumíveis são itens de uso limitado. +/// +public abstract partial class ConsumableItem(Vector2I initialPosition, MapData map, EntityDefinition definition) : Entity(initialPosition, map, definition) +{ + + /// + /// Gera uma ação onde o ator consome o item. + /// + /// + /// + public Action GetAction(Player consumer) + { + return new ItemAction(consumer, this); + } + + /// + /// Ativa a função deste item. + /// Este método é chamado pela ação gerada por ele mesmo. + /// Este método permite definir condições para a sua ativação. + /// + /// Ação gerada pelo item. + /// Se a ação foi realizada ou não. + public abstract bool Activate(ItemAction action); + + public void ConsumedBy(Player consumer) + { + Inventory inventory = consumer.Inventory; + inventory.RemoveItem(this); + QueueFree(); + } +} \ No newline at end of file -- cgit v1.2.3