Preserve daemon zone identity in projected galaxy
This commit is contained in:
parent
73ea4ad5bb
commit
7440eda8a9
3 changed files with 39 additions and 10 deletions
|
|
@ -8062,6 +8062,8 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
|
|||
"ResolveDaemonObserver()",
|
||||
"public AetheriaRuntimeZoneSnapshotCommit FindDaemonZoneSnapshot(GalaxyZone zone)",
|
||||
"public GalaxyZone CurrentDaemonGalaxyZone",
|
||||
"zone?.ZoneIndex ?? -1",
|
||||
"FindObservedGalaxyZone(run.CurrentZoneIndex)",
|
||||
"observed.IsAuthoritative",
|
||||
"TryRestoreEntityGraphFromDaemonRun(observed.Run)",
|
||||
"CreateDaemonZoneConstructionBlueprint(daemonZone)",
|
||||
|
|
@ -8144,12 +8146,34 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
|
|||
"Unity gameplay must not cache observed runtime zone context on the projected GalaxyZone model.");
|
||||
}
|
||||
|
||||
if (actionGameManager.Contains("ObservedGalaxy.Zones[run.CurrentZoneIndex]", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Unity gameplay must resolve observed zones by daemon zone identity, not projected array slot.");
|
||||
}
|
||||
|
||||
if (galaxy.Contains("public Zone Contents", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Projected GalaxyZone must not own Unity runtime Zone contents; observed zone context belongs to the client lowerer.");
|
||||
}
|
||||
|
||||
var requiredObservedZoneIdentitySymbols = new[]
|
||||
{
|
||||
"public int ZoneIndex = -1;",
|
||||
"ZoneIndex = zone.ZoneIndex,",
|
||||
"new GalaxyZone { ZoneIndex = index, Position = v }"
|
||||
};
|
||||
var missingObservedZoneIdentitySymbols = requiredObservedZoneIdentitySymbols
|
||||
.Where(symbol => !galaxy.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (missingObservedZoneIdentitySymbols.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Projected GalaxyZone no longer preserves daemon zone identity: " +
|
||||
string.Join(", ", missingObservedZoneIdentitySymbols));
|
||||
}
|
||||
|
||||
var contextPrepRendererLoads = FindMethodScopedLineHits(
|
||||
actionGameManager,
|
||||
new[] { "LoadDaemonZoneView(", "BindToEntity(" })
|
||||
|
|
|
|||
|
|
@ -853,7 +853,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
private static int ZoneIndex(GalaxyZone zone)
|
||||
{
|
||||
return ObservedGalaxy?.Zones == null || zone == null ? -1 : Array.IndexOf(ObservedGalaxy.Zones, zone);
|
||||
return zone?.ZoneIndex ?? -1;
|
||||
}
|
||||
|
||||
private static GalaxyZone FindObservedGalaxyZone(int daemonZoneIndex)
|
||||
{
|
||||
return daemonZoneIndex < 0
|
||||
? null
|
||||
: ObservedGalaxy?.Zones?.FirstOrDefault(zone => zone != null && zone.ZoneIndex == daemonZoneIndex);
|
||||
}
|
||||
|
||||
public AetheriaRuntimeZoneSnapshotCommit FindDaemonZoneSnapshot(GalaxyZone zone)
|
||||
|
|
@ -872,11 +879,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
get
|
||||
{
|
||||
var run = ResolveDaemonObserver()?.LastObservedState?.Run;
|
||||
return run?.CurrentZoneIndex >= 0 &&
|
||||
ObservedGalaxy?.Zones != null &&
|
||||
run.CurrentZoneIndex < ObservedGalaxy.Zones.Length
|
||||
? ObservedGalaxy.Zones[run.CurrentZoneIndex]
|
||||
: null;
|
||||
return FindObservedGalaxyZone(run?.CurrentZoneIndex ?? -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2231,9 +2234,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
return false;
|
||||
}
|
||||
|
||||
var targetZone = run.CurrentZoneIndex < ObservedGalaxy.Zones.Length
|
||||
? ObservedGalaxy.Zones[run.CurrentZoneIndex]
|
||||
: null;
|
||||
var targetZone = FindObservedGalaxyZone(run.CurrentZoneIndex);
|
||||
if (targetZone == null)
|
||||
{
|
||||
Debug.LogWarning($"Authoritative daemon frame references missing zone index {run.CurrentZoneIndex}.");
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ public class Galaxy
|
|||
.OrderBy(zone => zone.ZoneIndex)
|
||||
.Select(zone => new GalaxyZone
|
||||
{
|
||||
ZoneIndex = zone.ZoneIndex,
|
||||
Name = string.IsNullOrWhiteSpace(zone.Name) ? $"Daemon Zone {zone.ZoneIndex}" : zone.Name,
|
||||
Position = new float2((float)zone.PositionX, (float)zone.PositionY),
|
||||
Factions = ResolveDaemonZoneFactions(zone),
|
||||
|
|
@ -351,7 +352,9 @@ public class Galaxy
|
|||
Background.CloudDensity,
|
||||
v => (.2f - LengthSquared(v - new float2(.5f, .5f))) * 4,
|
||||
progressCallback);
|
||||
return outputSamples.Select(v => new GalaxyZone {Position = v}).ToArray();
|
||||
return outputSamples
|
||||
.Select((v, index) => new GalaxyZone { ZoneIndex = index, Position = v })
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static Faction[] ProjectFactions(AetheriaRuntimeCatalogSnapshot runtimeCatalog)
|
||||
|
|
@ -736,6 +739,7 @@ public class Galaxy
|
|||
|
||||
public class GalaxyZone
|
||||
{
|
||||
public int ZoneIndex = -1;
|
||||
public string Name;
|
||||
public float2 Position;
|
||||
public List<GalaxyZone> AdjacentZones = new List<GalaxyZone>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue