🚑 fixed empty state values
This commit is contained in:
@@ -66,8 +66,7 @@ internal class SnapshotHandler : Handler
|
|||||||
var entityId = buffer.ReadUShort();
|
var entityId = buffer.ReadUShort();
|
||||||
var ownerPeerId = buffer.ReadUShort();
|
var ownerPeerId = buffer.ReadUShort();
|
||||||
var payloadSize = buffer.ReadUShort();
|
var payloadSize = buffer.ReadUShort();
|
||||||
RagonLog.Trace("Read offset: " + buffer.ReadOffset);
|
|
||||||
|
|
||||||
var player = _playerCache.GetPlayerByPeer(ownerPeerId);
|
var player = _playerCache.GetPlayerByPeer(ownerPeerId);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ namespace Ragon.Server.Entity;
|
|||||||
|
|
||||||
public class RagonEntityState: IRagonEntityState
|
public class RagonEntityState: IRagonEntityState
|
||||||
{
|
{
|
||||||
private List<RagonProperty> _properties;
|
private readonly List<RagonProperty> _properties;
|
||||||
private RagonEntity _entity;
|
private readonly RagonEntity _entity;
|
||||||
private RagonBuffer _buffer;
|
|
||||||
|
|
||||||
public RagonEntityState(RagonEntity entity, int capacity = 10)
|
public RagonEntityState(RagonEntity entity, int capacity = 10)
|
||||||
{
|
{
|
||||||
_entity = entity;
|
_entity = entity;
|
||||||
_buffer = new RagonBuffer(8);
|
|
||||||
_properties = new List<RagonProperty>(capacity);
|
_properties = new List<RagonProperty>(capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +65,7 @@ public class RagonEntityState: IRagonEntityState
|
|||||||
{
|
{
|
||||||
foreach (var property in _properties)
|
foreach (var property in _properties)
|
||||||
{
|
{
|
||||||
var hasPayloadOrFixed = property.IsFixed || property is { IsFixed: false, Size: > 0 };
|
if (property.HasData)
|
||||||
if (hasPayloadOrFixed)
|
|
||||||
{
|
{
|
||||||
buffer.WriteBool(true);
|
buffer.WriteBool(true);
|
||||||
property.Write(buffer);
|
property.Write(buffer);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class RagonProperty : RagonPayload
|
|||||||
public int Size { get; set; }
|
public int Size { get; set; }
|
||||||
public bool IsDirty { get; private set; }
|
public bool IsDirty { get; private set; }
|
||||||
public bool IsFixed { get; private set; }
|
public bool IsFixed { get; private set; }
|
||||||
|
public bool HasData { get; private set; }
|
||||||
|
|
||||||
private uint[] _data;
|
private uint[] _data;
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ public class RagonProperty : RagonPayload
|
|||||||
buffer.ReadArray(_data, Size);
|
buffer.ReadArray(_data, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HasData = true;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user