ascnet/AscNet.GameServer/Handlers/PlayerModule.cs

56 lines
1.9 KiB
C#
Raw Normal View History

using AscNet.Common.MsgPack;
2023-11-11 07:28:21 +00:00
using MessagePack;
namespace AscNet.GameServer.Handlers
{
2023-11-13 12:33:51 +00:00
#region MsgPackScheme
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
2023-11-11 07:28:21 +00:00
[MessagePackObject(true)]
public class ChangePlayerMarkRequest
{
public long MaskId;
}
2023-11-13 12:33:51 +00:00
[MessagePackObject(true)]
public class ChangeCommunicationResponse
{
public int Code;
}
2023-11-14 02:18:00 +00:00
[MessagePackObject(true)]
public class ChangeCommunicationRequest
{
public long Id;
}
2023-11-13 12:33:51 +00:00
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#endregion
internal class PlayerModule
{
[RequestPacketHandler("ChangePlayerMarkRequest")]
public static void ChangePlayerMarkRequestHandler(Session session, Packet.Request packet)
{
2023-11-11 07:28:21 +00:00
ChangePlayerMarkRequest request = MessagePackSerializer.Deserialize<ChangePlayerMarkRequest>(packet.Content);
if (session.player.PlayerData.Marks is null)
{
session.log.Debug("Marks is somehow null");
session.player.PlayerData.Marks = new();
}
session.player.PlayerData.Marks.Add(request.MaskId);
session.SendResponse(new ChangePlayerMarkResponse(), packet.Id);
}
2023-11-13 12:33:51 +00:00
[RequestPacketHandler("ChangeCommunicationRequest")]
public static void ChangeCommunicationRequestHandler(Session session, Packet.Request packet)
{
2023-11-14 02:18:00 +00:00
ChangeCommunicationRequest request = MessagePackSerializer.Deserialize<ChangeCommunicationRequest>(packet.Content);
session.player.PlayerData.Communications.Add(request.Id);
2023-11-13 12:33:51 +00:00
session.SendResponse(new ChangeCommunicationResponse(), packet.Id);
}
}
}