Files
AdamuSw/src/GameServer/MessageHandler/TalkNpcHandlerPlugInBase.cs

48 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// <copyright file="TalkNpcHandlerPlugInBase.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.GameServer.MessageHandler;
using MUnique.OpenMU.GameLogic;
using MUnique.OpenMU.GameLogic.NPC;
using MUnique.OpenMU.GameLogic.PlayerActions;
using MUnique.OpenMU.Network.Packets.ClientToServer;
/// <summary>
/// Handler for talk npc request packets.
/// </summary>
internal abstract class TalkNpcHandlerPlugInBase : IPacketHandlerPlugIn
{
/// <inheritdoc/>
public virtual bool IsEncryptionExpected => false;
/// <inheritdoc/>
public byte Key => TalkToNpcRequest.Code;
/// <summary>
/// Gets the talk NPC action.
/// </summary>
protected abstract TalkNpcAction TalkNpcAction { get; }
/// <inheritdoc/>
public async ValueTask HandlePacketAsync(Player player, Memory<byte> packet)
{
TalkToNpcRequest message = packet;
// ADAMU-CUSTOM: remote NPC ("NPC list" mobile feature). Object id'leri her zaman <= 0x7FFF
// (GameMap IdGenerator), o yüzden yüksek bit serbest marker. Set edilmişse alt 15 bit bir
// NPC *definition number*'dır — o NPC'nin penceresini konum/harita bağımsız aç.
if ((message.NpcId & 0x8000) != 0)
{
await this.TalkNpcAction.TalkToNpcByNumberAsync(player, (short)(message.NpcId & 0x7FFF)).ConfigureAwait(false);
return;
}
// ADAMU-CUSTOM end
if (player.CurrentMap?.GetObject(message.NpcId) is NonPlayerCharacter npc)
{
await this.TalkNpcAction.TalkToNpcAsync(player, npc).ConfigureAwait(false);
}
}
}