TigerEmu/Communication/Messages/Incoming/Navigator/NavigateEvent.cs

37 lines
1.1 KiB
C#
Raw Normal View History

2023-11-10 13:55:42 +00:00
using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.Navigator;
using Tiger.Communication.Messages.Types;
using Tiger.Game.Navigator;
using Tiger.Networking.Game.Sessions;
namespace Tiger.Communication.Messages.Incoming.Navigator;
public class NavigateEvent : IMessageEvent
{
private readonly INavigatorManager _navigatorManager;
public NavigateEvent(INavigatorManager navigatorManager)
{
_navigatorManager = navigatorManager;
}
public IncomingHeaders Header => IncomingHeaders.Navigate;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
if (gameSession.Habbo == null)
{
await gameSession.CloseAsync();
return;
}
var nodeMask = request.ReadWire() == 1;
var nodeId = request.ReadWire();
if (!_navigatorManager.NavigatorNodes.TryGetValue(nodeId, out var node))
{
return;
}
await gameSession.SendComposerAsync(new NavNodeInfoComposer(nodeMask, node));
}
}