🚧 plugin system, webhook system

This commit is contained in:
2023-04-09 10:52:18 +04:00
parent f2edc94958
commit bfd6c1b54b
60 changed files with 762 additions and 267 deletions
+32 -14
View File
@@ -16,8 +16,9 @@
using Ragon.Protocol;
using Ragon.Server.Room;
namespace Ragon.Server;
namespace Ragon.Server.Entity;
public class RagonEntity
{
@@ -30,29 +31,33 @@ public class RagonEntity
public RagonAuthority Authority { get; private set; }
public RagonPayload Payload { get; private set; }
public RagonEntityState State { get; private set; }
private readonly List<RagonEvent> _bufferedEvents;
public RagonEntity(RagonRoomPlayer owner, ushort type, ushort staticId, ushort attachId, RagonAuthority eventAuthority)
public RagonEntity(RagonEntityParameters parameters)
{
Owner = owner;
StaticId = staticId;
Type = type;
AttachId = attachId;
Id = _idGenerator++;
Authority = eventAuthority;
StaticId = parameters.StaticId;
Type = parameters.Type;
AttachId = parameters.AttachId;
Authority = parameters.Authority;
State = new RagonEntityState(this);
Payload = new RagonPayload();
_bufferedEvents = new List<RagonEvent>();
}
public void SetOwner(RagonRoomPlayer owner)
public void Attach(RagonRoomPlayer owner)
{
Owner = owner;
}
public void Detach()
{
}
public void RestoreBufferedEvents(RagonRoomPlayer roomPlayer, RagonBuffer writer)
{
foreach (var evnt in _bufferedEvents)
@@ -96,7 +101,7 @@ public class RagonEntity
var buffer = room.Writer;
buffer.Clear();
buffer.WriteOperation(RagonOperation.DESTROY_ENTITY);
buffer.WriteOperation(RagonOperation.REMOVE_ENTITY);
buffer.WriteUShort(Id);
Payload.Write(buffer);
@@ -209,4 +214,17 @@ public class RagonEntity
}
}
}
public void Write(RagonBuffer writer)
{
State.Write(writer);
}
public void Read(RagonRoomPlayer player, RagonBuffer reader)
{
if (Owner.Connection.Id != player.Connection.Id)
return;
State.Read(reader);
}
}