Try fix UI state debug assert (#6191)

* Try fix UI state debug assert

* comment
This commit is contained in:
Leon Friedrich
2025-09-18 00:31:57 +02:00
committed by GitHub
parent abd5149245
commit 10e4766809
2 changed files with 26 additions and 16 deletions
+25 -15
View File
@@ -220,24 +220,34 @@ Had full state: {LastFullState != null}"
{
var compState = change.State;
if (compState is IComponentDeltaState delta
&& compData.TryGetValue(change.NetID, out var old)) // May fail if relying on implicit data
if (compState is not IComponentDeltaState delta)
{
DebugTools.Assert(old is not IComponentDeltaState, "last state is not a full state");
if (cloneDelta)
{
compState = delta.CreateNewFullState(old!);
}
else
{
delta.ApplyToFullState(old!);
compState = old;
}
DebugTools.Assert(compState is not IComponentDeltaState, "newly constructed state is not a full state");
compData[change.NetID] = compState;
continue;
}
compData[change.NetID] = compState;
if (!compData.TryGetValue(change.NetID, out var old))
{
// Either the server needs to ensure that the initial state it sends to a client is a full
// state, or the client needs to be able to construct an implicit full state (i.e., get-state
// code needs to be in shared code).
//
// Without this, the client won't be able to reset predicted changes made to this component.
DebugTools.Assert("Received delta state without having received or constructed an implicit full state");
continue;
}
DebugTools.Assert(old is not IComponentDeltaState, "last state is not a full state");
if (!cloneDelta)
{
delta.ApplyToFullState(old!);
continue;
}
var newFull = delta.CreateNewFullState(old!);
compData[change.NetID] = newFull;
DebugTools.Assert(newFull is not IComponentDeltaState, "constructed state is not a full state");
}
if (entityState.NetComponents == null)
@@ -305,7 +305,7 @@ public abstract class SharedUserInterfaceSystem : EntitySystem
private void OnUserInterfaceGetState(Entity<UserInterfaceComponent> ent, ref ComponentGetState args)
{
if (ent.Comp.LastFieldUpdate >= args.FromTick)
if (args.FromTick > ent.Comp.CreationTick && ent.Comp.LastFieldUpdate >= args.FromTick)
{
var fields = EntityManager.GetModifiedFields(ent.Comp, args.FromTick);