// // CMapResponder.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.Data.Abstractions; using NosSmooth.Packets.Server.Maps; using Remora.Results; namespace NosSmooth.Extensions.Pathfinding.Responders; /// internal class CMapResponder : IPacketResponder { private readonly PathfinderState _state; private readonly IInfoService _infoService; /// /// Initializes a new instance of the class. /// /// The state. /// The info service. public CMapResponder(PathfinderState state, IInfoService infoService) { _state = state; _infoService = infoService; } /// public async Task Respond(PacketEventArgs packetArgs, CancellationToken ct = default) { var packet = packetArgs.Packet; _state.MapId = packet.Id; var mapInfoResult = await _infoService.GetMapInfoAsync(packet.Id, ct); if (!mapInfoResult.IsSuccess) { return Result.FromError(mapInfoResult); } _state.MapInfo = mapInfoResult.Entity; return Result.FromSuccess(); } }