~ruther/NosSmooth

5dc905bc801df41fdd2146ad4dfd47be6acbab22 — Rutherther 2 years ago ce1faea
feat(game): respond to skill use packet sent from the client to set cooldown early
1 files changed, 22 insertions(+), 1 deletions(-)

M Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs
M Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs => Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs +22 -1
@@ 19,6 19,7 @@ using NosSmooth.Game.Events.Core;
using NosSmooth.Game.Events.Entities;
using NosSmooth.Game.Extensions;
using NosSmooth.Game.Helpers;
using NosSmooth.Packets.Client.Battle;
using NosSmooth.Packets.Server.Battle;
using NosSmooth.Packets.Server.Skills;
using Remora.Results;


@@ 28,7 29,8 @@ namespace NosSmooth.Game.PacketHandlers.Entities;
/// <summary>
/// Responds to skill used packet.
/// </summary>
public class SkillUsedResponder : IPacketResponder<SuPacket>, IPacketResponder<SrPacket>
public class SkillUsedResponder : IPacketResponder<SuPacket>, IPacketResponder<SrPacket>,
    IPacketResponder<UseSkillPacket>
{
    private readonly Game _game;
    private readonly EventDispatcher _eventDispatcher;


@@ 168,4 170,23 @@ public class SkillUsedResponder : IPacketResponder<SuPacket>, IPacketResponder<S

        return Result.FromSuccess();
    }

    /// <inheritdoc />
    public async Task<Result> Respond(PacketEventArgs<UseSkillPacket> packetArgs, CancellationToken ct = default)
    {
        var packet = packetArgs.Packet;
        var character = _game.Character;

        if (character is not null && character.Skills is not null)
        {
            var skillResult = character.Skills.TryGetSkillByVNum(packet.SkillId);

            if (skillResult.IsDefined(out var skillEntity))
            {
                skillEntity.IsOnCooldown = true;
            }
        }

        return Result.FromSuccess();
    }
}
\ No newline at end of file

Do not follow this link