58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
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;
|
|
}
|
|
|
|
public Task OnEntityMoveByServer(uint entityId, MotionInfo motion)
|
|
{
|
|
SceneEntityMoveScNotify notify = new()
|
|
{
|
|
EntityId = entityId,
|
|
Motion = motion
|
|
};
|
|
|
|
Session?.SendToService(RPGServiceType.Gateserver, ServiceCommandType.ForwardGameMessage, new CmdForwardGameMessage
|
|
{
|
|
SessionId = Session.SessionId,
|
|
CmdType = (uint)CmdType.CmdSceneEntityMoveScNotify,
|
|
Payload = notify.ToByteString()
|
|
});
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|