This commit is contained in:
2023-07-29 10:58:06 +03:00
parent 0a8d761cc1
commit c01b748031
16 changed files with 133 additions and 118 deletions
+3 -10
View File
@@ -60,7 +60,7 @@ namespace Ragon.Client
_sceneId = sceneId;
}
internal void Attach(RagonClient client, ushort entityId, ushort entityType, bool hasAuthority, RagonPlayer owner, RagonPayload payload)
internal void Attach(RagonClient client, ushort entityId, ushort entityType, bool hasAuthority, RagonPlayer owner)
{
Type = entityType;
Id = entityId;
@@ -70,7 +70,6 @@ namespace Ragon.Client
HasAuthority = hasAuthority;
_client = client;
_spawnPayload = payload;
Attached?.Invoke(this);
}
@@ -96,15 +95,9 @@ namespace Ragon.Client
return payload;
}
public void AttachPayload(IRagonPayload? payload)
public void AttachPayload(RagonPayload payload)
{
if (payload == null) return;
var buffer = new RagonBuffer();
payload.Serialize(buffer);
_spawnPayload = new RagonPayload();
_spawnPayload.Read(buffer);
_spawnPayload = payload;
}
public T GetAttachPayload<T>() where T : IRagonPayload, new()
+3 -7
View File
@@ -19,7 +19,7 @@ using Ragon.Protocol;
namespace Ragon.Client;
public struct RagonPayload
public class RagonPayload
{
private readonly uint[] _data = new uint[128];
private readonly int _size = 0;
@@ -32,16 +32,12 @@ public struct RagonPayload
public void Read(RagonBuffer buffer)
{
var readOnlySpan = _data.AsSpan();
buffer.ReadSpan(ref readOnlySpan, _size);
buffer.ReadArray(_data, _size);
}
public void Write(RagonBuffer buffer)
{
ReadOnlySpan<uint> readOnlySpan = _data.AsSpan();
buffer.WriteSpan(ref readOnlySpan, _size);
buffer.WriteArray(_data, _size);
}
public override string ToString()