using Google.Protobuf; using NahidaImpact.Gameserver.Controllers.Attributes; using NahidaImpact.Gameserver.Controllers.Result; using NahidaImpact.Gameserver.Game; using NahidaImpact.Gameserver.Game.Scene; using NahidaImpact.Gameserver.Helpers; using NahidaImpact.Gameserver.Network.Session; using NahidaImpact.Protocol; namespace NahidaImpact.Gameserver.Controllers; [NetController] internal class SceneController : ControllerBase { [NetCommand(CmdType.MarkMapReq)] public async ValueTask OnMarkMapReq(SceneManager sceneManager) { MarkMapReq request = Packet!.DecodeBody(); if (request.Mark != null) { Vector teleportToPosition = request.Mark.Pos; await sceneManager.TeleportTo(teleportToPosition.X, 800, teleportToPosition.Z); } return Response(CmdType.MarkMapRsp); } [NetCommand(CmdType.EvtDoSkillSuccNotify)] public async ValueTask OnEvtDoSkillSuccNotify(SceneManager sceneManager) { EvtDoSkillSuccNotify notify = Packet!.DecodeBody(); await sceneManager.ResetAllCoolDownsForAvatar(notify.CasterId); return Ok(); } [NetCommand(CmdType.CombatInvocationsNotify)] public async ValueTask OnCombatInvocationsNotify(ClientActionManager clientActionManager) { CombatInvocationsNotify notify = Packet!.DecodeBody(); foreach (CombatInvokeEntry invocation in notify.InvokeList) { IMessage? message = invocation.DecodeCombatInvocation(); if (message != null) await clientActionManager.InvokeAsync(invocation.ArgumentType, message); } return Ok(); } [NetCommand(CmdType.UnionCmdNotify)] public async ValueTask OnUnionCmdNotify(NetSession session) { UnionCmdNotify notify = Packet!.DecodeBody(); foreach (UnionCmd cmd in notify.CmdList) { await session.HandlePacket(cmd.ToNetPacket()); } return Ok(); } [NetCommand(CmdType.GetScenePointReq)] public ValueTask OnGetScenePointReq(SceneManager sceneManager, Player player) { GetScenePointRsp rsp = new() { SceneId = sceneManager.CurrentSceneId, BelongUid = player.Uid }; for (uint i = 1; i <= 777; i++) { rsp.UnlockedPointList.Add(i); } return ValueTask.FromResult(Response(CmdType.GetScenePointRsp, rsp)); } [NetCommand(CmdType.GetSceneAreaReq)] public ValueTask OnGetSceneAreaReq(SceneManager sceneManager) { GetSceneAreaRsp rsp = new() { SceneId = sceneManager.CurrentSceneId }; for (uint i = 1; i <= 100; i++) { rsp.AreaIdList.Add(i); } return ValueTask.FromResult(Response(CmdType.GetSceneAreaRsp, rsp)); } [NetCommand(CmdType.PostEnterSceneReq)] public async ValueTask OnPostEnterSceneReq(SceneManager sceneManager) { await sceneManager.OnEnterStateChanged(SceneEnterState.PostEnter); return Response(CmdType.PostEnterSceneRsp, new PostEnterSceneRsp { EnterSceneToken = sceneManager.EnterToken }); } [NetCommand(CmdType.EnterSceneDoneReq)] public async ValueTask OnEnterSceneDoneReq(SceneManager sceneManager) { await sceneManager.OnEnterStateChanged(SceneEnterState.EnterDone); return Response(CmdType.EnterSceneDoneRsp, new EnterSceneDoneRsp { EnterSceneToken = sceneManager.EnterToken }); } [NetCommand(CmdType.SceneInitFinishReq)] public async ValueTask OnSceneInitFinishReq(SceneManager sceneManager) { await sceneManager.OnEnterStateChanged(SceneEnterState.InitFinished); return Response(CmdType.SceneInitFinishRsp, new SceneInitFinishRsp { EnterSceneToken = sceneManager.EnterToken }); } [NetCommand(CmdType.EnterSceneReadyReq)] public async ValueTask OnEnterSceneReadyReq(SceneManager sceneManager) { await sceneManager.OnEnterStateChanged(SceneEnterState.ReadyToEnter); return Response(CmdType.EnterSceneReadyRsp, new EnterSceneReadyRsp { EnterSceneToken = sceneManager.EnterToken }); } }