~ruther/NosSmooth

ref: 2043a7d79fee86f80765ba9a785c09ef5aefa62c NosSmooth/Extensions/NosSmooth.Extensions.Combat/Operations/ICombatOperation.cs -rw-r--r-- 2.8 KiB
2043a7d7 — František Boháček docs: add missing documentation 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
//  ICombatOperation.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.Core.Contracts;
using NosSmooth.Extensions.Combat.Techniques;
using Remora.Results;

namespace NosSmooth.Extensions.Combat.Operations;

/// <summary>
/// A combat operation used in <see cref="ICombatTechnique"/> that can be used as one step.
/// </summary>
public interface ICombatOperation : IDisposable
{
    // 1. wait for CanBeUsed
    // 2. use OnlyExecute
    // 3. periodically check IsFinished
    // 4. Finished
    // 5. Call Dispose
    // 6. Go to next operation in queue
    // go to step 1

    /// <summary>
    /// Gets the queue type the operation belongs to.
    /// </summary>
    /// <remarks>
    /// Used for distinguishing what operations may run simultaneously.
    /// For example items may be used simultaneous to attacking. Attacking
    /// may not be simultaneous to walking.
    /// </remarks>
    public OperationQueueType QueueType { get; }

    /// <summary>
    /// Begin the execution without waiting for the finished state.
    /// </summary>
    /// <param name="combatState">The combat state.</param>
    /// <param name="ct">The cancellation token used for cancelling the operation.</param>
    /// <returns>A result that may or may not have succeeded.</returns>
    public Task<Result> BeginExecution(ICombatState combatState, CancellationToken ct = default);

    /// <summary>
    /// Asynchronously wait for finished state.
    /// </summary>
    /// <param name="combatState">The combat state.</param>
    /// <param name="ct">The cancellation token used for cancelling the operation.</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public Task<Result> WaitForFinishedAsync(ICombatState combatState, CancellationToken ct = default);

    /// <summary>
    /// Checks whether the operation is currently being executed.
    /// </summary>
    /// <returns>Whether the operation is being executed.</returns>
    public bool IsExecuting();

    /// <summary>
    /// Checks whether the operation is done.
    /// </summary>
    /// <returns>Whether the operation is finished.</returns>
    public bool IsFinished();

    /// <summary>
    /// Checks whether the operation can currently be used.
    /// </summary>
    /// <remarks>
    /// Ie. if the operation is to use a skill, it will return true only if the skill is not on a cooldown,
    /// the character has enough mana and is not stunned.
    /// </remarks>
    /// <param name="combatState">The combat state.</param>
    /// <returns>Whether the operation can be used right away.</returns>
    public Result<CanBeUsedResponse> CanBeUsed(ICombatState combatState);
}
Do not follow this link