From 539fd4820f37aa54df8878091db9680d89ee027a Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 13 Sep 2025 11:06:46 -0300 Subject: pergaminho --- scripts/Entities/Actions/SpellAction.cs | 33 +++++++++++++++++++++++++++++ scripts/Entities/Actions/SpellAction.cs.uid | 1 + 2 files changed, 34 insertions(+) create mode 100644 scripts/Entities/Actions/SpellAction.cs create mode 100644 scripts/Entities/Actions/SpellAction.cs.uid (limited to 'scripts/Entities/Actions') diff --git a/scripts/Entities/Actions/SpellAction.cs b/scripts/Entities/Actions/SpellAction.cs new file mode 100644 index 0000000..086a52a --- /dev/null +++ b/scripts/Entities/Actions/SpellAction.cs @@ -0,0 +1,33 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Magic; + +namespace TheLegendOfGustav.Entities.Actions; + +public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource spell) : DirectionalAction(actor, offset) +{ + private SpellResource spell = spell; + + public override bool Perform() + { + Actor target = null; + + if (GetTarget() is Actor actor) + { + target = actor; + } + + if (spell.Type == SpellType.Ranged && target == null) return false; + + if (Actor.Mp < spell.Cost) + { + return false; + } + + foreach (SpellEffect effect in spell.Effects) + { + effect.Apply(Actor, target); + } + return true; + } +} diff --git a/scripts/Entities/Actions/SpellAction.cs.uid b/scripts/Entities/Actions/SpellAction.cs.uid new file mode 100644 index 0000000..6f85025 --- /dev/null +++ b/scripts/Entities/Actions/SpellAction.cs.uid @@ -0,0 +1 @@ +uid://b18wblvggpev0 -- cgit v1.2.3