57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
|
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;
|
|||
|
}
|
|||
|
}
|