Snowflake/RPG.Services.Gameserver/Session/SessionEntityEventListener.cs

41 lines
1.2 KiB
C#
Raw Normal View History

using Google.Protobuf;
using RPG.Network.Proto;
using RPG.Services.Gameserver.Game.Entity;
namespace RPG.Services.Gameserver.Session;
internal class SessionEntityEventListener : IEntityEventListener
{
public PlayerSession? Session { get; set; }
public Task OnRemoveEntities(IEnumerable<uint> ids)
{
SceneEntityDisappearScNotify notify = new();
notify.EntityIdList.AddRange(ids);
Session?.SendToService(RPGServiceType.Gateserver, ServiceCommandType.ForwardGameMessage, new CmdForwardGameMessage
{
SessionId = Session.SessionId,
CmdType = (uint)CmdType.CmdSceneEntityDisappearScNotify,
Payload = notify.ToByteString()
});
return Task.CompletedTask;
}
public Task OnUpdateEntity(SceneEntityInfo entity)
{
SceneEntityUpdateScNotify notify = new();
notify.EntityList.Add(entity);
Session?.SendToService(RPGServiceType.Gateserver, ServiceCommandType.ForwardGameMessage, new CmdForwardGameMessage
{
SessionId = Session.SessionId,
CmdType = (uint)CmdType.CmdSceneEntityUpdateScNotify,
Payload = notify.ToByteString()
});
return Task.CompletedTask;
}
}