From 93268228b1307f6b895b706baf88aa6ff8cee498 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 18 Feb 2022 23:32:58 +0100 Subject: [PATCH] feat(combat): add responders for cancelling combat attack --- .../Responders/CancelResponder.cs | 35 +++++++++++++++++++ .../Responders/SuResponder.cs | 35 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 Extensions/NosSmooth.Extensions.Combat/Responders/CancelResponder.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Responders/SuResponder.cs diff --git a/Extensions/NosSmooth.Extensions.Combat/Responders/CancelResponder.cs b/Extensions/NosSmooth.Extensions.Combat/Responders/CancelResponder.cs new file mode 100644 index 0000000..33a85bd --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Responders/CancelResponder.cs @@ -0,0 +1,35 @@ +// +// CancelResponder.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.Core.Packets; +using NosSmooth.Packets.Server.Skills; +using Remora.Results; + +namespace NosSmooth.Extensions.Combat.Responders; + +/// +/// Responds to cancel packet. +/// +public class CancelResponder : IPacketResponder +{ + private readonly CombatManager _combatManager; + + /// + /// Initializes a new instance of the class. + /// + /// The combat manager. + public CancelResponder(CombatManager combatManager) + { + _combatManager = combatManager; + } + + /// + public Task Respond(PacketEventArgs packetArgs, CancellationToken ct = default) + { + _combatManager.CancelSkillTokens(); + return Task.FromResult(Result.FromSuccess()); + } +} \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Responders/SuResponder.cs b/Extensions/NosSmooth.Extensions.Combat/Responders/SuResponder.cs new file mode 100644 index 0000000..05190aa --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Responders/SuResponder.cs @@ -0,0 +1,35 @@ +// +// SuResponder.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.Core.Packets; +using NosSmooth.Packets.Server.Battle; +using Remora.Results; + +namespace NosSmooth.Extensions.Combat.Responders; + +/// +/// Responds to su packet. +/// +public class SuResponder : IPacketResponder +{ + private readonly CombatManager _combatManager; + + /// + /// Initializes a new instance of the class. + /// + /// The combat manager. + public SuResponder(CombatManager combatManager) + { + _combatManager = combatManager; + } + + /// + public Task Respond(PacketEventArgs packetArgs, CancellationToken ct = default) + { + _combatManager.CancelSkillTokens(); + return Task.FromResult(Result.FromSuccess()); + } +} \ No newline at end of file -- 2.49.0