🚑 fixed empty state values
This commit is contained in:
@@ -66,7 +66,6 @@ internal class SnapshotHandler : Handler
|
||||
var entityId = buffer.ReadUShort();
|
||||
var ownerPeerId = buffer.ReadUShort();
|
||||
var payloadSize = buffer.ReadUShort();
|
||||
RagonLog.Trace("Read offset: " + buffer.ReadOffset);
|
||||
|
||||
var player = _playerCache.GetPlayerByPeer(ownerPeerId);
|
||||
if (player == null)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user