//
// WalkOperation.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using NosSmooth.Extensions.Combat.Errors;
using NosSmooth.Extensions.Pathfinding;
using Remora.Results;
namespace NosSmooth.Extensions.Combat.Operations;
///
/// A combat operation that walks to the target.
///
/// The walk manager.
/// The x coordinate to walk to.
/// The y coordinate to walk to.
public record WalkOperation(WalkManager WalkManager, short X, short Y) : ICombatOperation
{
///
public Result CanBeUsed(ICombatState combatState)
{
var character = combatState.Game.Character;
if (character is null)
{
return new CharacterNotInitializedError();
}
return character.CantMove ? CanBeUsedResponse.MustWait : CanBeUsedResponse.CanBeUsed;
}
///
public async Task UseAsync(ICombatState combatState, CancellationToken ct = default)
{
return await WalkManager.GoToAsync(X, Y, true, ct);
}
}