2024-01-20 12:42:08 +00:00
|
|
|
|
using RPG.GameCore.Excel;
|
|
|
|
|
using RPG.Network.Proto;
|
2024-01-23 17:54:53 +00:00
|
|
|
|
using RPG.Services.Gameserver.Game.Entity;
|
|
|
|
|
using RPG.Services.Gameserver.Game.Maze;
|
2024-01-19 14:45:18 +00:00
|
|
|
|
using RPG.Services.Gameserver.Modules.Attributes;
|
|
|
|
|
using RPG.Services.Gameserver.Session;
|
|
|
|
|
|
|
|
|
|
namespace RPG.Services.Gameserver.Modules;
|
2024-01-21 15:34:19 +00:00
|
|
|
|
|
|
|
|
|
[GMAlias("adventure")]
|
2024-01-19 14:45:18 +00:00
|
|
|
|
internal class AdventureModule : BaseModule
|
|
|
|
|
{
|
2024-01-23 17:54:53 +00:00
|
|
|
|
private const int StartingEntryId = 2010101;
|
2024-01-20 12:42:08 +00:00
|
|
|
|
|
2024-01-23 17:54:53 +00:00
|
|
|
|
private readonly ExcelTables _excelTables;
|
|
|
|
|
private readonly MazeManager _mazeManager;
|
|
|
|
|
|
|
|
|
|
public AdventureModule(ModuleManager moduleManager, ExcelTables excelTables, MazeManager mazeManager) : base(moduleManager)
|
2024-01-20 12:42:08 +00:00
|
|
|
|
{
|
2024-01-23 17:54:53 +00:00
|
|
|
|
_excelTables = excelTables;
|
|
|
|
|
_mazeManager = mazeManager;
|
2024-01-20 12:42:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-21 15:34:19 +00:00
|
|
|
|
[GMCommand("maze")]
|
|
|
|
|
public Task OnGmEnterMaze(PlayerSession session, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length != 1) return Task.CompletedTask;
|
|
|
|
|
|
|
|
|
|
if (!uint.TryParse(args[0], out uint entryId))
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
2024-01-23 17:54:53 +00:00
|
|
|
|
MapEntryRow? entry = _excelTables.GetExcelRow<MapEntryRow>(ExcelType.MapEntry, entryId);
|
2024-01-21 15:34:19 +00:00
|
|
|
|
if (entry == null) return Task.CompletedTask;
|
|
|
|
|
|
2024-01-23 17:54:53 +00:00
|
|
|
|
_mazeManager.EnterMaze(entryId, ModuleManager.Get<TeamModule>().Team);
|
|
|
|
|
|
2024-01-21 15:34:19 +00:00
|
|
|
|
Send(session, CmdType.CmdEnterMazeByServerScNotify, new EnterMazeByServerScNotify
|
|
|
|
|
{
|
2024-01-23 17:54:53 +00:00
|
|
|
|
Maze = _mazeManager.Maze
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Task OnLogin()
|
|
|
|
|
{
|
|
|
|
|
_mazeManager.EnterMaze(StartingEntryId, ModuleManager.Get<TeamModule>().Team);
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnBattleWin(uint battleMonster, IEnumerable<uint> assistMonsters)
|
|
|
|
|
{
|
|
|
|
|
_mazeManager.RemoveEntities(assistMonsters.Append(battleMonster));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnBattleLost()
|
|
|
|
|
{
|
|
|
|
|
_mazeManager.ResetAvatarPosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[OnCommand(CmdType.CmdSceneCastSkillCsReq)]
|
|
|
|
|
public Task OnCmdSceneCastSkillCsReq(PlayerSession session, ReadOnlyMemory<byte> body)
|
|
|
|
|
{
|
|
|
|
|
SceneCastSkillCsReq req = SceneCastSkillCsReq.Parser.ParseFrom(body.Span);
|
|
|
|
|
|
|
|
|
|
BattleModule battleModule = ModuleManager.Get<BattleModule>();
|
2024-01-25 10:55:10 +00:00
|
|
|
|
if (_mazeManager.EntityManager.GetEntityById(req.CastEntityId) is NpcMonsterEntity)
|
2024-01-23 17:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
battleModule.OnBeingHitByMonster(req.CastEntityId, req.AssistMonsterEntityIdList);
|
|
|
|
|
}
|
2024-01-25 10:55:10 +00:00
|
|
|
|
else if (_mazeManager.EntityManager.GetEntityById(req.AbilityTargetEntityId) is NpcMonsterEntity)
|
2024-01-23 17:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
battleModule.OnSuccessfulAttack(req.AbilityTargetEntityId, req.AssistMonsterEntityIdList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Send(session, CmdType.CmdSceneCastSkillScRsp, new SceneCastSkillScRsp
|
|
|
|
|
{
|
|
|
|
|
Retcode = 0,
|
|
|
|
|
BattleInfo = battleModule.Battle ?? new()
|
2024-01-21 15:34:19 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-19 14:45:18 +00:00
|
|
|
|
[OnCommand(CmdType.CmdGetCurSceneInfoCsReq)]
|
|
|
|
|
public Task OnCmdGetCurSceneInfoCsReq(PlayerSession session, ReadOnlyMemory<byte> _)
|
|
|
|
|
{
|
|
|
|
|
Send(session, CmdType.CmdGetCurSceneInfoScRsp, new GetCurSceneInfoScRsp
|
|
|
|
|
{
|
|
|
|
|
Retcode = 0,
|
2024-01-23 17:54:53 +00:00
|
|
|
|
Scene = _mazeManager.SceneInfo
|
2024-01-19 14:45:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
2024-01-20 12:42:08 +00:00
|
|
|
|
|
|
|
|
|
[OnCommand(CmdType.CmdGetMazeMapInfoCsReq)]
|
|
|
|
|
public Task OnCmdGetMazeMapInfoCsReq(PlayerSession session, ReadOnlyMemory<byte> body)
|
|
|
|
|
{
|
|
|
|
|
GetMazeMapInfoCsReq req = GetMazeMapInfoCsReq.Parser.ParseFrom(body.Span);
|
|
|
|
|
|
|
|
|
|
Send(session, CmdType.CmdGetMazeMapInfoScRsp, new GetMazeMapInfoScRsp
|
|
|
|
|
{
|
|
|
|
|
Retcode = 0,
|
|
|
|
|
EntryId = req.EntryId,
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
LightenSectionList = { },
|
|
|
|
|
MazeGroupList = { },
|
|
|
|
|
MazePropList = { }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[OnCommand(CmdType.CmdEnterMazeCsReq)]
|
|
|
|
|
public Task OnCmdEnterMazeCsReq(PlayerSession session, ReadOnlyMemory<byte> body)
|
|
|
|
|
{
|
|
|
|
|
EnterMazeCsReq req = EnterMazeCsReq.Parser.ParseFrom(body.Span);
|
|
|
|
|
|
2024-01-23 17:54:53 +00:00
|
|
|
|
MapEntryRow? entry = _excelTables.GetExcelRow<MapEntryRow>(ExcelType.MapEntry, req.EntryId);
|
2024-01-20 12:42:08 +00:00
|
|
|
|
if (entry == null)
|
|
|
|
|
{
|
|
|
|
|
Send(session, CmdType.CmdEnterMazeScRsp, new EnterMazeScRsp
|
|
|
|
|
{
|
|
|
|
|
Retcode = Retcode.RET_MAZE_MAP_NOT_EXIST
|
|
|
|
|
});
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-23 17:54:53 +00:00
|
|
|
|
_mazeManager.EnterMaze(entry.ID, ModuleManager.Get<TeamModule>().Team);
|
2024-01-20 12:42:08 +00:00
|
|
|
|
Send(session, CmdType.CmdEnterMazeScRsp, new EnterMazeScRsp
|
|
|
|
|
{
|
|
|
|
|
Retcode = 0,
|
2024-01-23 17:54:53 +00:00
|
|
|
|
Maze = _mazeManager.Maze
|
2024-01-20 12:42:08 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
2024-01-19 14:45:18 +00:00
|
|
|
|
}
|