~ruther/NosSmooth

ref: 213fe53ae3a31d69b20543002b447347cf7893c0 NosSmooth/Extensions/NosSmooth.Extensions.Combat/Techniques/ICombatTechnique.cs -rw-r--r-- 2.7 KiB
213fe53a — Rutherther Merge pull request #81 from Rutherther/feat/pathfinding-mates 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
//
//  ICombatTechnique.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.Operations;
using Remora.Results;

namespace NosSmooth.Extensions.Combat.Techniques;

/// <summary>
/// A combat technique that allows to handle the whole combat situations using step callbacks.
/// </summary>
/// <remarks>
/// The callback methods decide the next steps, used in <see cref="CombatManager"/>.
/// </remarks>
public interface ICombatTechnique
{
    /// <summary>
    /// Gets the types this technique may handle.
    /// </summary>
    /// <remarks>
    /// <see cref="HandleNextCombatStep"/> will be called only for queue types
    /// from this collection.
    /// </remarks>
    public IReadOnlyList<OperationQueueType> HandlingQueueTypes { get; }

    /// <summary>
    /// Should check whether the technique should process more steps or quit the combat.
    /// </summary>
    /// <param name="state">The combat state.</param>
    /// <returns>Whether to continue with steps.</returns>
    public bool ShouldContinue(ICombatState state);

    /// <summary>
    /// Handle one step that should enqueue an operation.
    /// Enqueue only operation of the given queue type.
    /// </summary>
    /// <remarks>
    /// If error is returned, the combat will be cancelled.
    /// </remarks>
    /// <param name="queueType">The type of the operation to enqueue.</param>
    /// <param name="state">The combat state.</param>
    /// <returns>An id of the current target entity or an error.</returns>
    public Result<long?> HandleNextCombatStep(OperationQueueType queueType, ICombatState state);

    /// <summary>
    /// Handle waiting for an operation.
    /// </summary>
    /// <param name="queueType">The type of the operation.</param>
    /// <param name="state">The combat state.</param>
    /// <param name="operation">The operation that needs waiting.</param>
    /// <param name="error">The error received from the operation.</param>
    /// <returns>A result that may or may not have succeeded. In case of an error, <see cref="HandleError"/> will be called with the error.</returns>
    public Result HandleWaiting(OperationQueueType queueType, ICombatState state, ICombatOperation operation, CannotBeUsedError error);

    /// <summary>
    /// Handles an arbitrary error.
    /// </summary>
    /// <remarks>
    /// If an error is returned, the combat will be cancelled.
    /// </remarks>
    /// <param name="state">The combat state.</param>
    /// <param name="result">The errorful result.</param>
    /// <returns>A result that may or may not succeed.</returns>
    public Result HandleError(ICombatState state, Result result);
}
Do not follow this link