2024-02-09 22:15:05 +00:00
|
|
|
|
using GameServer.Controllers.Attributes;
|
|
|
|
|
using GameServer.Models;
|
|
|
|
|
using GameServer.Network;
|
|
|
|
|
using GameServer.Network.Messages;
|
2024-02-11 22:23:13 +00:00
|
|
|
|
using GameServer.Systems.Entity;
|
|
|
|
|
using GameServer.Systems.Event;
|
2024-02-09 22:15:05 +00:00
|
|
|
|
using Protocol;
|
|
|
|
|
|
|
|
|
|
namespace GameServer.Controllers;
|
|
|
|
|
internal class FormationController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ModelManager _modelManager;
|
|
|
|
|
|
|
|
|
|
public FormationController(PlayerSession session, ModelManager modelManager) : base(session)
|
|
|
|
|
{
|
|
|
|
|
_modelManager = modelManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NetEvent(MessageId.GetFormationDataRequest)]
|
|
|
|
|
public ResponseMessage OnGetFormationDataRequest() => Response(MessageId.GetFormationDataResponse, new GetFormationDataResponse
|
|
|
|
|
{
|
|
|
|
|
Formations =
|
|
|
|
|
{
|
|
|
|
|
new FightFormation
|
|
|
|
|
{
|
2024-02-12 20:15:14 +00:00
|
|
|
|
CurRole = _modelManager.Formation.RoleIds[0],
|
2024-02-09 22:15:05 +00:00
|
|
|
|
FormationId = 1,
|
|
|
|
|
IsCurrent = true,
|
2024-02-12 20:15:14 +00:00
|
|
|
|
RoleIds = { _modelManager.Formation.RoleIds },
|
2024-02-09 22:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
2024-02-10 00:56:31 +00:00
|
|
|
|
|
2024-02-11 22:23:13 +00:00
|
|
|
|
[NetEvent(MessageId.UpdateFormationRequest)]
|
|
|
|
|
public async Task<ResponseMessage> OnUpdateFormationRequest(UpdateFormationRequest request, EventSystem eventSystem)
|
|
|
|
|
{
|
|
|
|
|
_modelManager.Formation.Set([.. request.Formation.RoleIds]);
|
|
|
|
|
await eventSystem.Emit(GameEventType.FormationUpdated);
|
|
|
|
|
|
|
|
|
|
return Response(MessageId.UpdateFormationResponse, new UpdateFormationResponse
|
|
|
|
|
{
|
|
|
|
|
Formation = request.Formation
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-02-09 22:15:05 +00:00
|
|
|
|
}
|