~ruther/NosSmooth

ref: 3a690ba9750370c19c9612c8ef29132ab416acb2 NosSmooth/Extensions/NosSmooth.Extensions.Combat/Extensions/CombatStateExtensions.cs -rw-r--r-- 2.9 KiB
3a690ba9 — Rutherther Merge pull request #32 from Rutherther/combat 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
//  CombatStateExtensions.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.Combat.Operations;
using NosSmooth.Extensions.Combat.Policies;
using NosSmooth.Extensions.Pathfinding;
using NosSmooth.Game.Data.Characters;
using NosSmooth.Game.Data.Entities;
using NosSmooth.Game.Data.Items;
using OneOf.Types;
using Remora.Results;

namespace NosSmooth.Extensions.Combat.Extensions;

/// <summary>
/// Extension methods for <see cref="ICombatState"/>.
/// </summary>
public static class CombatStateExtensions
{
    /// <summary>
    /// Walk in the range of the given entity.
    /// </summary>
    /// <param name="state">The combat state.</param>
    /// <param name="walkManager">The walk manager.</param>
    /// <param name="entity">The entity.</param>
    /// <param name="range">The range distance to walk to.</param>
    public static void WalkInRange
    (
        this ICombatState state,
        WalkManager walkManager,
        IEntity entity,
        float range
    )
    {
        state.EnqueueOperation(new WalkInRangeOperation(walkManager, entity, range));
    }

    /// <summary>
    /// Walk to the given position.
    /// </summary>
    /// <param name="combatState">The combat state.</param>
    /// <param name="walkManager">The walk manager.</param>
    /// <param name="x">The target x coordinate.</param>
    /// <param name="y">The target y coordinate.</param>
    public static void WalkTo
    (
        this ICombatState combatState,
        WalkManager walkManager,
        short x,
        short y
    )
    {
        combatState.EnqueueOperation(new WalkOperation(walkManager, x, y));
    }

    /// <summary>
    /// Use the given skill.
    /// </summary>
    /// <param name="combatState">The combat state.</param>
    /// <param name="skill">The skill.</param>
    /// <param name="target">The target to use skill at.</param>
    public static void UseSkill(this ICombatState combatState, Skill skill, ILivingEntity target)
    {
        combatState.EnqueueOperation(new UseSkillOperation(skill, target));
    }

    /// <summary>
    /// Use primary skill.
    /// </summary>
    /// <param name="combatState">The combat state.</param>
    /// <param name="target">The target to use skill at.</param>
    public static void UsePrimarySkill(this ICombatState combatState, ILivingEntity target)
    {
        combatState.EnqueueOperation(new UsePrimarySkillOperation(target));
    }

    /// <summary>
    /// Use the given item.
    /// </summary>
    /// <param name="combatState">The combat state.</param>
    /// <param name="item">The item to use.</param>
    public static void UseItem(this ICombatState combatState, Item item)
    {
        combatState.EnqueueOperation(new UseItemOperation(item));
    }
}
Do not follow this link