2024-01-04 22:58:31 +00:00
|
|
|
|
using Google.Protobuf;
|
|
|
|
|
using NahidaImpact.Gameserver.Controllers.Attributes;
|
2024-01-04 13:48:39 +00:00
|
|
|
|
using NahidaImpact.Gameserver.Controllers.Result;
|
2024-01-04 20:08:29 +00:00
|
|
|
|
using NahidaImpact.Gameserver.Game;
|
2024-01-04 13:48:39 +00:00
|
|
|
|
using NahidaImpact.Gameserver.Game.Scene;
|
2024-01-04 22:58:31 +00:00
|
|
|
|
using NahidaImpact.Gameserver.Helpers;
|
|
|
|
|
using NahidaImpact.Gameserver.Network.Session;
|
2024-01-04 13:48:39 +00:00
|
|
|
|
using NahidaImpact.Protocol;
|
|
|
|
|
|
|
|
|
|
namespace NahidaImpact.Gameserver.Controllers;
|
|
|
|
|
|
|
|
|
|
[NetController]
|
|
|
|
|
internal class SceneController : ControllerBase
|
|
|
|
|
{
|
2024-01-05 15:14:13 +00:00
|
|
|
|
[NetCommand(CmdType.MarkMapReq)]
|
|
|
|
|
public async ValueTask<IResult> OnMarkMapReq(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
MarkMapReq request = Packet!.DecodeBody<MarkMapReq>();
|
|
|
|
|
if (request.Mark != null)
|
|
|
|
|
{
|
|
|
|
|
Vector teleportToPosition = request.Mark.Pos;
|
|
|
|
|
await sceneManager.TeleportTo(teleportToPosition.X, 800, teleportToPosition.Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Response(CmdType.MarkMapRsp);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 22:58:31 +00:00
|
|
|
|
[NetCommand(CmdType.EvtDoSkillSuccNotify)]
|
|
|
|
|
public async ValueTask<IResult> OnEvtDoSkillSuccNotify(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
EvtDoSkillSuccNotify notify = Packet!.DecodeBody<EvtDoSkillSuccNotify>();
|
|
|
|
|
await sceneManager.ResetAllCoolDownsForAvatar(notify.CasterId);
|
|
|
|
|
|
|
|
|
|
return Ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NetCommand(CmdType.CombatInvocationsNotify)]
|
|
|
|
|
public async ValueTask<IResult> OnCombatInvocationsNotify(ClientActionManager clientActionManager)
|
|
|
|
|
{
|
|
|
|
|
CombatInvocationsNotify notify = Packet!.DecodeBody<CombatInvocationsNotify>();
|
|
|
|
|
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<IResult> OnUnionCmdNotify(NetSession session)
|
|
|
|
|
{
|
|
|
|
|
UnionCmdNotify notify = Packet!.DecodeBody<UnionCmdNotify>();
|
|
|
|
|
|
|
|
|
|
foreach (UnionCmd cmd in notify.CmdList)
|
|
|
|
|
{
|
|
|
|
|
await session.HandlePacket(cmd.ToNetPacket());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Ok();
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 20:08:29 +00:00
|
|
|
|
[NetCommand(CmdType.GetScenePointReq)]
|
|
|
|
|
public ValueTask<IResult> 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<IResult> OnGetSceneAreaReq(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
GetSceneAreaRsp rsp = new()
|
|
|
|
|
{
|
|
|
|
|
SceneId = sceneManager.CurrentSceneId
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-04 21:17:25 +00:00
|
|
|
|
for (uint i = 1; i <= 100; i++)
|
2024-01-04 20:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
rsp.AreaIdList.Add(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ValueTask.FromResult(Response(CmdType.GetSceneAreaRsp, rsp));
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 13:48:39 +00:00
|
|
|
|
[NetCommand(CmdType.PostEnterSceneReq)]
|
|
|
|
|
public async ValueTask<IResult> OnPostEnterSceneReq(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
await sceneManager.OnEnterStateChanged(SceneEnterState.PostEnter);
|
|
|
|
|
|
|
|
|
|
return Response(CmdType.PostEnterSceneRsp, new PostEnterSceneRsp
|
|
|
|
|
{
|
|
|
|
|
EnterSceneToken = sceneManager.EnterToken
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NetCommand(CmdType.EnterSceneDoneReq)]
|
|
|
|
|
public async ValueTask<IResult> OnEnterSceneDoneReq(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
await sceneManager.OnEnterStateChanged(SceneEnterState.EnterDone);
|
|
|
|
|
|
|
|
|
|
return Response(CmdType.EnterSceneDoneRsp, new EnterSceneDoneRsp
|
|
|
|
|
{
|
|
|
|
|
EnterSceneToken = sceneManager.EnterToken
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NetCommand(CmdType.SceneInitFinishReq)]
|
|
|
|
|
public async ValueTask<IResult> OnSceneInitFinishReq(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
await sceneManager.OnEnterStateChanged(SceneEnterState.InitFinished);
|
|
|
|
|
|
|
|
|
|
return Response(CmdType.SceneInitFinishRsp, new SceneInitFinishRsp
|
|
|
|
|
{
|
|
|
|
|
EnterSceneToken = sceneManager.EnterToken
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NetCommand(CmdType.EnterSceneReadyReq)]
|
|
|
|
|
public async ValueTask<IResult> OnEnterSceneReadyReq(SceneManager sceneManager)
|
|
|
|
|
{
|
|
|
|
|
await sceneManager.OnEnterStateChanged(SceneEnterState.ReadyToEnter);
|
|
|
|
|
|
|
|
|
|
return Response(CmdType.EnterSceneReadyRsp, new EnterSceneReadyRsp
|
|
|
|
|
{
|
|
|
|
|
EnterSceneToken = sceneManager.EnterToken
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|