Move ship settings projection into runtime

This commit is contained in:
Meta Vens 2026-06-21 22:04:17 +01:00
commit 99e18e0ca9
3 changed files with 28 additions and 10 deletions

View file

@ -4103,8 +4103,8 @@ static void RequireInventoryShipSettingsUseEveSurface(string root)
"HandleCurrentShipSettingsSurfaceCommand(",
"AetheriaEveUnitySurfaceHost.RenderRuntime(",
"AetheriaEveUnitySurfaceHost.Hide(_shipSettingsSurfaceDocument)",
"AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurfaceState(",
"ProjectCurrentShipSettingsSurfaceState(",
"AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurface(",
"AetheriaRuntimeShipSettingsSurfaceBuilder.Project(",
"AetheriaRuntimeShipSettingsSurfaceCommands.TryRead(request, out var command)",
"AetheriaRuntimeShipSettingsCommandKind.DecrementShutdownThreshold",
"AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold",
@ -4143,7 +4143,8 @@ static void RequireInventoryShipSettingsUseEveSurface(string root)
"switch (request.Command)",
"var entity = GameManager.CurrentEntity",
"GameManager.CurrentEntity == null",
"RenderCurrentShipSettingsSurface(GameManager.CurrentEntity)"
"RenderCurrentShipSettingsSurface(GameManager.CurrentEntity)",
"new AetheriaRuntimeShipSettingsSurfaceState("
};
var hits = forbiddenSymbols
@ -4170,6 +4171,7 @@ static void RequireInventoryShipSettingsUseEveSurface(string root)
"public static class AetheriaRuntimeShipSettingsSurfaceCommands",
"public static bool TryRead(",
"AetheriaRuntimeShipSettingsSurfaceState",
"public static AetheriaRuntimeShipSettingsSurfaceState Project(",
"public static AetheriaRuntimeSurfaceDocument Build("
};
var missingBuilderSymbols = requiredBuilderSymbols

View file

@ -179,7 +179,7 @@ public class InventoryMenu : MonoBehaviour
transform,
_shipSettingsSurfaceDocument,
"Aetheria Inventory Ship Settings Surface",
AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurfaceState(entity)),
AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurface(entity)),
HandleCurrentShipSettingsSurfaceCommand,
_shipSettingsSurfaceChrome);
}
@ -238,14 +238,12 @@ public class InventoryMenu : MonoBehaviour
AetheriaEveUnitySurfaceHost.Hide(_shipSettingsSurfaceDocument);
}
private static AetheriaRuntimeShipSettingsSurfaceState ProjectCurrentShipSettingsSurfaceState(Entity entity)
private static AetheriaRuntimeShipSettingsSurfaceState ProjectCurrentShipSettingsSurface(Entity entity)
{
return new AetheriaRuntimeShipSettingsSurfaceState(
return AetheriaRuntimeShipSettingsSurfaceBuilder.Project(
entity?.Name ?? "",
entity == null
? ""
: ActionGameManager.RuntimePlayerSettings.Format(entity.Settings.ShutdownPerformance),
DateTime.UtcNow.ToString("O"));
entity?.Settings?.ShutdownPerformance ?? 0f,
ActionGameManager.RuntimePlayerSettings.Format);
}
private void RenderCargoItemDetailsSurface(ItemInstance item)

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using GameCult.Eve.Surface;
@ -30,6 +31,23 @@ namespace GameCult.Aetheria.State.Verse
public const string ResetShutdownThreshold = "aetheria.inventory.current_ship_settings.shutdown.reset";
public const string Close = "aetheria.inventory.current_ship_settings.close";
public static AetheriaRuntimeShipSettingsSurfaceState Project(
string shipName,
float shutdownPerformance,
Func<float, string> formatShutdownPerformance,
DateTime updatedAtUtc = default(DateTime))
{
if (updatedAtUtc == default(DateTime))
updatedAtUtc = DateTime.UtcNow;
return new AetheriaRuntimeShipSettingsSurfaceState(
shipName,
formatShutdownPerformance == null
? shutdownPerformance.ToString("0.###", CultureInfo.InvariantCulture)
: formatShutdownPerformance(shutdownPerformance),
updatedAtUtc.ToString("O", CultureInfo.InvariantCulture));
}
public static AetheriaRuntimeSurfaceDocument Build(
AetheriaRuntimeShipSettingsSurfaceState state,
long version = 1)