Stop rebuilding Unity zone entity membership
This commit is contained in:
parent
348f83a7f5
commit
a2ce1b27d9
2 changed files with 6 additions and 19 deletions
|
|
@ -7755,7 +7755,7 @@ static void RequireMainMenuContinueRunState(string root)
|
|||
"CanApplyDaemonEntitySnapshotsInPlace",
|
||||
"ZoneRenderer?.ApplyDaemonFrame(daemonZone, run)",
|
||||
"ApplyDaemonEntitySnapshotsInPlace",
|
||||
"ReplaceZoneEntitiesFromTypedSnapshots",
|
||||
"ReplaceObservedEntityFacadesFromTypedSnapshots",
|
||||
"RestoreCurrentEntityBinding",
|
||||
"RestoreCurrentEntityBinding(currentEntity, actionBarBindings)",
|
||||
"RestoreActiveConsumablesFromTypedEntitySnapshot(entity, entitySnapshot)",
|
||||
|
|
@ -8070,7 +8070,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
|
|||
"daemonZone?.Orbits ?? Array.Empty<AetheriaRuntimeOrbitSnapshotCommit>()",
|
||||
"ZoneRenderer.TryGetBodyView(parentOrbitPlanetBodyKey, out var parentBodyView)",
|
||||
"ResolveDaemonObserver()?.LastObservedState?.Run",
|
||||
"ReplaceZoneEntitiesFromTypedSnapshots",
|
||||
"ReplaceObservedEntityFacadesFromTypedSnapshots",
|
||||
"EntityConstructionBlueprintProjector.ProjectObservedFromBlueprint",
|
||||
"public static Galaxy ObservedGalaxy",
|
||||
"TryRequestDaemonMoveVector",
|
||||
|
|
@ -8134,20 +8134,15 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
|
|||
"Unity frame application must project observed daemon state, not instantiate authoritative gameplay entities.");
|
||||
}
|
||||
|
||||
var permittedEntityProjectionMethods = new[]
|
||||
{
|
||||
"ReplaceZoneEntitiesFromTypedSnapshots"
|
||||
};
|
||||
var unauthorizedEntityProjectionHits = FindMethodScopedLineHits(
|
||||
actionGameManager,
|
||||
new[] { "Zone.Entities.Add(", "Zone.Entities.Remove(" })
|
||||
.Where(hit => !permittedEntityProjectionMethods.Contains(hit.MethodName, StringComparer.Ordinal))
|
||||
new[] { "Zone.Entities.Add(", "Zone.Entities.Remove(", "Zone.Agents.Clear()" })
|
||||
.Select(hit => $"{hit.MethodName}:{hit.LineNumber}: {hit.Line.Trim()}")
|
||||
.ToArray();
|
||||
if (unauthorizedEntityProjectionHits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Unity gameplay may only add/remove zone entities while lowering observed daemon snapshots: " +
|
||||
"Unity gameplay must not rebuild renderer-local Zone entity membership while lowering daemon snapshots: " +
|
||||
string.Join("; ", unauthorizedEntityProjectionHits));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2261,7 +2261,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
.Select(ToActionBarBindingSnapshot)
|
||||
.Where(binding => binding != null)
|
||||
.ToArray() ?? Array.Empty<AetheriaRuntimeActionBarBindingSnapshot>();
|
||||
ReplaceZoneEntitiesFromTypedSnapshots(entitySnapshots, currentEntityKey, actionBarBindings);
|
||||
ReplaceObservedEntityFacadesFromTypedSnapshots(entitySnapshots, currentEntityKey, actionBarBindings);
|
||||
ZoneRenderer?.ApplyDaemonFrame(daemonZone, run);
|
||||
RestoreDroppedPickupsFromDaemonZoneState(daemonZone);
|
||||
_lastAppliedAuthoritativeDaemonRunId = runId;
|
||||
|
|
@ -2718,17 +2718,11 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void ReplaceZoneEntitiesFromTypedSnapshots(
|
||||
private void ReplaceObservedEntityFacadesFromTypedSnapshots(
|
||||
IReadOnlyList<AetheriaRuntimeEntitySnapshot> entitySnapshots,
|
||||
string currentEntityKey,
|
||||
IReadOnlyList<AetheriaRuntimeActionBarBindingSnapshot> actionBarBindings)
|
||||
{
|
||||
foreach (var existingEntity in Zone.Entities.ToArray())
|
||||
{
|
||||
Zone.Entities.Remove(existingEntity);
|
||||
}
|
||||
Zone.Agents.Clear();
|
||||
|
||||
var restoredEntities = new Dictionary<string, Entity>();
|
||||
foreach (var entitySnapshot in entitySnapshots)
|
||||
{
|
||||
|
|
@ -2752,8 +2746,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
entity.TractorPower = (float)entitySnapshot.TractorPower;
|
||||
entity.RestoreActiveState(entitySnapshot.IsActive);
|
||||
entity.DaemonEntityIndex = EntityIndexFromRecordKey(entitySnapshot.RecordKey);
|
||||
entity.Zone = Zone;
|
||||
Zone.Entities.Add(entity);
|
||||
restoredEntities[entitySnapshot.RecordKey] = entity;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue