From 56a156ee87adcf08bc854a4db3b78c51849341ef Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 8 Aug 2026 09:31:24 +0100 Subject: [PATCH] Complete the Hangar to Terminus runtime path --- Aetheria.State.Daemon.Smoke/Program.cs | 6 ++- Aetheria.State.Daemon/Program.cs | 18 ++++--- Aetheria.State/AetheriaRuntimeStateMapper.cs | 53 +++++++++++++++++++ .../Assets/Editor/AetheriaUnityBuild.cs | 2 +- Aetheria.Unity/Packages/manifest.json | 2 +- Aetheria.Unity/Packages/packages-lock.json | 4 +- .../AetheriaRuntimeHangarSurfaceBuilder.cs | 19 +++++-- scripts/run-aetheria-unity.ps1 | 7 ++- scripts/verify-aetheria-unity-client.ps1 | 12 +++++ 9 files changed, 106 insertions(+), 17 deletions(-) diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index 1f5db9942..59e4cd2fe 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -174,8 +174,12 @@ internal sealed class AetheriaDaemonYmirSmokeChecks template = node.MutableDocument(new CultRecordKey(ship.LoadoutTemplateKey)) .ReadAsync().GetAwaiter().GetResult()!; var surface = AetheriaRuntimeHangarSurfaceBuilder.Build( - hangar, ship.ShipId, AetheriaGameModes.Terminus, "2026-08-08T00:00:01Z", 1, template, runtimeCatalog); + hangar, ship.ShipId, AetheriaGameModes.Terminus, "2026-08-08T00:00:01Z", 1, + AetheriaRuntimeStateMapper.ToRuntimeLoadoutTemplate(template), runtimeCatalog); + var world = surface.Surface.Root.Children.Single(component => component.Kind == "world.scene3d"); Require(surface.Surface.Id == AetheriaRuntimeHangarCommands.SurfaceId && + world.Props.Any(prop => prop.Key == "entityViewPointerId" && !string.IsNullOrWhiteSpace(prop.Value)) && + world.Props.Any(prop => prop.Key == "entityBodyId" && !string.IsNullOrWhiteSpace(prop.Value)) && surface.Commands.Any(command => command.Command == AetheriaRuntimeHangarCommands.EquipItem) && surface.Commands.Any(command => command.Command == AetheriaRuntimeHangarCommands.RemoveItem) && surface.Commands.Any(command => command.Command == AetheriaRuntimeHangarCommands.Launch) && diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index ac4fc3696..42c89bd56 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -502,7 +502,7 @@ static async Task TickAsync( publishTopology: true).ConfigureAwait(false); await PublishSecondaryTopologyDocumentsAsync(node, options, result).ConfigureAwait(false); TracePhase("api-publication"); - await PublishStateSurfacesAsync(node, options, result.Frame.PublishedAtUtc).ConfigureAwait(false); + await PublishStateSurfacesAsync(node, options, result.Frame.PublishedAtUtc, publishHangar: false).ConfigureAwait(false); TracePhase("state-surfaces"); await PublishOdinSurfaceAnnouncementsAsync(node, options, result.Frame.PublishedAtUtc).ConfigureAwait(false); TracePhase("odin-announcements"); @@ -603,7 +603,7 @@ static async Task PersistPreparedDocumentsAsync( if (initialTopology) { await PublishSecondaryTopologyDocumentsAsync(node, options, prepared.Publication).ConfigureAwait(false); - await PublishStateSurfacesAsync(node, options, prepared.Publication.Frame.PublishedAtUtc).ConfigureAwait(false); + await PublishStateSurfacesAsync(node, options, prepared.Publication.Frame.PublishedAtUtc, publishHangar: false).ConfigureAwait(false); await PublishOdinSurfaceAnnouncementsAsync(node, options, prepared.Publication.Frame.PublishedAtUtc).ConfigureAwait(false); } else @@ -2706,7 +2706,8 @@ static async Task AcceptEveCommandsAsync( static async Task PublishStateSurfacesAsync( AetheriaStateNode node, AetheriaDaemonHostOptions options, - string updatedAtUtc) + string updatedAtUtc, + bool publishHangar = true) { var verseHost = await EnsureVerseHostSettingsAsync(node, options, updatedAtUtc).ConfigureAwait(false); var eveStatus = await node.MutableDocument(AetheriaStateNode.EveCommandAcceptanceStatusKey).ReadAsync().ConfigureAwait(false); @@ -2732,7 +2733,7 @@ static async Task PublishStateSurfacesAsync( await node.MutableDocument(AetheriaStateNode.ProviderAdvertisementSurfaceKey) .ReplaceAsync(AetheriaEveSurfaceDocuments.BuildProviderAdvertisement(verseHost, node.StatePath, updatedAtUtc)) .ConfigureAwait(false); - if (hangar != null) + if (publishHangar && hangar != null) await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.HangarSurface) .ReplaceAsync(AetheriaRuntimeSurfaceDocuments.ToPortableSurface( AetheriaRuntimeHangarSurfaceBuilder.Build( @@ -2741,7 +2742,7 @@ static async Task PublishStateSurfacesAsync( AetheriaGameModes.Terminus, updatedAtUtc, Math.Max(1, hangar.Revision), - hangarLoadout, + hangarLoadout == null ? null : AetheriaRuntimeStateMapper.ToRuntimeLoadoutTemplate(hangarLoadout), node.RuntimeCatalog().Latest()))) .ConfigureAwait(false); await node.FlushAsync().ConfigureAwait(false); @@ -3199,7 +3200,12 @@ static async Task PublishRuntimeSessionAsync( Status = status }) .ConfigureAwait(false); - await PublishStateSurfacesAsync(node, options, now).ConfigureAwait(false); + await PublishStateSurfacesAsync( + node, + options, + now, + publishHangar: !string.Equals(status, "running", StringComparison.Ordinal) && + !string.Equals(status, "completed", StringComparison.Ordinal)).ConfigureAwait(false); } static async Task EnsureWorldDocumentAsync(AetheriaStateNode node) diff --git a/Aetheria.State/AetheriaRuntimeStateMapper.cs b/Aetheria.State/AetheriaRuntimeStateMapper.cs index 62a87d63c..847de4f4d 100644 --- a/Aetheria.State/AetheriaRuntimeStateMapper.cs +++ b/Aetheria.State/AetheriaRuntimeStateMapper.cs @@ -67,6 +67,18 @@ public static class AetheriaRuntimeStateMapper }; } + public static AetheriaRuntimeLoadoutTemplateCommit ToRuntimeLoadoutTemplate( + AetheriaLoadoutTemplate loadout) + { + if (loadout == null) throw new ArgumentNullException(nameof(loadout)); + return new AetheriaRuntimeLoadoutTemplateCommit + { + Name = loadout.Name, + OwnerPlayerKey = loadout.OwnerPlayerKey, + RootEntity = ToRuntimeEntityLoadout(loadout.RootEntity) + }; + } + public static CultRecordKey LoadoutKey(string name) { return new CultRecordKey($"global:aetheria.loadout_template.{StableToken(name)}.v1"); @@ -94,6 +106,47 @@ public static class AetheriaRuntimeStateMapper }; } + private static AetheriaRuntimeEntityLoadoutCommit ToRuntimeEntityLoadout(AetheriaEntityLoadout entity) => new() + { + Name = entity.Name, + Kind = entity.Kind, + FactionKey = entity.FactionKey, + Hull = ToRuntimeLoadoutItem(entity.Hull), + Equipment = (entity.Equipment ?? []).Select(ToRuntimeItemSlot).ToArray(), + CargoBays = (entity.CargoBays ?? []).Select(ToRuntimeItemSlot).ToArray(), + DockingBays = (entity.DockingBays ?? []).Select(ToRuntimeItemSlot).ToArray(), + CargoContents = (entity.CargoContents ?? []).Select(value => new AetheriaRuntimeCargoBayLoadoutCommit + { + Items = (value.Items ?? []).Select(ToRuntimeItemSlot).ToArray() + }).ToArray(), + DockingBayContents = (entity.DockingBayContents ?? []).Select(value => new AetheriaRuntimeCargoBayLoadoutCommit + { + Items = (value.Items ?? []).Select(ToRuntimeItemSlot).ToArray() + }).ToArray(), + DockingBayAssignments = (entity.DockingBayAssignments ?? []).ToArray(), + WeaponGroups = (entity.WeaponGroups ?? []).Select(value => (IReadOnlyList)(value ?? []).ToArray()).ToArray(), + Children = (entity.Children ?? []).Select(ToRuntimeEntityLoadout).ToArray() + }; + + private static AetheriaRuntimeLoadoutItemSlotCommit ToRuntimeItemSlot(AetheriaLoadoutItemSlot slot) => new() + { + X = slot.Position?.X ?? 0, + Y = slot.Position?.Y ?? 0, + Rotation = slot.Rotation, + Item = ToRuntimeLoadoutItem(slot.Item) + }; + + private static AetheriaRuntimeLoadoutItemCommit ToRuntimeLoadoutItem(AetheriaLoadoutItem item) => new() + { + ItemKey = item.ItemKey, + Quality = item.Quality, + Durability = item.Durability, + Quantity = item.Quantity, + Enabled = item.Enabled, + OverrideShutdown = item.OverrideShutdown, + Temperature = item.Temperature + }; + private static AetheriaLoadoutItem ToLoadoutItem(AetheriaRuntimeLoadoutItemCommit? item) { item ??= new AetheriaRuntimeLoadoutItemCommit(); diff --git a/Aetheria.Unity/Assets/Editor/AetheriaUnityBuild.cs b/Aetheria.Unity/Assets/Editor/AetheriaUnityBuild.cs index c44046784..9702dcca1 100644 --- a/Aetheria.Unity/Assets/Editor/AetheriaUnityBuild.cs +++ b/Aetheria.Unity/Assets/Editor/AetheriaUnityBuild.cs @@ -20,7 +20,7 @@ public static class AetheriaUnityBuild new[] { scenePath }, "Build/Windows/Aetheria.exe", BuildTarget.StandaloneWindows64, - BuildOptions.Development); + BuildOptions.None); if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded) throw new System.InvalidOperationException("Aetheria Unity build failed: " + report.summary.result); } diff --git a/Aetheria.Unity/Packages/manifest.json b/Aetheria.Unity/Packages/manifest.json index 6dd1e7741..49c03b934 100644 --- a/Aetheria.Unity/Packages/manifest.json +++ b/Aetheria.Unity/Packages/manifest.json @@ -11,6 +11,6 @@ "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.2.3", "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.4", "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.103", - "org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.2" + "org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#befdd6a4a1f0376b40a3103aae811670336c0fee" } } diff --git a/Aetheria.Unity/Packages/packages-lock.json b/Aetheria.Unity/Packages/packages-lock.json index 8f42c31f8..81772b43b 100644 --- a/Aetheria.Unity/Packages/packages-lock.json +++ b/Aetheria.Unity/Packages/packages-lock.json @@ -168,13 +168,13 @@ "hash": "050b2019bd6faa4275013516870d1ded245ee391" }, "org.gamecult.eve.unity-uitoolkit": { - "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.2", + "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#befdd6a4a1f0376b40a3103aae811670336c0fee", "depth": 0, "source": "git", "dependencies": { "org.gamecult.eve.surface": "0.2.4" }, - "hash": "44390549775ec535ee31fc60a5bc594f372f4147" + "hash": "befdd6a4a1f0376b40a3103aae811670336c0fee" }, "com.unity.modules.assetbundle": { "version": "1.0.0", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeHangarSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeHangarSurfaceBuilder.cs index c7575dd3b..1be7af3f4 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeHangarSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeHangarSurfaceBuilder.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using Aetheria.State.Documents; #nullable enable @@ -30,7 +29,7 @@ namespace GameCult.Aetheria.State.Verse string selectedMode, string updatedAtUtc, long version = 1, - AetheriaLoadoutTemplate? loadout = null, + AetheriaRuntimeLoadoutTemplateCommit? loadout = null, AetheriaRuntimeCatalogSnapshot? catalog = null) { if (hangar == null) throw new ArgumentNullException(nameof(hangar)); @@ -40,7 +39,7 @@ namespace GameCult.Aetheria.State.Verse var mode = AetheriaGameModes.IsKnown(selectedMode) ? selectedMode : AetheriaGameModes.Terminus; var canLaunch = selected != null && loadout != null && string.Equals(selected.Status, AetheriaHangarShipStatuses.Available, StringComparison.Ordinal); var canContinue = selected != null && string.Equals(selected.Status, AetheriaHangarShipStatuses.Deployed, StringComparison.Ordinal) && !string.IsNullOrWhiteSpace(selected.ActiveDeploymentId); - var equipment = loadout?.RootEntity?.Equipment ?? Array.Empty(); + var equipment = loadout?.RootEntity?.Equipment ?? Array.Empty(); var inventory = hangar.Inventory ?? Array.Empty(); var root = Component( @@ -49,6 +48,16 @@ namespace GameCult.Aetheria.State.Verse Props(("title", "HANGAR"), ("selectedMode", mode), ("hangarRevision", hangar.Revision.ToString(CultureInfo.InvariantCulture))), new[] { + Component("aetheria.hangar.world", "world.scene3d", Props( + ("statePointerId", AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), + ("entityViewPointerId", AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString()), + ("entityViewSchema", GameCult.Eve.Surface.EveEntitySoaViewDocument.SchemaId), + ("entityBodyId", AetheriaRuntimeDaemonSoaFramePublisher.BodyId), + ("zoneRenderPointerId", AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest.ToString()), + ("zoneRenderSchema", AetheriaRuntimeDaemonSchemas.ZoneRender), + ("assetManifest", AetheriaRuntimeVerseRecordKeys.EveAssetCatalog.ToString()), + ("cameraRig", "hangar-static"), + ("viewId", "aetheria.hangar")), Array.Empty()), Panel("aetheria.hangar.ship_summary", "SHIP", selected == null ? new[] { Text("aetheria.hangar.ship.none", "No ship selected") } : new[] @@ -75,7 +84,7 @@ namespace GameCult.Aetheria.State.Verse Panel("aetheria.hangar.loadout", "LOADOUT", equipment.Select((slot, index) => Button( $"aetheria.hangar.loadout.item.{index}", - $"{ItemName(catalog, slot.Item?.ItemKey)} [{slot.Position?.X ?? 0},{slot.Position?.Y ?? 0}] REMOVE", + $"{ItemName(catalog, slot.Item?.ItemKey)} [{slot.X},{slot.Y}] REMOVE", AetheriaRuntimeHangarCommands.RemoveItem, ("shipId", selected?.ShipId ?? ""), ("equipmentIndex", index.ToString(CultureInfo.InvariantCulture)), @@ -159,7 +168,7 @@ namespace GameCult.Aetheria.State.Verse Component(id, "text", Props(("value", value)), Array.Empty()); private static AetheriaRuntimeSurfaceComponent Button(string id, string label, string command, params (string Key, string Value)[] extra) => - Component(id, "button", Props(new[] { ("label", label), ("command", command) }.Concat(extra).ToArray()), Array.Empty()); + Component(id, "control.button", Props(new[] { ("label", label), ("command", command) }.Concat(extra).ToArray()), Array.Empty()); private static AetheriaRuntimeSurfaceCommandTemplate Command(string command, string label) => new AetheriaRuntimeSurfaceCommandTemplate(command, label, AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport); diff --git a/scripts/run-aetheria-unity.ps1 b/scripts/run-aetheria-unity.ps1 index 8cc3817c4..1ec6d0b05 100644 --- a/scripts/run-aetheria-unity.ps1 +++ b/scripts/run-aetheria-unity.ps1 @@ -1,6 +1,7 @@ param( [string] $UnityExe = "C:\Program Files\Unity\Hub\Editor\6000.4.2f1\Editor\Unity.exe", [int] $Port = 3076, + [string] $State = "", [switch] $SkipBuild ) @@ -11,7 +12,11 @@ $artifacts = Join-Path $project "Build\Logs" $clientExe = Join-Path $project "Build\Windows\Aetheria.exe" $daemonProject = Join-Path $root "Aetheria.State.Daemon\Aetheria.State.Daemon.csproj" $importProject = Join-Path $root "Aetheria.State.Import\Aetheria.State.Import.csproj" -$state = Join-Path $project "Build\aetheria-unity.cc" +$state = if ([string]::IsNullOrWhiteSpace($State)) { + Join-Path $project "Build\aetheria-unity.cc" +} else { + [System.IO.Path]::GetFullPath($State) +} $stateRecords = "$state.records" New-Item -ItemType Directory -Force $artifacts | Out-Null diff --git a/scripts/verify-aetheria-unity-client.ps1 b/scripts/verify-aetheria-unity-client.ps1 index ba502d314..bddae87df 100644 --- a/scripts/verify-aetheria-unity-client.ps1 +++ b/scripts/verify-aetheria-unity-client.ps1 @@ -22,6 +22,9 @@ $expected = @{ "org.gamecult.eve.unity-scene" = @( "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.103", "050b2019bd6faa4275013516870d1ded245ee391") + "org.gamecult.eve.unity-uitoolkit" = @( + "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#befdd6a4a1f0376b40a3103aae811670336c0fee", + "befdd6a4a1f0376b40a3103aae811670336c0fee") } foreach ($packageName in $expected.Keys) { @@ -114,6 +117,15 @@ foreach ($forbiddenInput in @("AetheriaRuntimeVerseSchemas", "AetheriaRuntimeVer if ($bootstrapSource -match [regex]::Escape($forbiddenInput)) { throw "Client bootstrap depends on forbidden product input '$forbiddenInput'." } } +$uiToolkitPackage = Get-ChildItem (Join-Path $ProjectPath "Library/PackageCache") -Directory | + Where-Object Name -Like "org.gamecult.eve.unity-uitoolkit@*" | + Select-Object -First 1 +if (-not $uiToolkitPackage) { throw "Resolved Eve Unity UI Toolkit package is missing from Library/PackageCache." } +$uiToolkitLowererSource = Get-Content (Join-Path $uiToolkitPackage.FullName "Runtime/EveUiToolkitSurfaceLowerer.cs") -Raw +if ($uiToolkitLowererSource -notmatch 'unity-uitoolkit-.*Guid\.NewGuid') { + throw "Resolved Eve Unity UI Toolkit commands do not mint invocation-scoped idempotency keys." +} + $launcherSource = Get-Content (Join-Path (Split-Path $PSScriptRoot -Parent) "scripts/run-aetheria-unity.ps1") -Raw if ($launcherSource -notmatch 'EVEUNITY_SURFACE_ID\s*=\s*"aetheria\.hangar"') { throw "Released launcher must enter through the daemon-owned Hangar surface."