From 5dc905bc801df41fdd2146ad4dfd47be6acbab22 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 30 Dec 2022 19:52:05 +0100 Subject: [PATCH] feat(game): respond to skill use packet sent from the client to set cooldown early --- .../Entities/SkillUsedResponder.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs b/Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs index 6ca7117..6ee25da 100644 --- a/Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs +++ b/Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs @@ -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; /// /// Responds to skill used packet. /// -public class SkillUsedResponder : IPacketResponder, IPacketResponder +public class SkillUsedResponder : IPacketResponder, IPacketResponder, + IPacketResponder { private readonly Game _game; private readonly EventDispatcher _eventDispatcher; @@ -168,4 +170,23 @@ public class SkillUsedResponder : IPacketResponder, IPacketResponder + public async Task Respond(PacketEventArgs 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 -- 2.49.0