🚑 fixed empty state values

This commit is contained in:
2023-07-30 17:44:51 +03:00
parent cd9304e63a
commit 4a8aae11e3
3 changed files with 7 additions and 9 deletions
@@ -21,14 +21,12 @@ namespace Ragon.Server.Entity;
public class RagonEntityState: IRagonEntityState
{
private List<RagonProperty> _properties;
private RagonEntity _entity;
private RagonBuffer _buffer;
private readonly List<RagonProperty> _properties;
private readonly RagonEntity _entity;
public RagonEntityState(RagonEntity entity, int capacity = 10)
{
_entity = entity;
_buffer = new RagonBuffer(8);
_properties = new List<RagonProperty>(capacity);
}
@@ -67,8 +65,7 @@ public class RagonEntityState: IRagonEntityState
{
foreach (var property in _properties)
{
var hasPayloadOrFixed = property.IsFixed || property is { IsFixed: false, Size: > 0 };
if (hasPayloadOrFixed)
if (property.HasData)
{
buffer.WriteBool(true);
property.Write(buffer);
@@ -23,6 +23,7 @@ public class RagonProperty : RagonPayload
public int Size { get; set; }
public bool IsDirty { get; private set; }
public bool IsFixed { get; private set; }
public bool HasData { get; private set; }
private uint[] _data;
@@ -47,6 +48,7 @@ public class RagonProperty : RagonPayload
buffer.ReadArray(_data, Size);
}
HasData = true;
IsDirty = true;
}