server-master/srcs/_plugins/WingsEmu.Plugins.BasicImplementation/Shop/ShopPlayerCloseEventHandler.cs
2026-02-10 18:21:30 +01:00

35 lines
No EOL
1.1 KiB
C#

using System.Threading;
using System.Threading.Tasks;
using PhoenixLib.Events;
using WingsEmu.Game.Characters.Events;
using WingsEmu.Game.Extensions;
using WingsEmu.Game.Networking;
using WingsEmu.Game.Shops.Event;
namespace WingsEmu.Plugins.BasicImplementations.Shop;
public class ShopPlayerCloseEventHandler : IAsyncEventProcessor<ShopPlayerCloseEvent>
{
public async Task HandleAsync(ShopPlayerCloseEvent e, CancellationToken cancellation)
{
IClientSession session = e.Sender;
if (!session.PlayerEntity.HasShopOpened || !session.HasCurrentMapInstance)
{
return;
}
session.PlayerEntity.ShopComponent.RemoveShop();
session.PlayerEntity.HasShopOpened = false;
session.PlayerEntity.IsShopping = false;
session.BroadcastShop();
session.BroadcastPlayerShopFlag(0);
session.SendCondPacket();
await session.EmitEventAsync(new PlayerRestEvent
{
RestTeamMemberMates = false
});
await session.EmitEventAsync(new ShopClosedEvent());
}
}