KafkaSR/RPG.Services.Gameserver/Modules/MissionModule.cs

57 lines
1.7 KiB
C#
Raw Normal View History

2024-01-29 23:49:21 +00:00
using RPG.GameCore.Excel;
using RPG.Network.Proto;
using RPG.Services.Gameserver.Modules.Attributes;
using RPG.Services.Gameserver.Session;
namespace RPG.Services.Gameserver.Modules;
internal class MissionModule : BaseModule
{
private readonly ExcelTables _excelTables;
public MissionModule(ExcelTables excelTables)
{
_excelTables = excelTables;
}
[OnCommand(CmdType.CmdGetMissionDataCsReq)]
public Task OnCmdGetMissionDataCsReq(PlayerSession session, ReadOnlyMemory<byte> _)
{
GetMissionDataScRsp rsp = new();
Send(session, CmdType.CmdGetMissionDataScRsp, rsp);
return Task.CompletedTask;
}
[OnCommand(CmdType.CmdGetMissionStatusCsReq)]
public Task OnCmdGetMissionStatusCsReq(PlayerSession session, ReadOnlyMemory<byte> body)
{
GetMissionStatusCsReq req = GetMissionStatusCsReq.Parser.ParseFrom(body.Span);
GetMissionStatusScRsp rsp = new();
rsp.FinishedMainMissionIdList.AddRange(_excelTables.GetAllRows(ExcelType.MainMission).Select(row => row.Id));
foreach (uint id in req.SubMissionIdList)
{
rsp.SubMissionStatusList.Add(new Mission
{
Id = id,
Progress = 0,
Status = MissionStatus.MissionFinish
});
}
foreach (uint id in req.MissionEventIdList)
{
rsp.MissionEventStatusList.Add(new Mission
{
Id = id,
Progress = 0,
Status = MissionStatus.MissionFinish
});
}
Send(session, CmdType.CmdGetMissionStatusScRsp, rsp);
return Task.CompletedTask;
}
}