🚧 pass-through raw data, refactoring

This commit is contained in:
2023-10-07 19:30:52 +03:00
parent 8788cb0fcf
commit e1a3ea45e2
29 changed files with 434 additions and 219 deletions
@@ -20,20 +20,24 @@ using Ragon.Server.Entity;
namespace Ragon.Server.Handler;
public sealed class EntityDestroyOperation: IRagonOperation
public sealed class EntityDestroyOperation: BaseOperation
{
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
public void Handle(RagonContext context, RagonBuffer reader, RagonBuffer writer)
public EntityDestroyOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
{
}
public override void Handle(RagonContext context, byte[] data)
{
var player = context.RoomPlayer;
var room = context.Room;
var entityId = reader.ReadUShort();
var entityId = Reader.ReadUShort();
if (room.Entities.TryGetValue(entityId, out var entity))
{
var payload = new RagonPayload();
payload.Read(reader);
payload.Read(Reader);
room.DetachEntity(entity);
player.DetachEntity(entity);