🚧 plugin system, webhook system
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Ragon.Protocol;
|
||||
|
||||
namespace Ragon.Server.Entity;
|
||||
|
||||
public ref struct RagonEntityParameters
|
||||
{
|
||||
public ushort Type;
|
||||
public ushort StaticId;
|
||||
public ushort AttachId;
|
||||
public RagonAuthority Authority;
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
using Ragon.Protocol;
|
||||
|
||||
namespace Ragon.Server;
|
||||
namespace Ragon.Server.Entity;
|
||||
|
||||
public class RagonEntityState
|
||||
{
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.Room;
|
||||
|
||||
namespace Ragon.Server;
|
||||
namespace Ragon.Server.Entity;
|
||||
|
||||
public class RagonEvent
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
using Ragon.Protocol;
|
||||
|
||||
namespace Ragon.Server;
|
||||
namespace Ragon.Server.Entity;
|
||||
|
||||
public class RagonPayload
|
||||
{
|
||||
|
||||
@@ -14,11 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
using System.ComponentModel;
|
||||
using Ragon.Protocol;
|
||||
|
||||
namespace Ragon.Server;
|
||||
namespace Ragon.Server.Entity;
|
||||
|
||||
public class RagonProperty : RagonPayload
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user