using Yuanshen.Gameserver.Controllers.Attributes; using Yuanshen.Gameserver.Controllers.Result; using Yuanshen.Gameserver.Game; using Yuanshen.Protocol; using Microsoft.Extensions.Logging; namespace Yuanshen.Gameserver.Controllers; [NetController] internal sealed class EventController : ControllerBase { [NetCommand(CmdType.SeeMonsterReq)] public ValueTask OnSeeMonsterReq() { SeeMonsterReq req = Packet!.DecodeBody(); return ValueTask.FromResult(Response(CmdType.SeeMonsterRsp, new SeeMonsterRsp { Retcode = Retcode.RET_SUCC })); } [NetCommand(CmdType.EvtAvatarEnterFocusNotify)] public ValueTask OnEvtAvatarEnterFocusNotify() => Handled(); [NetCommand(CmdType.EvtAvatarUpdateFocusNotify)] public ValueTask OnEvtAvatarUpdateFocusNotify() => Handled(); [NetCommand(CmdType.EvtAvatarExitFocusNotify)] public ValueTask OnEvtAvatarExitFocusNotify() => Handled(); [NetCommand(CmdType.EvtCreateGadgetNotify)] public ValueTask OnEvtCreateGadgetNotify(Player player, ILogger logger) { EvtCreateGadgetNotify notify = Packet!.DecodeBody(); player.ClientGadgets[notify.EntityId] = notify.ConfigId; logger.LogDebug("Gadget created entity={entity} config={config} owner={owner}", notify.EntityId, notify.ConfigId, notify.OwnerEntityId); return ValueTask.FromResult(Ok()); } [NetCommand(CmdType.EvtDestroyGadgetNotify)] public ValueTask OnEvtDestroyGadgetNotify(Player player, ILogger logger) { EvtDestroyGadgetNotify notify = Packet!.DecodeBody(); player.ClientGadgets.Remove(notify.EntityId); logger.LogDebug("Gadget destroyed entity={entity}", notify.EntityId); return ValueTask.FromResult(Ok()); } private ValueTask Handled() where TMessage : Google.Protobuf.IMessage, new() { Packet!.DecodeBody(); return ValueTask.FromResult(Ok()); } }