This commit is contained in:
2023-06-27 23:41:30 +03:00
parent 6c441d9dee
commit 20662ae24d
14 changed files with 163 additions and 49 deletions
+14 -29
View File
@@ -29,15 +29,14 @@ namespace Ragon.Client
public bool IsFixed => _fixed;
public int Size => _size;
private RagonEntity _entity;
private RagonBuffer _propertyBuffer;
private RagonEntity _entity;
private bool _dirty;
private int _size;
private int _ticks;
private int _priority;
private bool _fixed;
private string _name;
protected bool InvokeLocal;
protected RagonProperty(int priority, bool invokeLocal)
@@ -45,7 +44,6 @@ namespace Ragon.Client
_size = 0;
_priority = priority;
_fixed = false;
_propertyBuffer = new RagonBuffer();
InvokeLocal = invokeLocal;
}
@@ -94,44 +92,31 @@ namespace Ragon.Client
internal void AssignEntity(RagonEntity ent)
{
_entity = ent;
Changed?.Invoke();
}
internal void Write(RagonBuffer buffer)
{
_propertyBuffer.Clear();
if (_fixed)
{
Serialize(_propertyBuffer);
buffer.FromBuffer(_propertyBuffer, _size);
Serialize(buffer);
return;
}
else
{
Serialize(_propertyBuffer);
var propSize = _propertyBuffer.WriteOffset;
buffer.WriteUShort((ushort) propSize);
buffer.FromBuffer(_propertyBuffer, propSize);
}
var sizeOffset = buffer.WriteOffset;
buffer.Write(0, 16);
var propOffset = buffer.WriteOffset;
Serialize(buffer);
var propSize = (uint)(buffer.WriteOffset - propOffset);
buffer.Write(propSize, 16, sizeOffset);
}
internal void Read(RagonBuffer buffer)
{
_propertyBuffer.Clear();
if (_fixed)
{
buffer.ToBuffer(_propertyBuffer, _size);
Deserialize(_propertyBuffer);
return;
}
var propSize = buffer.ReadUShort();
buffer.ToBuffer(_propertyBuffer, propSize);
Deserialize(_propertyBuffer);
Deserialize(buffer);
}
public virtual void Serialize(RagonBuffer buffer)