diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-04 16:58:58 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-04 16:58:58 -0300 |
| commit | 6f2c2edd52171a4df7f35de695c9b2e7801d3e5f (patch) | |
| tree | 509002136987182309a934623b19d19393e306e3 /scripts/entities/actors/actions | |
| parent | 9953c9a5818baa392a48a4d18339c73f3b7a814e (diff) | |
Preparação para itens
Diffstat (limited to 'scripts/entities/actors/actions')
| -rw-r--r-- | scripts/entities/actors/actions/BumpAction.cs | 2 | ||||
| -rw-r--r-- | scripts/entities/actors/actions/DirectionalAction.cs | 4 | ||||
| -rw-r--r-- | scripts/entities/actors/actions/MeleeAction.cs | 14 | ||||
| -rw-r--r-- | scripts/entities/actors/actions/MovementAction.cs | 4 |
4 files changed, 16 insertions, 8 deletions
diff --git a/scripts/entities/actors/actions/BumpAction.cs b/scripts/entities/actors/actions/BumpAction.cs index 805520c..bee202b 100644 --- a/scripts/entities/actors/actions/BumpAction.cs +++ b/scripts/entities/actors/actions/BumpAction.cs @@ -19,7 +19,7 @@ public partial class BumpAction : DirectionalAction Action action; // Se houver um ator no destino, crie uma ação de ataque. - if (GetTargetActor() != null) { + if (GetTarget() != null) { action = new MeleeAction(actor, Offset); } else { // Mas se não houver, crie uma ação de movimento. diff --git a/scripts/entities/actors/actions/DirectionalAction.cs b/scripts/entities/actors/actions/DirectionalAction.cs index ca2ca95..9c7a915 100644 --- a/scripts/entities/actors/actions/DirectionalAction.cs +++ b/scripts/entities/actors/actions/DirectionalAction.cs @@ -24,7 +24,7 @@ public abstract partial class DirectionalAction : Action /// Função que obtém o alvo da ação, se houver. /// </summary> /// <returns>O ator alvo da ação, nulo se não houver.</returns> - protected Actor GetTargetActor() { - return Map_Data.GetBlockingActorAtPosition(Destination); + protected Entity GetTarget() { + return Map_Data.GetBlockingEntityAtPosition(Destination); } } diff --git a/scripts/entities/actors/actions/MeleeAction.cs b/scripts/entities/actors/actions/MeleeAction.cs index b20430a..6dfeb78 100644 --- a/scripts/entities/actors/actions/MeleeAction.cs +++ b/scripts/entities/actors/actions/MeleeAction.cs @@ -15,7 +15,15 @@ public partial class MeleeAction : DirectionalAction public override void Perform() { // Eu te disse que este método seria útil. - Actor target = GetTargetActor(); + Entity potentialTarget = GetTarget(); + + // Só podemos atacar atores. + if (potentialTarget is not Actor) { + return; + } + + Actor target = (Actor)potentialTarget; + // Se não houver um ator na direção, não podemos continuar. // Isto é uma ação gratuita. @@ -24,13 +32,13 @@ public partial class MeleeAction : DirectionalAction // não podemos ter dano negativo. int damage = actor.Atk - target.Def; - string attackDesc = $"{actor.ActorName} ataca {target.ActorName}"; + string attackDesc = $"{actor.DisplayName} ataca {target.DisplayName}"; if (damage > 0) { attackDesc += $" e remove {damage} de HP."; target.Hp -= damage; } else { - attackDesc += $" mas {target.ActorName} tem músculos de aço."; + attackDesc += $" mas {target.DisplayName} tem músculos de aço."; } MessageLogData.Instance.AddMessage(attackDesc); diff --git a/scripts/entities/actors/actions/MovementAction.cs b/scripts/entities/actors/actions/MovementAction.cs index 3608357..2c394fc 100644 --- a/scripts/entities/actors/actions/MovementAction.cs +++ b/scripts/entities/actors/actions/MovementAction.cs @@ -12,11 +12,11 @@ public partial class MovementAction : DirectionalAction public override void Perform() { // Não anda se o destino for um tile sólido. - if (!Map_Data.IsTileWalkable(Destination)) return; + if (!Map_Data.GetTile(Destination).IsWalkable) return; // Não anda se o destino for oculpado por um ator. // Na maioria dos casos, essa condição nunca é verdadeira. - if (GetTargetActor() != null) return; + if (GetTarget() != null) return; actor.Walk(Offset); actor.Energy -= cost; |
