Resolve Eve state refs in the Unity surface host
This commit is contained in:
parent
eaa3f0e6ed
commit
7a5a154031
4 changed files with 47 additions and 15 deletions
|
|
@ -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<string, string> 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) ||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue