~ruther/NosSmooth

d4d8d8177fc1f1bff4888c3ecfa4ff794da61a08 — Rutherther 2 years ago 00e37b8
feat(game): update skills api to allow using skills on self (character)
1 files changed, 43 insertions(+), 1 deletions(-)

M Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs
M Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs => Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs +43 -1
@@ 20,14 20,17 @@ namespace NosSmooth.Game.Apis;
public class NostaleSkillsPacketApi
{
    private readonly INostaleClient _client;
    private readonly Game _game;

    /// <summary>
    /// Initializes a new instance of the <see cref="NostaleSkillsPacketApi"/> class.
    /// </summary>
    /// <param name="client">The nostale client.</param>
    public NostaleSkillsPacketApi(INostaleClient client)
    /// <param name="game">The game.</param>
    public NostaleSkillsPacketApi(INostaleClient client, Game game)
    {
        _client = client;
        _game = game;
    }

    /// <summary>


@@ 69,6 72,45 @@ public class NostaleSkillsPacketApi
    }

    /// <summary>
    /// Use the given (targetable) skill on character itself.
    /// </summary>
    /// <remarks>
    /// For skills that cannot be targeted on an entity, proceed to UseSkillAt.
    /// </remarks>
    /// <param name="castId">The cast id of the skill.</param>
    /// <param name="mapX">The x coordinate on the map. (Used for non targeted dashes etc., says where the dash will be to.)</param>
    /// <param name="mapY">The y coordinate on the map. (Used for non targeted dashes etc., says where the dash will be to.)</param>
    /// <param name="ct">The cancellation token for cancelling the operation.</param>
    /// <returns>A result that may or may not have succeeded.</returns>
    public async Task<Result> UseSkillOnCharacter
    (
        short castId,
        short? mapX = default,
        short? mapY = default,
        CancellationToken ct = default
    )
    {
        var character = _game.Character;
        if (character is null)
        {
            return new NotInitializedError("Character");
        }

        return await _client.SendPacketAsync
        (
            new UseSkillPacket
            (
                castId,
                EntityType.Player,
                character.Id,
                mapX,
                mapY
            ),
            ct
        );
    }

    /// <summary>
    /// Use the given (targetable) skill on specified entity.
    /// </summary>
    /// <remarks>

Do not follow this link