2024-02-11 22:23:13 +00:00
|
|
|
|
using Core.Config;
|
|
|
|
|
using GameServer.Controllers.Attributes;
|
2024-02-09 22:15:05 +00:00
|
|
|
|
using GameServer.Models;
|
|
|
|
|
using GameServer.Network;
|
|
|
|
|
using GameServer.Network.Messages;
|
2024-02-10 16:04:03 +00:00
|
|
|
|
using GameServer.Systems.Event;
|
2024-02-09 22:15:05 +00:00
|
|
|
|
using Protocol;
|
|
|
|
|
|
|
|
|
|
namespace GameServer.Controllers;
|
|
|
|
|
internal class RoleController : Controller
|
|
|
|
|
{
|
|
|
|
|
public RoleController(PlayerSession session) : base(session)
|
|
|
|
|
{
|
2024-02-10 11:51:20 +00:00
|
|
|
|
// RoleController.
|
2024-02-09 22:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[GameEvent(GameEventType.EnterGame)]
|
2024-02-11 22:23:13 +00:00
|
|
|
|
public async Task OnEnterGame(ModelManager modelManager, ConfigManager configManager)
|
2024-02-09 22:15:05 +00:00
|
|
|
|
{
|
|
|
|
|
PlayerModel player = modelManager.Player;
|
|
|
|
|
|
|
|
|
|
await Session.Push(MessageId.PbGetRoleListNotify, new PbGetRoleListNotify
|
|
|
|
|
{
|
|
|
|
|
RoleList =
|
|
|
|
|
{
|
2024-02-11 22:23:13 +00:00
|
|
|
|
configManager.GetCollection(ConfigType.RoleInfo)
|
|
|
|
|
.Enumerate<RoleInfoConfig>()
|
|
|
|
|
.Select(config => new roleInfo
|
2024-02-09 22:15:05 +00:00
|
|
|
|
{
|
2024-02-11 22:23:13 +00:00
|
|
|
|
RoleId = config.Id,
|
2024-02-10 22:28:35 +00:00
|
|
|
|
Level = 1
|
|
|
|
|
})
|
2024-02-09 22:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-10 22:28:35 +00:00
|
|
|
|
[NetEvent(MessageId.SwitchRoleRequest)]
|
2024-02-17 13:49:28 +00:00
|
|
|
|
public async Task<ResponseMessage> OnSwitchRoleRequest(SwitchRoleRequest request, CreatureController creatureController)
|
2024-02-10 22:28:35 +00:00
|
|
|
|
{
|
2024-02-17 13:49:28 +00:00
|
|
|
|
await creatureController.SwitchPlayerEntity(request.RoleId);
|
2024-02-10 22:28:35 +00:00
|
|
|
|
return Response(MessageId.SwitchRoleResponse, new SwitchRoleResponse
|
|
|
|
|
{
|
|
|
|
|
RoleId = request.RoleId
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-09 22:15:05 +00:00
|
|
|
|
[NetEvent(MessageId.RoleFavorListRequest)]
|
|
|
|
|
public ResponseMessage OnRoleFavorListRequest() => Response(MessageId.RoleFavorListResponse, new RoleFavorListResponse());
|
|
|
|
|
}
|