Snowflake/RPG.Services.Gameserver/Modules/TeamModule.cs

60 lines
1.8 KiB
C#

using RPG.Network.Proto;
using RPG.Services.Gameserver.Game.Team;
using RPG.Services.Gameserver.Modules.Attributes;
using RPG.Services.Gameserver.Session;
namespace RPG.Services.Gameserver.Modules;
internal class TeamModule : BaseModule
{
private static readonly uint[] StartingLineup = [1007, 1102, 1101, 1003];
public PlayerTeam Team { get; } = new();
public TeamModule(ModuleManager moduleManager) : base(moduleManager)
{
}
public void InitStartingLineup()
{
for (uint i = 0; i < StartingLineup.Length; i++)
{
Team.Join(StartingLineup[i], AvatarType.AvatarFormalType, i);
}
}
[OnCommand(CmdType.CmdChangeLineupLeaderCsReq)]
public Task OnCmdChangeLineupLeaderCsReq(PlayerSession session, ReadOnlyMemory<byte> body)
{
ChangeLineupLeaderCsReq req = ChangeLineupLeaderCsReq.Parser.ParseFrom(body.Span);
Send(session, CmdType.CmdChangeLineupLeaderScRsp, new ChangeLineupLeaderScRsp
{
Retcode = 0,
Slot = req.Slot
});
return Task.CompletedTask;
}
[OnCommand(CmdType.CmdGetAllLineupDataCsReq)]
public Task OnCmdGetAllLineupDataCsReq(PlayerSession session, ReadOnlyMemory<byte> _)
{
GetAllLineupDataScRsp rsp = new();
rsp.LineupList.Add(Team.LineupInfo);
Send(session, CmdType.CmdGetAllLineupDataScRsp, rsp);
return Task.CompletedTask;
}
[OnCommand(CmdType.CmdGetCurLineupDataCsReq)]
public Task OnCmdGetCurLineupDataCsReq(PlayerSession session, ReadOnlyMemory<byte> _)
{
Send(session, CmdType.CmdGetCurLineupDataScRsp, new GetCurLineupDataScRsp
{
Retcode = 0,
Lineup = Team.LineupInfo
});
return Task.CompletedTask;
}
}