Move observed sector projection into gameplay boot

This commit is contained in:
Meta Vens 2026-06-28 08:34:28 +01:00
commit 5b7a5b3a8c
5 changed files with 79 additions and 65 deletions

View file

@ -49,7 +49,7 @@ public class ActionGameManager : MonoBehaviour
_observedZoneContextProjector ??= new AetheriaUnityObservedZoneContextProjector(
ItemManager,
Settings.PlanetSettings,
() => AetheriaUnityObservedRunProjection.Galaxy,
() => ObservedGalaxy,
Debug.LogWarning,
PlayMusic);
private AetheriaUnityCurrentEntityBinder CurrentEntityBinder =>
@ -96,7 +96,7 @@ public class ActionGameManager : MonoBehaviour
private AetheriaUnityObservedFrameApplier ObservedFrameApplier =>
_observedFrameApplier ??= new AetheriaUnityObservedFrameApplier(
ResolveDaemonObserver,
AetheriaUnityObservedRunProjection.FindZone,
zoneIndex => AetheriaUnityObservedRunProjection.FindZone(ObservedGalaxy, zoneIndex),
() => Zone,
zone => Zone = zone,
_observedEntityIndex,
@ -292,6 +292,7 @@ public class ActionGameManager : MonoBehaviour
private ItemManager ItemManager { get; set; }
private AetheriaUnityLoadoutItemProjector _loadoutItemProjector;
private Galaxy ObservedGalaxy { get; set; }
private Zone Zone { get; set; }
private readonly AetheriaUnityDragSession _dragSession = new AetheriaUnityDragSession();
@ -319,6 +320,7 @@ public class ActionGameManager : MonoBehaviour
var boot = GameplayBootShell.Boot();
ItemManager = boot.ItemManager;
_loadoutItemProjector = boot.LoadoutItemProjector;
ObservedGalaxy = boot.ObservedGalaxy;
SceneWiring.ConfigureCurrentEntityPresentation(_currentEntityPresentation, boot.RuntimeCatalog);
SceneWiring.ConfigureTargetPresentation(
_targetPresentation,

View file

@ -34,13 +34,27 @@ public sealed class AetheriaUnityGameplayBootShell
$"Aetheria runtime state file is missing at {stateBoot.StateFilePath}; gameplay requires an authoritative daemon mirror.");
}
var runtimeCatalog = AetheriaUnityRuntimeClientProvider.ResolveClient(stateBoot.StateFilePath, stateBoot.RuntimeId)
.Aetheria()
.LatestCatalog();
var aetheria = AetheriaUnityRuntimeClientProvider.ResolveClient(stateBoot.StateFilePath, stateBoot.RuntimeId)
.Aetheria();
var runtimeCatalog = aetheria.LatestCatalog();
if (runtimeCatalog == null)
throw new InvalidOperationException("Aetheria typed runtime catalog is required before gameplay boot.");
var sectorMap = aetheria.LatestSectorMap();
if (sectorMap == null)
throw new InvalidOperationException("Aetheria typed sector map is required before gameplay boot.");
Log?.Invoke($"Aetheria runtime catalog: {runtimeCatalog.Items.Count} items, {runtimeCatalog.Corporations.Count} corporations, {runtimeCatalog.NameFiles.Count} name files");
Log?.Invoke($"Aetheria observed sector-map frame: {sectorMap.FrameId}");
var backgroundSettings = sectorMap.IsTutorial
? Settings.TutorialBackgroundSettings
: Settings.SectorBackgroundSettings;
backgroundSettings.NoisePosition = sectorMap.GenerationSeed == 0 ? 1 : sectorMap.GenerationSeed;
var observedGalaxy = AetheriaUnityObservedRunProjection.Project(
sectorMap,
backgroundSettings,
runtimeCatalog,
Log);
var itemManager = new ItemManager(
runtimeCatalog,
@ -60,6 +74,7 @@ public sealed class AetheriaUnityGameplayBootShell
return new AetheriaUnityGameplayBootResult(
runtimeCatalog,
observedGalaxy,
itemManager,
loadoutItemProjector);
}
@ -104,15 +119,18 @@ public readonly struct AetheriaUnityGameplayBootResult
{
public AetheriaUnityGameplayBootResult(
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
Galaxy observedGalaxy,
ItemManager itemManager,
AetheriaUnityLoadoutItemProjector loadoutItemProjector)
{
RuntimeCatalog = runtimeCatalog;
ObservedGalaxy = observedGalaxy;
ItemManager = itemManager;
LoadoutItemProjector = loadoutItemProjector;
}
public AetheriaRuntimeCatalogSnapshot RuntimeCatalog { get; }
public Galaxy ObservedGalaxy { get; }
public ItemManager ItemManager { get; }
public AetheriaUnityLoadoutItemProjector LoadoutItemProjector { get; }
}

View file

@ -4,18 +4,16 @@ using GameCult.Aetheria.State.Verse;
public static class AetheriaUnityObservedRunProjection
{
public static Galaxy Galaxy { get; private set; }
public static void Project(
public static Galaxy Project(
AetheriaRuntimeSectorMapDocument sectorMap,
SectorBackgroundSettings backgroundSettings,
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
Action<string> log)
{
Galaxy = global::Galaxy.ProjectObservedSectorMap(sectorMap, backgroundSettings, runtimeCatalog, log);
return global::Galaxy.ProjectObservedSectorMap(sectorMap, backgroundSettings, runtimeCatalog, log);
}
public static void Project(
public static Galaxy Project(
AetheriaRuntimeDaemonFrameDocument frame,
SectorBackgroundSettings backgroundSettings,
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
@ -24,14 +22,14 @@ public static class AetheriaUnityObservedRunProjection
if (frame == null || frame.Run == null)
throw new ArgumentNullException(nameof(frame));
Galaxy = global::Galaxy.ProjectObservedDaemonRun(frame.Run, backgroundSettings, runtimeCatalog, log);
return global::Galaxy.ProjectObservedDaemonRun(frame.Run, backgroundSettings, runtimeCatalog, log);
}
public static GalaxyZone FindZone(int daemonZoneIndex)
public static GalaxyZone FindZone(Galaxy galaxy, int daemonZoneIndex)
{
return daemonZoneIndex < 0
? null
: Galaxy?.Zones?.FirstOrDefault(zone => zone != null && zone.ZoneIndex == daemonZoneIndex);
: galaxy?.Zones?.FirstOrDefault(zone => zone != null && zone.ZoneIndex == daemonZoneIndex);
}
public static AetheriaRuntimeZoneSnapshotCommit FindZoneSnapshot(AetheriaRuntimeRunCheckpointCommit run)