~ruther/NosSmooth

57ffc54074eeba2d9b52412da5997d7efa3fdac8 — Rutherther 2 years ago ddaf090
feat(combat): prevent NotInRange error
1 files changed, 11 insertions(+), 3 deletions(-)

M Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs
M Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs => Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs +11 -3
@@ 12,6 12,7 @@ using NosSmooth.Extensions.Combat.Selectors;
using NosSmooth.Extensions.Pathfinding;
using NosSmooth.Game.Apis.Safe;
using NosSmooth.Game.Data.Entities;
using NosSmooth.Game.Errors;
using NosSmooth.Game.Extensions;
using Remora.Results;



@@ 83,13 84,13 @@ public class SimpleAttackTechnique : ICombatTechnique
    public Result HandleWaiting(OperationQueueType queueType, ICombatState state, ICombatOperation operation, CannotBeUsedError cannotBeUsedError)
    {
        if (cannotBeUsedError.UnderlyingError is TargetDeadError)
        {
        { // target is dead, that means exiting the technique. For that, remove the operation.
            state.RemoveCurrentOperation(queueType, true);
            return Result.FromSuccess();
        }

        if (cannotBeUsedError.Response == CanBeUsedResponse.WontBeUsable)
        {
        { // Unfortunately we cannot handle that error.
            return cannotBeUsedError;
        }



@@ 98,7 99,14 @@ public class SimpleAttackTechnique : ICombatTechnique

    /// <inheritdoc />
    public Result HandleError(ICombatState state, Result result)
    { // no handling of errors is done
    {
        if (result.Error is NotInRangeError)
        { // the entity has moved between WalkInRange and UseSkill operations. That is unlikely
          // but it's better to be sure in case that happens it gets solved
            state.RemoveCurrentOperation(OperationQueueType.TotalControl, true);
            return Result.FromSuccess();
        }

        return result;
    }


Do not follow this link