2024-03-05 10:37:18 +00:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Supercell.GUT.Logic.Avatar;
|
|
|
|
|
using Supercell.GUT.Logic.Message.Avatar;
|
2024-03-06 15:00:12 +00:00
|
|
|
|
using Supercell.GUT.Server.Document;
|
2024-03-05 10:37:18 +00:00
|
|
|
|
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;
|
2024-03-06 15:00:12 +00:00
|
|
|
|
private readonly DocumentManager _documentManager;
|
2024-03-05 10:37:18 +00:00
|
|
|
|
|
2024-03-06 15:00:12 +00:00
|
|
|
|
public AvatarMessageHandler(ClientConnection connection, ILogger<AvatarMessageHandler> logger, DocumentManager documentManager)
|
2024-03-05 10:37:18 +00:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_connection = connection;
|
2024-03-06 15:00:12 +00:00
|
|
|
|
_documentManager = documentManager;
|
2024-03-05 10:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MessageHandler(10201)]
|
|
|
|
|
public async Task OnSelectAvatar(SelectAvatarMessage selectAvatarMessage)
|
|
|
|
|
{
|
2024-03-06 15:00:12 +00:00
|
|
|
|
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;
|
2024-03-05 10:37:18 +00:00
|
|
|
|
|
|
|
|
|
await _connection.SendMessage(new AvatarDataMessage()
|
|
|
|
|
{
|
2024-03-06 15:00:12 +00:00
|
|
|
|
LogicClientAvatar = _connection.LogicClientAvatar
|
2024-03-05 10:37:18 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2024-03-06 15:00:12 +00:00
|
|
|
|
|
|
|
|
|
[MessageHandler(10210)]
|
|
|
|
|
public async Task OnTutorialProgressUpdate(TutorialProgressUpdateMessage tutorialProgressUpdateMessage)
|
|
|
|
|
{
|
2024-03-06 15:52:53 +00:00
|
|
|
|
// _connection.LogicClientAvatar!.SetTutorialFlags(tutorialProgressUpdateMessage.TutorialFlags);
|
2024-03-06 15:00:12 +00:00
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
2024-03-05 10:37:18 +00:00
|
|
|
|
}
|