mirror of
https://github.com/thebreaddev/Supercell.GUT.git
synced 2024-11-10 07:44:37 +00:00
281d2789ea
not finished. early wip state
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Supercell.GUT.Logic.Avatar;
|
|
using Supercell.GUT.Logic.Message.Avatar;
|
|
using Supercell.GUT.Server.Document;
|
|
using Supercell.GUT.Server.Network.Connection;
|
|
using Supercell.GUT.Server.Protocol.Attributes;
|
|
|
|
namespace Supercell.GUT.Server.Protocol.Handlers;
|
|
|
|
[ServiceNode(3)]
|
|
internal class AvatarMessageHandler : MessageHandlerBase
|
|
{
|
|
private readonly ILogger _logger;
|
|
private readonly ClientConnection _connection;
|
|
private readonly DocumentManager _documentManager;
|
|
|
|
public AvatarMessageHandler(ClientConnection connection, ILogger<AvatarMessageHandler> logger, DocumentManager documentManager)
|
|
{
|
|
_logger = logger;
|
|
_connection = connection;
|
|
_documentManager = documentManager;
|
|
}
|
|
|
|
[MessageHandler(10201)]
|
|
public async Task OnSelectAvatar(SelectAvatarMessage selectAvatarMessage)
|
|
{
|
|
await _documentManager.EnsureAvatarDocument();
|
|
LogicClientAvatar logicClientAvatar = _documentManager.AvatarDocument!.LogicClientAvatar;
|
|
|
|
if (logicClientAvatar.Id.LowerInt == 0)
|
|
{
|
|
_documentManager.AvatarDocument.SetId(_documentManager.AvatarDocument.DocumentId);
|
|
await _documentManager.SaveAsync();
|
|
}
|
|
|
|
_connection.LogicClientAvatar = logicClientAvatar;
|
|
|
|
await _connection.SendMessage(new AvatarDataMessage()
|
|
{
|
|
LogicClientAvatar = _connection.LogicClientAvatar
|
|
});
|
|
}
|
|
|
|
[MessageHandler(10210)]
|
|
public async Task OnTutorialProgressUpdate(TutorialProgressUpdateMessage tutorialProgressUpdateMessage)
|
|
{
|
|
_connection.LogicClientAvatar!.SetTutorialFlags(tutorialProgressUpdateMessage.TutorialFlags);
|
|
|
|
await _documentManager.SaveAsync();
|
|
}
|
|
|
|
[MessageHandler(10504)]
|
|
public async Task OnAskForFriendList(AskForFriendListMessage askForFriendListMessage)
|
|
{
|
|
await _connection.SendMessage(new FriendListMessage());
|
|
}
|
|
|
|
[MessageHandler(10503)]
|
|
public async Task OnAskForAddableFriends(AskForAddableFriendsMessage askForAddableFriendsMessage)
|
|
{
|
|
await _connection.SendMessage(new AddableFriendsMessage());
|
|
}
|
|
}
|