diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-13 11:06:46 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-13 11:06:46 -0300 |
| commit | 539fd4820f37aa54df8878091db9680d89ee027a (patch) | |
| tree | 41f9f5d6aa123058e3549c1baba4155fa5a85279 /scripts/Entities/Actions | |
| parent | b8962990ddb75b874a49c83d8eeaba7b7e45c196 (diff) | |
pergaminho
Diffstat (limited to 'scripts/Entities/Actions')
| -rw-r--r-- | scripts/Entities/Actions/SpellAction.cs | 33 | ||||
| -rw-r--r-- | scripts/Entities/Actions/SpellAction.cs.uid | 1 |
2 files changed, 34 insertions, 0 deletions
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 |
