🚑 independent buffers in properties
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Ragon.Client
|
|||||||
public bool IsFixed => _fixed;
|
public bool IsFixed => _fixed;
|
||||||
public int Size => _size;
|
public int Size => _size;
|
||||||
|
|
||||||
|
private RagonBuffer _propertyBuffer;
|
||||||
private RagonEntity _entity;
|
private RagonEntity _entity;
|
||||||
private bool _dirty;
|
private bool _dirty;
|
||||||
private int _size;
|
private int _size;
|
||||||
@@ -44,6 +45,7 @@ namespace Ragon.Client
|
|||||||
_size = 0;
|
_size = 0;
|
||||||
_priority = priority;
|
_priority = priority;
|
||||||
_fixed = false;
|
_fixed = false;
|
||||||
|
_propertyBuffer = new RagonBuffer();
|
||||||
|
|
||||||
InvokeLocal = invokeLocal;
|
InvokeLocal = invokeLocal;
|
||||||
}
|
}
|
||||||
@@ -98,25 +100,38 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
internal void Write(RagonBuffer buffer)
|
internal void Write(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
|
_propertyBuffer.Clear();
|
||||||
|
|
||||||
if (_fixed)
|
if (_fixed)
|
||||||
{
|
{
|
||||||
Serialize(buffer);
|
Serialize(_propertyBuffer);
|
||||||
|
|
||||||
|
buffer.FromBuffer(_propertyBuffer, _size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sizeOffset = buffer.WriteOffset;
|
Serialize(_propertyBuffer);
|
||||||
buffer.Write(0, 16);
|
|
||||||
var propOffset = buffer.WriteOffset;
|
|
||||||
|
|
||||||
Serialize(buffer);
|
var propertySize = (ushort) _propertyBuffer.WriteOffset;
|
||||||
|
buffer.WriteUShort(propertySize);;
|
||||||
var propSize = (uint)(buffer.WriteOffset - propOffset);
|
buffer.FromBuffer(_propertyBuffer, propertySize);
|
||||||
buffer.Write(propSize, 16, sizeOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Read(RagonBuffer buffer)
|
internal void Read(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
Deserialize(buffer);
|
_propertyBuffer.Clear();
|
||||||
|
|
||||||
|
if (_fixed)
|
||||||
|
{
|
||||||
|
buffer.ToBuffer(_propertyBuffer, _size);
|
||||||
|
|
||||||
|
Deserialize(_propertyBuffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var propSize = buffer.ReadUShort();
|
||||||
|
buffer.ToBuffer(_propertyBuffer, propSize);
|
||||||
|
Deserialize(_propertyBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Serialize(RagonBuffer buffer)
|
public virtual void Serialize(RagonBuffer buffer)
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
|||||||
|
|
||||||
Writer.Clear();
|
Writer.Clear();
|
||||||
Writer.WriteOperation(RagonOperation.OWNERSHIP_ENTITY_CHANGED);
|
Writer.WriteOperation(RagonOperation.OWNERSHIP_ENTITY_CHANGED);
|
||||||
Writer.WriteString(Owner.Id);
|
Writer.WriteUShort(Owner.Connection.Id);
|
||||||
Writer.WriteUShort((ushort)entitiesToUpdate.Count);
|
Writer.WriteUShort((ushort)entitiesToUpdate.Count);
|
||||||
|
|
||||||
foreach (var entity in entitiesToUpdate)
|
foreach (var entity in entitiesToUpdate)
|
||||||
|
|||||||
Reference in New Issue
Block a user