From 7a5a154031539744731763281d2bc7ecbf791d3c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 21 Jun 2026 23:31:00 +0100 Subject: [PATCH] Resolve Eve state refs in the Unity surface host --- Aetheria.State.Verify/Program.cs | 9 +++++- Assets/Scripts/UI/Menu/InventoryMenu.cs | 15 +++------- .../Runtime/AetheriaEveUnitySurfaceHost.cs | 8 +++-- ...theriaRuntimeShipSettingsSurfaceBuilder.cs | 30 +++++++++++++++++++ 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index c7721fde2..5d09af05d 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4216,6 +4216,7 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold", "AetheriaRuntimeShipSettingsCommandKind.ResetShutdownThreshold", "AetheriaRuntimeShipSettingsCommandKind.Close", + "AetheriaRuntimeShipSettingsSurfaceCommands.ResolveShutdownPerformance(", "GameManager.TryGetObservedCurrentEntity(out var currentEntity)", "GameManager.TryGetObservedCurrentEntity(out var entity)" }; @@ -4247,6 +4248,9 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "() => GameManager.CurrentEntity.Settings.ShutdownPerformance", "f => GameManager.RequestEntityShutdownPerformance(GameManager.CurrentEntity, f)", "switch (request.Command)", + "ShutdownThresholdStep", + "Mathf.Clamp01(entity.Settings.ShutdownPerformance", + "Mathf.Clamp01(GameManager.Settings.GameplaySettings.DefaultShutdownPerformance", "var entity = GameManager.CurrentEntity", "GameManager.CurrentEntity == null", "RenderCurrentShipSettingsSurface(GameManager.CurrentEntity)", @@ -4278,7 +4282,9 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "public static bool TryRead(", "AetheriaRuntimeShipSettingsSurfaceState", "public static AetheriaRuntimeShipSettingsSurfaceState Project(", - "public static AetheriaRuntimeSurfaceDocument Build(" + "public static AetheriaRuntimeSurfaceDocument Build(", + "public static float ResolveShutdownPerformance(", + "public static float ClampShutdownPerformance(" }; var missingBuilderSymbols = requiredBuilderSymbols .Where(symbol => !shipSettingsSurfaceBuilder.Contains(symbol, StringComparison.Ordinal)) @@ -4432,6 +4438,7 @@ static void RequireInventoryCargoItemDetailsUseEveSurface(string root) !unityProject.Contains("AetheriaRuntimeDaemonItemStatQueries.cs", StringComparison.Ordinal) || !eveUnitySurfaceHost.Contains("Func stateRefResolver", StringComparison.Ordinal) || !eveUnitySurfaceHost.Contains("ContainsStateRefs(surface)", StringComparison.Ordinal) || + !eveUnitySurfaceHost.Contains("prop.Key.EndsWith(\"Ref\", StringComparison.Ordinal)", StringComparison.Ordinal) || !eveUnitySurfaceHost.Contains("CreateDefaultStateRefResolver()", StringComparison.Ordinal) || !eveUnitySurfaceHost.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver(stateBoot.StateFilePath)", StringComparison.Ordinal) || !runtimeEveSurfaceAdapter.Contains("public static EveSurfaceDocument ResolveStateRefs(", StringComparison.Ordinal) || diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index 7e7539bc6..9169ee88f 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -17,8 +17,6 @@ using UnityEngine.UIElements; public class InventoryMenu : MonoBehaviour { - private const float ShutdownThresholdStep = 0.05f; - public InventoryPanel[] InventoryPanels; public ActionGameManager GameManager; public ConfirmationDialog Dialog; @@ -207,19 +205,14 @@ public class InventoryMenu : MonoBehaviour switch (command.Kind) { case AetheriaRuntimeShipSettingsCommandKind.DecrementShutdownThreshold: - GameManager.RequestEntityShutdownPerformance( - entity, - Mathf.Clamp01(entity.Settings.ShutdownPerformance - ShutdownThresholdStep)); - return; case AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold: - GameManager.RequestEntityShutdownPerformance( - entity, - Mathf.Clamp01(entity.Settings.ShutdownPerformance + ShutdownThresholdStep)); - return; case AetheriaRuntimeShipSettingsCommandKind.ResetShutdownThreshold: GameManager.RequestEntityShutdownPerformance( entity, - Mathf.Clamp01(GameManager.Settings.GameplaySettings.DefaultShutdownPerformance)); + AetheriaRuntimeShipSettingsSurfaceCommands.ResolveShutdownPerformance( + command.Kind, + entity.Settings.ShutdownPerformance, + GameManager.Settings.GameplaySettings.DefaultShutdownPerformance)); return; case AetheriaRuntimeShipSettingsCommandKind.Close: HideCurrentShipSettingsSurface(); diff --git a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs index a4c42f443..8587a3d9f 100644 --- a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs +++ b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using GameCult.Aetheria.State.Verse; using GameCult.Eve.Surface; using GameCult.Eve.UnityUIToolkit; @@ -202,9 +203,10 @@ namespace GameCult.Aetheria.EveRuntime private static bool ContainsStateRefs(EveSurfaceComponent component) { if (component.Props != null && - (component.Props.ContainsKey(AetheriaRuntimeSurfaceStateRefs.Source) || - component.Props.ContainsKey(AetheriaRuntimeSurfaceStateRefs.Value) || - component.Props.ContainsKey(AetheriaRuntimeSurfaceStateRefs.Label))) + component.Props.Any(prop => + !string.IsNullOrWhiteSpace(prop.Value) && + (string.Equals(prop.Key, AetheriaRuntimeSurfaceStateRefs.Source, StringComparison.Ordinal) || + prop.Key.EndsWith("Ref", StringComparison.Ordinal)))) { return true; } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs index d8d06c45b..0ead307ed 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs @@ -158,6 +158,8 @@ namespace GameCult.Aetheria.State.Verse public static class AetheriaRuntimeShipSettingsSurfaceCommands { + public const float DefaultShutdownThresholdStep = 0.05f; + public static bool TryRead( EveSurfaceCommandRequest request, out AetheriaRuntimeShipSettingsCommand command) @@ -189,5 +191,33 @@ namespace GameCult.Aetheria.State.Verse return false; } } + + public static float ResolveShutdownPerformance( + AetheriaRuntimeShipSettingsCommandKind kind, + float currentShutdownPerformance, + float defaultShutdownPerformance, + float shutdownThresholdStep = DefaultShutdownThresholdStep) + { + switch (kind) + { + case AetheriaRuntimeShipSettingsCommandKind.DecrementShutdownThreshold: + return ClampShutdownPerformance(currentShutdownPerformance - shutdownThresholdStep); + case AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold: + return ClampShutdownPerformance(currentShutdownPerformance + shutdownThresholdStep); + case AetheriaRuntimeShipSettingsCommandKind.ResetShutdownThreshold: + return ClampShutdownPerformance(defaultShutdownPerformance); + default: + return ClampShutdownPerformance(currentShutdownPerformance); + } + } + + public static float ClampShutdownPerformance(float value) + { + if (float.IsNaN(value)) + return 0f; + if (value <= 0f) + return 0f; + return value >= 1f ? 1f : value; + } } }