From 1e17a31e3eeed8ccf76982534002513cee6593f1 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 14 Sep 2025 10:41:08 -0300 Subject: Magicas --- scripts/Entities/Items/GrimoireConsumable.cs | 22 ++++++++++++++++++++++ scripts/Entities/Items/GrimoireConsumable.cs.uid | 1 + .../Entities/Items/GrimoireConsumableDefinition.cs | 11 +++++++++++ .../Items/GrimoireConsumableDefinition.cs.uid | 1 + 4 files changed, 35 insertions(+) create mode 100644 scripts/Entities/Items/GrimoireConsumable.cs create mode 100644 scripts/Entities/Items/GrimoireConsumable.cs.uid create mode 100644 scripts/Entities/Items/GrimoireConsumableDefinition.cs create mode 100644 scripts/Entities/Items/GrimoireConsumableDefinition.cs.uid (limited to 'scripts/Entities/Items') diff --git a/scripts/Entities/Items/GrimoireConsumable.cs b/scripts/Entities/Items/GrimoireConsumable.cs new file mode 100644 index 0000000..e5157a7 --- /dev/null +++ b/scripts/Entities/Items/GrimoireConsumable.cs @@ -0,0 +1,22 @@ +using Godot; +using TheLegendOfGustav.Entities.Actions; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Magic; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Items; + +public partial class GrimoireConsumable(Vector2I initialPosition, MapData map, GrimoireConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition) +{ + private SpellResource spell = definition.Spell; + + public override bool Activate(ItemAction action) + { + Player consumer = action.Player; + + consumer.SpellBook.LearnSpell(spell); + + ConsumedBy(consumer); + return true; + } +} \ No newline at end of file diff --git a/scripts/Entities/Items/GrimoireConsumable.cs.uid b/scripts/Entities/Items/GrimoireConsumable.cs.uid new file mode 100644 index 0000000..2d56832 --- /dev/null +++ b/scripts/Entities/Items/GrimoireConsumable.cs.uid @@ -0,0 +1 @@ +uid://cdk0yd56njql0 diff --git a/scripts/Entities/Items/GrimoireConsumableDefinition.cs b/scripts/Entities/Items/GrimoireConsumableDefinition.cs new file mode 100644 index 0000000..4b041c1 --- /dev/null +++ b/scripts/Entities/Items/GrimoireConsumableDefinition.cs @@ -0,0 +1,11 @@ +using Godot; +using TheLegendOfGustav.Magic; + +namespace TheLegendOfGustav.Entities.Items; + +[GlobalClass] +public partial class GrimoireConsumableDefinition : ConsumableItemDefinition +{ + [Export] + public SpellResource Spell { get; set; } +} \ No newline at end of file diff --git a/scripts/Entities/Items/GrimoireConsumableDefinition.cs.uid b/scripts/Entities/Items/GrimoireConsumableDefinition.cs.uid new file mode 100644 index 0000000..97ad272 --- /dev/null +++ b/scripts/Entities/Items/GrimoireConsumableDefinition.cs.uid @@ -0,0 +1 @@ +uid://blkth0in1fp74 -- cgit v1.2.3