Integrate CultMesh UI and URP cleanup
This commit is contained in:
parent
932cc9f906
commit
4d7bb65868
131 changed files with 7209 additions and 5084 deletions
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -69,6 +70,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
private SchematicDisplayItem[] _schematicItems;
|
||||
private AetherDrive _aetherDrive;
|
||||
private AetheriaRuntimeDaemonRenderSettings? _renderSettings;
|
||||
private AetheriaClientState _runtimeState;
|
||||
|
||||
private bool _enemy;
|
||||
private Entity _player;
|
||||
|
|
@ -92,6 +94,15 @@ public class SchematicDisplay : MonoBehaviour
|
|||
_renderSettings = renderSettings;
|
||||
}
|
||||
|
||||
private AetheriaClientState RuntimeState
|
||||
{
|
||||
get
|
||||
{
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-schematic-display");
|
||||
return _runtimeState;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowShip(Entity entity, Entity player = null)
|
||||
{
|
||||
_enemy = player != null;
|
||||
|
|
@ -318,7 +329,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-schematic-display");
|
||||
return RuntimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -332,7 +343,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-schematic-display");
|
||||
return RuntimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -346,9 +357,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentEntityState("unity-schematic-display")
|
||||
?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();
|
||||
return RuntimeState.CurrentEntity.Latest()?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
|
@ -18,6 +19,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
private string _captureActionName = "";
|
||||
private int _captureBindingIndex = -1;
|
||||
private string _captureBindingLabel = "";
|
||||
private AetheriaClientState _runtimeState;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _surfaceChrome = new AetheriaEveUnitySurfaceChrome
|
||||
{
|
||||
RootAlignItems = Align.Center,
|
||||
|
|
@ -368,8 +370,10 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings(RequireLocalStateBoot(), "unity-input-screen");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState(
|
||||
RequireLocalStateBoot(),
|
||||
"unity-input-screen");
|
||||
return _runtimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UIElements;
|
||||
using UiButton = UnityEngine.UIElements.Button;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
|
|
@ -15,37 +18,46 @@ public class MainMenu : MonoBehaviour
|
|||
public GameSettings Settings;
|
||||
public ConfirmationDialog Dialog;
|
||||
public bool InGame;
|
||||
public float FadeTime = 0.5f;
|
||||
public float FadeDistance = 512f;
|
||||
public float FadeAlphaExponent = 2f;
|
||||
public float FadePositionExponent = 2f;
|
||||
public float HoverSpacing = 8f;
|
||||
public float HoverAnimationDuration = 0.16f;
|
||||
|
||||
private UIDocument _menuSurfaceDocument;
|
||||
private UIDocument _currentMenuSurfaceDocument;
|
||||
private UIDocument _nextMenuSurfaceDocument;
|
||||
private Func<bool> _canOpenRuntimeInputScreen;
|
||||
private Action _openRuntimeInputScreen;
|
||||
private bool _fadeFromRight;
|
||||
private bool _fading;
|
||||
private float _fadeLerp;
|
||||
private readonly List<MenuHoverButton> _hoverButtons = new List<MenuHoverButton>();
|
||||
private readonly AetheriaEveUnitySurfaceChrome _menuSurfaceChrome = new AetheriaEveUnitySurfaceChrome
|
||||
{
|
||||
RootAlignItems = Align.Center,
|
||||
RootJustifyContent = Justify.Center,
|
||||
RootPaddingLeft = 24f,
|
||||
UseShell = false,
|
||||
RootAlignItems = Align.FlexStart,
|
||||
RootJustifyContent = Justify.FlexStart,
|
||||
RootPaddingLeft = 96f,
|
||||
RootPaddingTop = 92f,
|
||||
RootPaddingRight = 24f,
|
||||
RootPaddingTop = 24f,
|
||||
RootPaddingBottom = 24f,
|
||||
RootBackgroundColor = new Color(0f, 0f, 0f, 0.6f),
|
||||
Width = 560f,
|
||||
MinWidth = 0f,
|
||||
MaxWidth = 560f,
|
||||
PaddingLeft = 20f,
|
||||
PaddingRight = 20f,
|
||||
PaddingTop = 20f,
|
||||
PaddingBottom = 20f,
|
||||
BorderRadius = 0f,
|
||||
BorderWidth = 0f,
|
||||
BackgroundColor = new Color(0.08f, 0.1f, 0.14f, 0.96f)
|
||||
RootBackgroundColor = new Color(0f, 0f, 0f, 0f),
|
||||
RootPickingMode = PickingMode.Position
|
||||
};
|
||||
|
||||
void Start()
|
||||
{
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
}
|
||||
|
||||
private void ShowMain()
|
||||
void Update()
|
||||
{
|
||||
UpdateMenuFade();
|
||||
UpdateHoverButtons();
|
||||
}
|
||||
|
||||
private void ShowMain(bool animateFromRight = true)
|
||||
{
|
||||
var stateBoot = CurrentStateBoot();
|
||||
var sectorMap = ResolveSectorMap(stateBoot);
|
||||
|
|
@ -60,7 +72,8 @@ public class MainMenu : MonoBehaviour
|
|||
CanOpenRuntimeInputScreen(),
|
||||
InGame,
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
HandleMainSurfaceCommand);
|
||||
HandleMainSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void HandleMainSurfaceCommand(EveSurfaceCommandRequest request)
|
||||
|
|
@ -77,7 +90,7 @@ public class MainMenu : MonoBehaviour
|
|||
if (ResolveSectorMap(CurrentStateBoot()) == null)
|
||||
{
|
||||
Debug.LogWarning("Main-menu Continue requested without a typed Aetheria sector-map projection.");
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +100,7 @@ public class MainMenu : MonoBehaviour
|
|||
StartNewGame();
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.Quit:
|
||||
Application.Quit();
|
||||
|
|
@ -102,7 +115,7 @@ public class MainMenu : MonoBehaviour
|
|||
{
|
||||
if (!TryStartDaemonObservedGame("Starting Daemon Run"))
|
||||
{
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +158,9 @@ public class MainMenu : MonoBehaviour
|
|||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentSectorMap(stateBoot, "unity-main-menu");
|
||||
.RuntimeState(stateBoot, "unity-main-menu")
|
||||
.SectorMap
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -162,7 +177,9 @@ public class MainMenu : MonoBehaviour
|
|||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings(stateBoot, "unity-main-menu");
|
||||
.RuntimeState(stateBoot, "unity-main-menu")
|
||||
.PlayerSettings
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -179,7 +196,9 @@ public class MainMenu : MonoBehaviour
|
|||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentVerseHostSettings(stateBoot, "unity-main-menu");
|
||||
.RuntimeState(stateBoot, "unity-main-menu")
|
||||
.VerseHostSettings
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -192,18 +211,19 @@ public class MainMenu : MonoBehaviour
|
|||
{
|
||||
if (!TryStartDaemonObservedGame("Continuing Daemon Run"))
|
||||
{
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowSettings()
|
||||
private void ShowSettings(bool animateFromRight = true)
|
||||
{
|
||||
RenderMenuSurface(
|
||||
AetheriaRuntimeMainMenuSurfaceBuilder.BuildSettings(DateTime.UtcNow.ToString("O")),
|
||||
HandleSettingsSurfaceCommand);
|
||||
HandleSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void ShowInputSettings()
|
||||
private void ShowInputSettings(bool animateFromRight = true)
|
||||
{
|
||||
var stateBoot = CurrentStateBoot();
|
||||
RenderMenuSurface(
|
||||
|
|
@ -213,19 +233,21 @@ public class MainMenu : MonoBehaviour
|
|||
CanOpenRuntimeInputScreen(),
|
||||
InGame,
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
HandleInputSettingsSurfaceCommand);
|
||||
HandleInputSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void ShowPlayerSettingsSurface()
|
||||
private void ShowPlayerSettingsSurface(bool animateFromRight = true)
|
||||
{
|
||||
RenderMenuSurface(
|
||||
AetheriaRuntimeMainMenuSurfaceBuilder.BuildPlayerSettingsShell(
|
||||
ResolvePlayerSettings(CurrentStateBoot()),
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
HandlePlayerSettingsSurfaceCommand);
|
||||
HandlePlayerSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void ShowVerseSettingsSurface()
|
||||
private void ShowVerseSettingsSurface(bool animateFromRight = true)
|
||||
{
|
||||
var stateBoot = CurrentStateBoot();
|
||||
RenderMenuSurface(
|
||||
|
|
@ -234,20 +256,377 @@ public class MainMenu : MonoBehaviour
|
|||
stateBoot,
|
||||
ResolveVerseHostSettings(stateBoot),
|
||||
DateTime.UtcNow.ToString("O"))),
|
||||
HandleVerseSettingsSurfaceCommand);
|
||||
HandleVerseSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void RenderMenuSurface(
|
||||
AetheriaRuntimeSurfaceDocument document,
|
||||
Action<EveSurfaceCommandRequest> commandHandler)
|
||||
Action<EveSurfaceCommandRequest> commandHandler,
|
||||
bool animateFromRight)
|
||||
{
|
||||
_menuSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
var initialRender = _currentMenuSurfaceDocument == null;
|
||||
var targetDocument = initialRender ? _currentMenuSurfaceDocument : _nextMenuSurfaceDocument;
|
||||
targetDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
transform,
|
||||
_menuSurfaceDocument,
|
||||
"Aetheria Menu Surface",
|
||||
targetDocument,
|
||||
initialRender ? "Aetheria Menu Surface" : "Aetheria Menu Surface Transition",
|
||||
document,
|
||||
commandHandler,
|
||||
_menuSurfaceChrome);
|
||||
_menuSurfaceChrome,
|
||||
sortingOrder: initialRender ? 1000 : 1001);
|
||||
|
||||
ApplyMenuStyles(targetDocument.rootVisualElement, IsRootMainMenu(document));
|
||||
SetDocumentTransition(targetDocument, initialRender ? 0f : (animateFromRight ? FadeDistance : -FadeDistance), initialRender ? 1f : 0f);
|
||||
|
||||
if (initialRender)
|
||||
{
|
||||
_currentMenuSurfaceDocument = targetDocument;
|
||||
return;
|
||||
}
|
||||
|
||||
_nextMenuSurfaceDocument = targetDocument;
|
||||
_fadeFromRight = animateFromRight;
|
||||
_fadeLerp = 0f;
|
||||
_fading = true;
|
||||
}
|
||||
|
||||
private static bool IsRootMainMenu(AetheriaRuntimeSurfaceDocument document)
|
||||
{
|
||||
return string.Equals(
|
||||
document?.Surface?.Id,
|
||||
AetheriaRuntimeMainMenuCommands.RootSurfaceId,
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private void UpdateMenuFade()
|
||||
{
|
||||
if (!_fading)
|
||||
return;
|
||||
|
||||
_fadeLerp += Time.unscaledDeltaTime / Mathf.Max(0.01f, FadeTime);
|
||||
var t = Mathf.Clamp01(_fadeLerp);
|
||||
var outgoing = Mathf.Pow(t, FadePositionExponent);
|
||||
var incoming = Mathf.Pow(1f - t, FadePositionExponent);
|
||||
var direction = _fadeFromRight ? 1f : -1f;
|
||||
|
||||
SetDocumentTransition(
|
||||
_currentMenuSurfaceDocument,
|
||||
-direction * FadeDistance * outgoing,
|
||||
Mathf.Pow(1f - t, FadeAlphaExponent));
|
||||
SetDocumentTransition(
|
||||
_nextMenuSurfaceDocument,
|
||||
direction * FadeDistance * incoming,
|
||||
Mathf.Pow(t, FadeAlphaExponent));
|
||||
|
||||
if (_fadeLerp <= 1f)
|
||||
return;
|
||||
|
||||
_fading = false;
|
||||
AetheriaEveUnitySurfaceHost.Hide(_currentMenuSurfaceDocument);
|
||||
var previous = _currentMenuSurfaceDocument;
|
||||
_currentMenuSurfaceDocument = _nextMenuSurfaceDocument;
|
||||
_nextMenuSurfaceDocument = previous;
|
||||
SetDocumentTransition(_currentMenuSurfaceDocument, 0f, 1f);
|
||||
}
|
||||
|
||||
private static void SetDocumentTransition(UIDocument document, float x, float opacity)
|
||||
{
|
||||
if (document?.rootVisualElement == null)
|
||||
return;
|
||||
|
||||
document.rootVisualElement.style.translate = new Translate(new Length(x, LengthUnit.Pixel), 0f, 0f);
|
||||
document.rootVisualElement.style.opacity = opacity;
|
||||
}
|
||||
|
||||
private void UpdateHoverButtons()
|
||||
{
|
||||
for (var i = _hoverButtons.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var hover = _hoverButtons[i];
|
||||
if (hover.Button == null)
|
||||
{
|
||||
_hoverButtons.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var direction = hover.Hovering && hover.Button.enabledInHierarchy ? 1f : -1f;
|
||||
hover.Lerp = Mathf.Clamp01(hover.Lerp + Time.unscaledDeltaTime / Mathf.Max(0.01f, HoverAnimationDuration) * direction);
|
||||
hover.Button.style.letterSpacing = HoverSpacing * hover.Lerp;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyMenuStyles(VisualElement root, bool rootMainMenu)
|
||||
{
|
||||
if (root == null)
|
||||
return;
|
||||
|
||||
StyleMenuTree(root, rootMainMenu);
|
||||
|
||||
var surface = rootMainMenu
|
||||
? FindElement(root, $"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.root")
|
||||
: FindFirstKind(root, "surface");
|
||||
if (surface != null)
|
||||
{
|
||||
surface.style.flexGrow = 0f;
|
||||
surface.style.width = rootMainMenu ? 680f : 560f;
|
||||
surface.style.alignItems = Align.FlexStart;
|
||||
surface.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
var title = FindElement(root, $"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.title") as Label;
|
||||
if (title != null)
|
||||
{
|
||||
title.style.fontSize = 82f;
|
||||
title.style.color = new Color(0.82f, 0.95f, 1f, 0.96f);
|
||||
title.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
title.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
title.style.marginLeft = 0f;
|
||||
title.style.marginBottom = -12f;
|
||||
title.style.width = 660f;
|
||||
}
|
||||
|
||||
var subtitle = FindElement(root, $"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.subtitle") as Label;
|
||||
if (subtitle != null)
|
||||
{
|
||||
subtitle.style.fontSize = 38f;
|
||||
subtitle.style.color = new Color(0.82f, 0.95f, 1f, 0.92f);
|
||||
subtitle.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
subtitle.style.unityTextAlign = TextAnchor.MiddleRight;
|
||||
subtitle.style.marginTop = 0f;
|
||||
subtitle.style.marginBottom = 36f;
|
||||
subtitle.style.width = 660f;
|
||||
}
|
||||
|
||||
RegisterHoverButtons(root);
|
||||
}
|
||||
|
||||
private void StyleMenuTree(VisualElement element, bool rootMainMenu)
|
||||
{
|
||||
if (element == null)
|
||||
return;
|
||||
|
||||
element.pickingMode = PickingMode.Position;
|
||||
|
||||
if (element is UiButton button)
|
||||
StyleMenuButton(button, rootMainMenu);
|
||||
else if (element is TextField textField)
|
||||
StyleMenuTextField(textField, rootMainMenu);
|
||||
else if (element is Label label)
|
||||
StyleMenuLabel(label, rootMainMenu);
|
||||
else
|
||||
StyleMenuContainer(element, rootMainMenu);
|
||||
|
||||
foreach (var child in element.Children())
|
||||
StyleMenuTree(child, rootMainMenu);
|
||||
}
|
||||
|
||||
private static void StyleMenuContainer(VisualElement element, bool rootMainMenu)
|
||||
{
|
||||
element.style.backgroundColor = new Color(0f, 0f, 0f, 0f);
|
||||
element.style.borderLeftWidth = 0f;
|
||||
element.style.borderRightWidth = 0f;
|
||||
element.style.borderTopWidth = 0f;
|
||||
element.style.borderBottomWidth = 0f;
|
||||
element.style.marginLeft = 0f;
|
||||
element.style.marginTop = 0f;
|
||||
element.style.marginBottom = 0f;
|
||||
|
||||
if (element.ClassListContains("eve-row"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
element.style.flexWrap = Wrap.Wrap;
|
||||
element.style.alignItems = Align.Center;
|
||||
element.style.marginTop = 2f;
|
||||
element.style.marginBottom = 6f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-card"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Column;
|
||||
element.style.alignItems = Align.FlexStart;
|
||||
element.style.width = rootMainMenu ? 680f : 540f;
|
||||
element.style.marginBottom = 18f;
|
||||
element.style.paddingTop = 0f;
|
||||
element.style.paddingBottom = 2f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-metric") || element.ClassListContains("eve-field"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
element.style.alignItems = Align.Center;
|
||||
element.style.width = rootMainMenu ? 320f : 520f;
|
||||
element.style.marginBottom = 5f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-kind-control-text"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
element.style.alignItems = Align.Center;
|
||||
element.style.width = rootMainMenu ? 520f : 520f;
|
||||
element.style.marginBottom = rootMainMenu ? 6f : 10f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-surface-root") || element.ClassListContains("eve-kind-surface"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Column;
|
||||
element.style.alignItems = Align.FlexStart;
|
||||
element.style.width = rootMainMenu ? 680f : 560f;
|
||||
return;
|
||||
}
|
||||
|
||||
element.style.flexDirection = FlexDirection.Column;
|
||||
element.style.alignItems = Align.FlexStart;
|
||||
}
|
||||
|
||||
private static void StyleMenuLabel(Label label, bool rootMainMenu)
|
||||
{
|
||||
label.style.color = new Color(0.86f, 0.98f, 1f, 0.94f);
|
||||
label.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.whiteSpace = WhiteSpace.Normal;
|
||||
label.style.marginLeft = 0f;
|
||||
label.style.marginTop = 0f;
|
||||
label.style.marginBottom = 0f;
|
||||
|
||||
if (label.ClassListContains("eve-title"))
|
||||
{
|
||||
label.style.fontSize = rootMainMenu ? 24f : 24f;
|
||||
label.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
label.style.marginTop = rootMainMenu ? 0f : 2f;
|
||||
label.style.marginBottom = rootMainMenu ? 0f : 10f;
|
||||
label.style.maxWidth = rootMainMenu ? 620f : 520f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (label.ClassListContains("eve-muted"))
|
||||
{
|
||||
label.style.fontSize = rootMainMenu ? 18f : 15f;
|
||||
label.style.color = new Color(0.78f, 0.92f, 0.98f, 0.84f);
|
||||
label.style.width = rootMainMenu ? 120f : 190f;
|
||||
label.style.marginRight = 12f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (label.ClassListContains("eve-value"))
|
||||
{
|
||||
label.style.fontSize = rootMainMenu ? 20f : 16f;
|
||||
label.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
label.style.maxWidth = rootMainMenu ? 360f : 300f;
|
||||
return;
|
||||
}
|
||||
|
||||
label.style.fontSize = rootMainMenu ? 24f : 16f;
|
||||
label.style.maxWidth = rootMainMenu ? 620f : 520f;
|
||||
label.style.marginBottom = rootMainMenu ? 0f : 10f;
|
||||
}
|
||||
|
||||
private static void StyleMenuTextField(TextField field, bool rootMainMenu)
|
||||
{
|
||||
field.style.width = rootMainMenu ? 360f : 520f;
|
||||
field.style.height = rootMainMenu ? 30f : 28f;
|
||||
field.style.marginLeft = 0f;
|
||||
field.style.marginTop = 0f;
|
||||
field.style.marginBottom = rootMainMenu ? 4f : 8f;
|
||||
field.style.color = new Color(0.86f, 0.98f, 1f, 0.96f);
|
||||
field.style.fontSize = rootMainMenu ? 18f : 15f;
|
||||
field.pickingMode = PickingMode.Position;
|
||||
|
||||
field.labelElement.style.minWidth = rootMainMenu ? 100f : 190f;
|
||||
field.labelElement.style.width = rootMainMenu ? 100f : 190f;
|
||||
field.labelElement.style.color = new Color(0.78f, 0.92f, 0.98f, 0.84f);
|
||||
}
|
||||
|
||||
private static void StyleMenuButton(UiButton button, bool rootMainMenu)
|
||||
{
|
||||
button.style.backgroundColor = new Color(0f, 0f, 0f, 0f);
|
||||
button.style.borderLeftWidth = 0f;
|
||||
button.style.borderRightWidth = 0f;
|
||||
button.style.borderTopWidth = 0f;
|
||||
button.style.borderBottomWidth = 0f;
|
||||
button.style.color = new Color(0.86f, 0.98f, 1f, 0.96f);
|
||||
button.style.fontSize = rootMainMenu ? 24f : 16f;
|
||||
button.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
button.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
button.style.width = rootMainMenu ? 220f : 230f;
|
||||
button.style.height = rootMainMenu ? 32f : 24f;
|
||||
button.style.marginLeft = 0f;
|
||||
button.style.marginTop = 0f;
|
||||
button.style.marginRight = rootMainMenu ? 0f : 14f;
|
||||
button.style.marginBottom = rootMainMenu ? 0f : 4f;
|
||||
button.style.paddingLeft = 0f;
|
||||
button.style.paddingRight = 0f;
|
||||
button.style.paddingTop = 0f;
|
||||
button.style.paddingBottom = 0f;
|
||||
button.style.letterSpacing = 0f;
|
||||
button.focusable = true;
|
||||
button.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
private void RegisterHoverButtons(VisualElement root)
|
||||
{
|
||||
foreach (var button in FindButtons(root))
|
||||
{
|
||||
var hover = new MenuHoverButton(button);
|
||||
_hoverButtons.Add(hover);
|
||||
button.RegisterCallback<PointerEnterEvent>(_ => hover.Hovering = true);
|
||||
button.RegisterCallback<PointerLeaveEvent>(_ => hover.Hovering = false);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<UiButton> FindButtons(VisualElement root)
|
||||
{
|
||||
if (root == null)
|
||||
yield break;
|
||||
|
||||
if (root is UiButton button)
|
||||
yield return button;
|
||||
|
||||
foreach (var child in root.Children())
|
||||
{
|
||||
foreach (var nested in FindButtons(child))
|
||||
yield return nested;
|
||||
}
|
||||
}
|
||||
|
||||
private static VisualElement FindFirstKind(VisualElement root, string kind)
|
||||
{
|
||||
if (root == null)
|
||||
return null;
|
||||
|
||||
if (root.ClassListContains($"eve-kind-{kind}"))
|
||||
return root;
|
||||
|
||||
foreach (var child in root.Children())
|
||||
{
|
||||
var match = FindFirstKind(child, kind);
|
||||
if (match != null)
|
||||
return match;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static VisualElement FindElement(VisualElement root, string name)
|
||||
{
|
||||
if (root == null)
|
||||
return null;
|
||||
|
||||
if (string.Equals(root.name, name, StringComparison.Ordinal))
|
||||
return root;
|
||||
|
||||
foreach (var child in root.Children())
|
||||
{
|
||||
var match = FindElement(child, name);
|
||||
if (match != null)
|
||||
return match;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void HandleSettingsSurfaceCommand(EveSurfaceCommandRequest request)
|
||||
|
|
@ -261,16 +640,16 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowPlayerSettings:
|
||||
ShowPlayerSettingsSurface();
|
||||
ShowPlayerSettingsSurface(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowVerseSettings:
|
||||
ShowVerseSettingsSurface();
|
||||
ShowVerseSettingsSurface(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowInputSettings:
|
||||
ShowInputSettings();
|
||||
ShowInputSettings(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToMain:
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
return;
|
||||
default:
|
||||
Debug.LogWarning($"Unhandled settings menu command kind: {command.Kind}");
|
||||
|
|
@ -289,12 +668,12 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.OpenRuntimeInputScreen:
|
||||
if (!TryOpenRuntimeInputScreen())
|
||||
{
|
||||
ShowInputSettings();
|
||||
ShowInputSettings(false);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -315,11 +694,11 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.PlayerSettingsCommand:
|
||||
SendKnownAetheriaEveCommand(request, "player-settings");
|
||||
ShowPlayerSettingsSurface();
|
||||
ShowPlayerSettingsSurface(false);
|
||||
return;
|
||||
default:
|
||||
Debug.LogWarning($"Unhandled player-settings command kind: {command.Kind}");
|
||||
|
|
@ -338,15 +717,15 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ClientTargetCommand:
|
||||
RequestClientTargetCommand(request);
|
||||
ShowVerseSettingsSurface();
|
||||
ShowVerseSettingsSurface(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.VerseHostCommand:
|
||||
SendKnownAetheriaEveCommand(request, "Verse-host");
|
||||
ShowVerseSettingsSurface();
|
||||
ShowVerseSettingsSurface(false);
|
||||
return;
|
||||
default:
|
||||
Debug.LogWarning($"Unhandled verse-settings command kind: {command.Kind}");
|
||||
|
|
@ -356,10 +735,8 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
private void HideMenuSurface()
|
||||
{
|
||||
if (_menuSurfaceDocument == null)
|
||||
return;
|
||||
|
||||
AetheriaEveUnitySurfaceHost.Hide(_menuSurfaceDocument);
|
||||
AetheriaEveUnitySurfaceHost.Hide(_currentMenuSurfaceDocument);
|
||||
AetheriaEveUnitySurfaceHost.Hide(_nextMenuSurfaceDocument);
|
||||
}
|
||||
|
||||
public void SetRuntimeInputScreenShell(Func<bool> canOpenRuntimeInputScreen, Action openRuntimeInputScreen)
|
||||
|
|
@ -446,10 +823,28 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_menuSurfaceDocument != null)
|
||||
if (_currentMenuSurfaceDocument != null)
|
||||
{
|
||||
Destroy(_menuSurfaceDocument.gameObject);
|
||||
_menuSurfaceDocument = null;
|
||||
Destroy(_currentMenuSurfaceDocument.gameObject);
|
||||
_currentMenuSurfaceDocument = null;
|
||||
}
|
||||
|
||||
if (_nextMenuSurfaceDocument != null)
|
||||
{
|
||||
Destroy(_nextMenuSurfaceDocument.gameObject);
|
||||
_nextMenuSurfaceDocument = null;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class MenuHoverButton
|
||||
{
|
||||
public MenuHoverButton(UiButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
|
||||
public UiButton Button { get; }
|
||||
public bool Hovering { get; set; }
|
||||
public float Lerp { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
|
|
@ -21,17 +22,14 @@ public class InventoryMenu : MonoBehaviour
|
|||
public ConfirmationDialog Dialog;
|
||||
// public ClickCatcher Background;
|
||||
|
||||
private int2 _selectedPosition;
|
||||
private InventoryPanel _selectedPanel;
|
||||
private ItemInstance _selectedItem;
|
||||
private EquippedItem _selectedEquippedItem;
|
||||
private int2[] _selectedCells;
|
||||
private AetheriaRuntimeCurrentEntityDocument _shipSettingsCurrentEntity;
|
||||
private UIDocument _shipSettingsSurfaceDocument;
|
||||
private UIDocument _cargoItemDetailsSurfaceDocument;
|
||||
private UIDocument _equippedItemDetailsSurfaceDocument;
|
||||
private AetheriaUnityActionBarPresentation _actionBarPresentation;
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
|
||||
private AetheriaClientState _runtimeState;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _shipSettingsSurfaceChrome = PanelChrome(360f, 420f);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _cargoItemDetailsSurfaceChrome = PanelChrome(420f, 520f);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _equippedItemDetailsSurfaceChrome = PanelChrome(460f, 560f);
|
||||
|
|
@ -55,10 +53,12 @@ public class InventoryMenu : MonoBehaviour
|
|||
_actionBarPresentation = actionBarPresentation;
|
||||
}
|
||||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
|
||||
{
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
_presentationEntityIndex = presentationEntityIndex;
|
||||
}
|
||||
|
||||
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-inventory-menu");
|
||||
// private int2 _dragCellOffset;
|
||||
// private ItemRotation _originalRotation;
|
||||
// //private Shape _previousFakeOccupancy;
|
||||
|
|
@ -108,74 +108,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
foreach (var panel in InventoryPanels)
|
||||
{
|
||||
panel.OnClickAsObservable().Subscribe(e =>
|
||||
{
|
||||
if (e.data is InventoryCargoEventData cargoEvent)
|
||||
{
|
||||
var item = cargoEvent.CargoBay.Occupancy[cargoEvent.Position.x, cargoEvent.Position.y];
|
||||
if(item!=null)
|
||||
{
|
||||
if (e.clickCount == 2)
|
||||
{
|
||||
HideCargoItemDetailsSurface();
|
||||
HideEquippedItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
|
||||
RequestCargoItemTransfer(cargoEvent.CargoBay, otherPanel, item);
|
||||
// TODO: SFX: Equip
|
||||
// else
|
||||
// TODO: SFX: Fail
|
||||
}
|
||||
else
|
||||
{
|
||||
HideCurrentShipSettingsSurface();
|
||||
HideCargoItemDetailsSurface();
|
||||
HideEquippedItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
|
||||
_selectedItem = item;
|
||||
_selectedCells = GetSelectedCells(item, _selectedPosition);
|
||||
ApplySelectedCellHighlight();
|
||||
RenderCargoItemDetailsSurface(item);
|
||||
// TODO: SFX: Success
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.data is InventoryEntityEventData entityEvent)
|
||||
{
|
||||
var item = entityEvent.Entity.GearOccupancy[entityEvent.Position.x, entityEvent.Position.y];
|
||||
if (item != null)
|
||||
{
|
||||
if (e.clickCount == 2)
|
||||
{
|
||||
HideCargoItemDetailsSurface();
|
||||
HideEquippedItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
|
||||
RequestEquippedItemTransfer(entityEvent.Entity, item, otherPanel);
|
||||
// TODO: SFX: Unequip
|
||||
// else
|
||||
// TODO: SFX: Fail
|
||||
}
|
||||
else
|
||||
{
|
||||
HideCurrentShipSettingsSurface();
|
||||
HideCargoItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = item.Position;
|
||||
_selectedItem = item.EquippableItem;
|
||||
_selectedEquippedItem = item;
|
||||
_selectedCells = GetSelectedCells(item.EquippableItem, _selectedPosition);
|
||||
ApplySelectedCellHighlight();
|
||||
RenderEquippedItemDetailsSurface(item);
|
||||
// TODO: SFX: Success
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
panel.OnBackgroundClick.Subscribe(data =>
|
||||
{
|
||||
if (!TryReadCurrentEntity(out var currentEntity)) return;
|
||||
|
|
@ -499,122 +431,9 @@ public class InventoryMenu : MonoBehaviour
|
|||
item.Entity.WeaponGroups[groupIndex].items.Contains(item);
|
||||
}
|
||||
|
||||
private void RequestCargoItemTransfer(EquippedCargoBay origin, InventoryPanel destination, ItemInstance item)
|
||||
{
|
||||
if (destination.DisplayedEntity != null && item is EquippableItem equippableItem)
|
||||
{
|
||||
RequestCargoItemEquip(origin, destination.DisplayedEntity, equippableItem);
|
||||
return;
|
||||
}
|
||||
|
||||
if (destination.DisplayedCargo != null)
|
||||
RequestCargoItemTransfer(origin, destination.DisplayedCargo, item);
|
||||
}
|
||||
|
||||
private void ClearSelectedItemSelection()
|
||||
{
|
||||
ClearSelectedCellHighlight();
|
||||
_selectedPanel = null;
|
||||
_selectedItem = null;
|
||||
_selectedEquippedItem = null;
|
||||
_selectedCells = null;
|
||||
_selectedPosition = default;
|
||||
}
|
||||
|
||||
private void RequestEquippedItemTransfer(Entity origin, EquippedItem item, InventoryPanel destination)
|
||||
{
|
||||
if (destination.DisplayedCargo != null)
|
||||
RequestEquippedItemStore(item, destination.DisplayedCargo);
|
||||
}
|
||||
|
||||
private void RequestCargoItemTransfer(
|
||||
EquippedCargoBay origin,
|
||||
EquippedCargoBay destination,
|
||||
ItemInstance item)
|
||||
{
|
||||
if (!TryResolveCargoBay(origin, out var originEntityKey, out var originCargoIndex) ||
|
||||
!TryResolveCargoBay(destination, out var destinationEntityKey, out var destinationCargoIndex) ||
|
||||
item == null ||
|
||||
string.IsNullOrWhiteSpace(item.ItemKey) ||
|
||||
!origin.Cargo.TryGetValue(item, out var originPosition) ||
|
||||
!TryValidateTypedCargoSlot(originEntityKey, originCargoIndex, item, originPosition, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var quantity = item is SimpleCommodity commodity ? commodity.Quantity : 1;
|
||||
if (quantity <= 0)
|
||||
return;
|
||||
|
||||
TrySubmitOperation(
|
||||
operations => operations.TransferCargoItem(
|
||||
originEntityKey,
|
||||
originCargoIndex,
|
||||
destinationEntityKey,
|
||||
destinationCargoIndex,
|
||||
item.ItemKey,
|
||||
quantity,
|
||||
originPosition.x,
|
||||
originPosition.y,
|
||||
default,
|
||||
default,
|
||||
false),
|
||||
"cargo transfer");
|
||||
}
|
||||
|
||||
private void RequestCargoItemEquip(
|
||||
EquippedCargoBay origin,
|
||||
Entity destination,
|
||||
EquippableItem item)
|
||||
{
|
||||
if (!TryResolveCargoBay(origin, out var originEntityKey, out var originCargoIndex) ||
|
||||
!TryResolveEntityRecordKey(destination, out var destinationEntityKey) ||
|
||||
item == null ||
|
||||
string.IsNullOrWhiteSpace(item.ItemKey) ||
|
||||
!origin.Cargo.TryGetValue(item, out var originPosition) ||
|
||||
!TryValidateTypedCargoSlot(originEntityKey, originCargoIndex, item, originPosition, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrySubmitOperation(
|
||||
operations => operations.EquipItem(
|
||||
"cargo",
|
||||
originEntityKey,
|
||||
originCargoIndex,
|
||||
destinationEntityKey,
|
||||
item.ItemKey,
|
||||
originPosition.x,
|
||||
originPosition.y,
|
||||
default,
|
||||
default,
|
||||
false),
|
||||
"cargo equip");
|
||||
}
|
||||
|
||||
private void RequestEquippedItemStore(
|
||||
EquippedItem item,
|
||||
EquippedCargoBay destination)
|
||||
{
|
||||
if (!TryResolveEquippedItem(item, out var originEntityKey, out var equipmentIndex) ||
|
||||
!TryResolveCargoBay(destination, out var destinationEntityKey, out var destinationCargoIndex) ||
|
||||
item?.EquippableItem == null ||
|
||||
!TryValidateTypedEquipmentSlot(originEntityKey, equipmentIndex, item))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrySubmitOperation(
|
||||
operations => operations.StoreItem(
|
||||
originEntityKey,
|
||||
equipmentIndex,
|
||||
destinationEntityKey,
|
||||
destinationCargoIndex,
|
||||
item.EquippableItem.ItemKey,
|
||||
default,
|
||||
default,
|
||||
false),
|
||||
"equipment store");
|
||||
}
|
||||
|
||||
private void RequestEntityShutdownPerformance(string targetEntityKey, float shutdownPerformance)
|
||||
|
|
@ -678,17 +497,17 @@ public class InventoryMenu : MonoBehaviour
|
|||
"weapon-group membership");
|
||||
}
|
||||
|
||||
private bool TryResolveEntityRecordKey(Entity entity, out string recordKey)
|
||||
private bool TryGetRecordKeyForPresentationEntity(Entity entity, out string recordKey)
|
||||
{
|
||||
recordKey = "";
|
||||
return _observedEntityIndex != null &&
|
||||
_observedEntityIndex.TryResolveEntityRecordKey(entity, out recordKey);
|
||||
return _presentationEntityIndex != null &&
|
||||
_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(entity, out recordKey);
|
||||
}
|
||||
|
||||
private bool IsCurrentEntity(Entity entity)
|
||||
{
|
||||
if (entity == null ||
|
||||
!TryResolveEntityRecordKey(entity, out var entityKey) ||
|
||||
!TryGetRecordKeyForPresentationEntity(entity, out var entityKey) ||
|
||||
string.IsNullOrWhiteSpace(entityKey) ||
|
||||
!TryResolveCurrentEntityKey(out var currentEntityKey))
|
||||
{
|
||||
|
|
@ -732,9 +551,9 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
currentEntity = null;
|
||||
var currentEntityKey = CurrentEntitySnapshot()?.EntityKey ?? "";
|
||||
return _observedEntityIndex != null &&
|
||||
return _presentationEntityIndex != null &&
|
||||
!string.IsNullOrWhiteSpace(currentEntityKey) &&
|
||||
_observedEntityIndex.TryResolveEntityByRecordKey(currentEntityKey, out currentEntity);
|
||||
_presentationEntityIndex.TryGetPresentationEntityByRecordKey(currentEntityKey, out currentEntity);
|
||||
}
|
||||
|
||||
private bool TryResolveCurrentDockingBay(out EquippedDockingBay dockingBay)
|
||||
|
|
@ -744,8 +563,8 @@ public class InventoryMenu : MonoBehaviour
|
|||
if (refit?.IsDocked != true ||
|
||||
refit.DockingBayIndex < 0 ||
|
||||
string.IsNullOrWhiteSpace(refit.DockParentEntityKey) ||
|
||||
_observedEntityIndex == null ||
|
||||
!_observedEntityIndex.TryResolveDockingBayByRecordKey(
|
||||
_presentationEntityIndex == null ||
|
||||
!_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
|
||||
refit.DockParentEntityKey,
|
||||
refit.DockingBayIndex,
|
||||
out dockingBay))
|
||||
|
|
@ -756,18 +575,13 @@ public class InventoryMenu : MonoBehaviour
|
|||
return dockingBay != null;
|
||||
}
|
||||
|
||||
private bool TryResolveCargoBay(EquippedCargoBay cargoBay, out string entityKey, out int cargoIndex)
|
||||
{
|
||||
return TryResolveEquippedItem(cargoBay, out entityKey, out cargoIndex);
|
||||
}
|
||||
|
||||
private bool TryResolveEquippedItem(EquippedItem item, out string entityKey, out int equipmentIndex)
|
||||
{
|
||||
entityKey = "";
|
||||
equipmentIndex = -1;
|
||||
var entity = item?.Entity;
|
||||
if (entity?.Equipment == null ||
|
||||
!TryResolveEntityRecordKey(entity, out entityKey))
|
||||
!TryGetRecordKeyForPresentationEntity(entity, out entityKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -776,97 +590,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
return equipmentIndex >= 0;
|
||||
}
|
||||
|
||||
private bool TryResolveTypedInventoryRows(
|
||||
string entityKey,
|
||||
out IReadOnlyList<AetheriaRuntimeRtsInventoryItem> equipment,
|
||||
out IReadOnlyList<AetheriaRuntimeRtsInventoryItem> cargo)
|
||||
{
|
||||
equipment = Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
cargo = Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
if (string.IsNullOrWhiteSpace(entityKey))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var current = CurrentEntitySnapshot();
|
||||
if (current != null && string.Equals(current.EntityKey, entityKey, StringComparison.Ordinal))
|
||||
{
|
||||
equipment = current.Equipment ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
cargo = current.Cargo ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
return true;
|
||||
}
|
||||
|
||||
var refit = StationRefitSnapshot();
|
||||
var entityIndex = -1;
|
||||
if (refit != null)
|
||||
{
|
||||
if (string.Equals(refit.DockParentEntityKey, entityKey, StringComparison.Ordinal))
|
||||
entityIndex = refit.DockParentEntityIndex;
|
||||
else
|
||||
entityIndex = (refit.AvailableEntities ?? Array.Empty<AetheriaRuntimeStationRefitEntityOption>())
|
||||
.FirstOrDefault(option => string.Equals(option.EntityKey, entityKey, StringComparison.Ordinal))
|
||||
?.EntityIndex ?? -1;
|
||||
}
|
||||
|
||||
if (entityIndex < 0)
|
||||
return false;
|
||||
|
||||
var inventory = InventorySnapshot(entityIndex);
|
||||
if (inventory == null || !string.Equals(inventory.EntityKey, entityKey, StringComparison.Ordinal))
|
||||
return false;
|
||||
|
||||
equipment = inventory.Equipment ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
cargo = inventory.Cargo ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to validate Aetheria typed inventory document for {entityKey}: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryValidateTypedCargoSlot(
|
||||
string entityKey,
|
||||
int cargoIndex,
|
||||
ItemInstance item,
|
||||
int2 originPosition,
|
||||
bool hasOriginPosition)
|
||||
{
|
||||
if (item == null ||
|
||||
string.IsNullOrWhiteSpace(item.ItemKey) ||
|
||||
!TryResolveTypedInventoryRows(entityKey, out _, out var cargo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return cargo.Any(row =>
|
||||
string.Equals(row.Source, "cargo", StringComparison.Ordinal) &&
|
||||
row.SourceIndex == cargoIndex &&
|
||||
string.Equals(row.ItemKey, item.ItemKey, StringComparison.Ordinal) &&
|
||||
(!hasOriginPosition || (row.X == originPosition.x && row.Y == originPosition.y)));
|
||||
}
|
||||
|
||||
private bool TryValidateTypedEquipmentSlot(
|
||||
string entityKey,
|
||||
int equipmentIndex,
|
||||
EquippedItem item)
|
||||
{
|
||||
if (item?.EquippableItem == null ||
|
||||
string.IsNullOrWhiteSpace(item.EquippableItem.ItemKey) ||
|
||||
!TryResolveTypedInventoryRows(entityKey, out var equipment, out _))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return equipment.Any(row =>
|
||||
string.Equals(row.Source, "equipment", StringComparison.Ordinal) &&
|
||||
row.SourceIndex == equipmentIndex &&
|
||||
row.X == item.Position.x &&
|
||||
row.Y == item.Position.y &&
|
||||
string.Equals(row.ItemKey, item.EquippableItem.ItemKey, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private bool TrySubmitOperation(
|
||||
Action<AetheriaControl> submit,
|
||||
string label)
|
||||
|
|
@ -890,7 +613,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentEntityState("unity-inventory-menu");
|
||||
return RuntimeState.CurrentEntity.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -903,7 +626,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentStationRefit("unity-inventory-menu");
|
||||
return RuntimeState.StationRefit.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -912,19 +635,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private AetheriaRuntimeInventoryDocument InventorySnapshot(int entityIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentInventory(entityIndex, "unity-inventory-menu");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria typed inventory document for entity {entityIndex}: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// if (Keyboard.current.qKey.wasPressedThisFrame && _dragItem != null)
|
||||
|
|
@ -937,41 +647,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
// }
|
||||
}
|
||||
|
||||
private void ClearSelectedCellHighlight()
|
||||
{
|
||||
if (_selectedPanel == null || _selectedCells == null) return;
|
||||
|
||||
foreach (var v in _selectedCells)
|
||||
{
|
||||
if (_selectedPanel.CellInstances.ContainsKey(v))
|
||||
_selectedPanel.CellInstances[v].Icon.color = _selectedPanel.GetColor(v);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplySelectedCellHighlight()
|
||||
{
|
||||
if (_selectedPanel == null || _selectedCells == null) return;
|
||||
|
||||
foreach (var v in _selectedCells)
|
||||
{
|
||||
if (_selectedPanel.CellInstances.ContainsKey(v))
|
||||
_selectedPanel.CellInstances[v].Icon.color = _selectedPanel.GetColor(v, true);
|
||||
}
|
||||
}
|
||||
|
||||
private int2[] GetSelectedCells(ItemInstance item, int2 position)
|
||||
{
|
||||
var typedItem = FindTypedInventoryItem(item);
|
||||
if (typedItem != null && typedItem.ShapeCells.Count > 0)
|
||||
{
|
||||
return typedItem.ShapeCells
|
||||
.Select(cell => RotateTypedShapeCell(cell, typedItem, item.Rotation) + position)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return Array.Empty<int2>();
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogItem FindTypedInventoryItem(ItemInstance item)
|
||||
{
|
||||
return CatalogSnapshot()?.FindItem(item, x => x.ItemKey);
|
||||
|
|
@ -981,7 +656,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-inventory-menu");
|
||||
return RuntimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -994,7 +669,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-inventory-menu");
|
||||
return RuntimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1042,20 +717,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
return $"{FormatValue(value - 273.15f)} C";
|
||||
}
|
||||
|
||||
private static int2 RotateTypedShapeCell(
|
||||
AetheriaRuntimeShapeCell cell,
|
||||
AetheriaRuntimeCatalogItem item,
|
||||
ItemRotation rotation)
|
||||
{
|
||||
return rotation switch
|
||||
{
|
||||
ItemRotation.Clockwise => new int2(cell.Y, item.ShapeWidth - 1 - cell.X),
|
||||
ItemRotation.Reversed => new int2(item.ShapeWidth - 1 - cell.X, item.ShapeHeight - 1 - cell.Y),
|
||||
ItemRotation.CounterClockwise => new int2(item.ShapeHeight - 1 - cell.Y, cell.X),
|
||||
_ => new int2(cell.X, cell.Y)
|
||||
};
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_shipSettingsSurfaceDocument != null)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using Ink.Runtime;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
|
|
@ -20,16 +21,17 @@ public class LocalMenu : MonoBehaviour
|
|||
public ChoicePrefab ChoicePrefab;
|
||||
|
||||
private string _currentPath;
|
||||
private LocationStory _currentLocation;
|
||||
private LocationStory _currentLocalInkLocation;
|
||||
private Story _activeStory;
|
||||
private readonly List<ActiveStoryChoice> _activeChoices = new List<ActiveStoryChoice>();
|
||||
private UIDocument _surfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _surfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
|
||||
private AetheriaClientState _runtimeState;
|
||||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
|
||||
{
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
_presentationEntityIndex = presentationEntityIndex;
|
||||
}
|
||||
|
||||
private sealed class ActiveStoryChoice
|
||||
|
|
@ -48,13 +50,13 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!TryResolveDockedLocalStory(out _currentLocation))
|
||||
if (!TryResolveDockedLocalInkStory(out _currentLocalInkLocation))
|
||||
{
|
||||
HideStorySurface();
|
||||
return;
|
||||
}
|
||||
|
||||
_activeStory = _currentLocation.Story;
|
||||
_activeStory = _currentLocalInkLocation.Story;
|
||||
Continue();
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +86,7 @@ public class LocalMenu : MonoBehaviour
|
|||
else if (!_activeStory.canContinue)
|
||||
{
|
||||
// There's no choices, but we also can't continue; indicates we hit an END
|
||||
if (_activeStory == _currentLocation.Story)
|
||||
if (_activeStory == _currentLocalInkLocation.Story)
|
||||
{
|
||||
// END inside location-based story thread, restart the story
|
||||
_activeStory.ResetState();
|
||||
|
|
@ -93,7 +95,7 @@ public class LocalMenu : MonoBehaviour
|
|||
else
|
||||
{
|
||||
// END inside quest content, switch back to location thread and present choices
|
||||
_activeStory = _currentLocation.Story;
|
||||
_activeStory = _currentLocalInkLocation.Story;
|
||||
Continue();
|
||||
}
|
||||
}
|
||||
|
|
@ -103,10 +105,10 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
void PresentCurrentChoices()
|
||||
{
|
||||
Debug.Log($"Current Path: \"{_currentPath}\" in {(_activeStory == _currentLocation.Story ? "Location Story" : "Quest Story")}");
|
||||
if(!string.IsNullOrEmpty(_currentPath) && _currentLocation.KnotQuests.ContainsKey(_currentPath))
|
||||
Debug.Log($"Current Path: \"{_currentPath}\" in {(_activeStory == _currentLocalInkLocation.Story ? "Location Story" : "Quest Story")}");
|
||||
if(!string.IsNullOrEmpty(_currentPath) && _currentLocalInkLocation.KnotQuests.ContainsKey(_currentPath))
|
||||
{
|
||||
foreach (var quest in _currentLocation.KnotQuests[_currentPath])
|
||||
foreach (var quest in _currentLocalInkLocation.KnotQuests[_currentPath])
|
||||
{
|
||||
if (quest.Story == _activeStory) continue; // Don't repeat choices for active injected branch
|
||||
|
||||
|
|
@ -188,23 +190,26 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private string ResolveLocationLabel()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocation?.Name))
|
||||
return _currentLocation.Name;
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocation?.FileName))
|
||||
return _currentLocation.FileName;
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocalInkLocation?.Name))
|
||||
return _currentLocalInkLocation.Name;
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocalInkLocation?.FileName))
|
||||
return _currentLocalInkLocation.FileName;
|
||||
return "Local";
|
||||
}
|
||||
|
||||
private bool TryResolveDockedLocalStory(out LocationStory story)
|
||||
private bool TryResolveDockedLocalInkStory(out LocationStory story)
|
||||
{
|
||||
story = null;
|
||||
var docking = CurrentDockingSnapshot();
|
||||
if (_observedEntityIndex == null ||
|
||||
// Ink story execution is still a Unity-local island. The docking identity
|
||||
// comes from managed typed state; the remaining object lookup should go
|
||||
// away when local story state becomes a daemon-owned CultMesh document.
|
||||
if (_presentationEntityIndex == null ||
|
||||
docking == null ||
|
||||
!docking.IsDocked ||
|
||||
string.IsNullOrWhiteSpace(docking.DockParentEntityKey) ||
|
||||
docking.DockingBayIndex < 0 ||
|
||||
!_observedEntityIndex.TryResolveDockingBayByRecordKey(
|
||||
!_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
|
||||
docking.DockParentEntityKey,
|
||||
docking.DockingBayIndex,
|
||||
out var dockingBay) ||
|
||||
|
|
@ -217,11 +222,12 @@ public class LocalMenu : MonoBehaviour
|
|||
return true;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
|
||||
private AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-local-menu");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-local-menu");
|
||||
return _runtimeState.CurrentDocking.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -33,6 +34,7 @@ public class MapRenderer : MonoBehaviour
|
|||
public RawImage RtsIconPrototype;
|
||||
public float Scale;
|
||||
public float2 Position;
|
||||
private AetheriaClientState _runtimeState;
|
||||
public float IconSize = 1f/128;
|
||||
|
||||
private RectTransform _rect;
|
||||
|
|
@ -307,9 +309,8 @@ public class MapRenderer : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings("unity-map-renderer")
|
||||
?.ShowAsteroidsInMinimap ?? false;
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-map-renderer");
|
||||
return _runtimeState.PlayerSettings.Latest()?.ShowAsteroidsInMinimap ?? false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ public class MenuPanel : MonoBehaviour
|
|||
private MenuTabBinding _current;
|
||||
private UIDocument _tabSurfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _tabSurfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaClientState _runtimeState;
|
||||
|
||||
public MenuTab CurrentTab { get; private set; }
|
||||
|
||||
|
|
@ -157,12 +159,13 @@ public class MenuPanel : MonoBehaviour
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static bool TryResolveCurrentDocking(out AetheriaRuntimeCurrentDockingDocument docking)
|
||||
private bool TryResolveCurrentDocking(out AetheriaRuntimeCurrentDockingDocument docking)
|
||||
{
|
||||
docking = null;
|
||||
try
|
||||
{
|
||||
docking = AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-runtime-menu-tabs");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-runtime-menu-tabs");
|
||||
docking = _runtimeState.CurrentDocking.Latest();
|
||||
return docking != null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
|
@ -33,6 +34,7 @@ public class SectorMap : MonoBehaviour
|
|||
public Texture2D HomeIcon;
|
||||
public Prototype LegendPrototype;
|
||||
public float IconDistance = 1;
|
||||
private AetheriaClientState _runtimeState;
|
||||
public float IconBackgroundSize = 3;
|
||||
public float LabelDistance = .4f;
|
||||
public float LinkWidth;
|
||||
|
|
@ -219,8 +221,8 @@ public class SectorMap : MonoBehaviour
|
|||
|
||||
private void EnsureSectorMapLoaded()
|
||||
{
|
||||
_sectorMap = AetheriaUnityRuntimeClientProvider
|
||||
.CurrentSectorMap("unity-sector-map");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-sector-map");
|
||||
_sectorMap = _runtimeState.SectorMap.Latest();
|
||||
|
||||
if (_sectorMapLoaded)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
|
@ -45,6 +44,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
private float _sectorBackgroundDepth;
|
||||
private float _sectorCameraDepth;
|
||||
private UIDocument _zoneDetailsSurfaceDocument;
|
||||
private AetheriaClientState _runtimeState;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _zoneDetailsSurfaceChrome = new AetheriaEveUnitySurfaceChrome
|
||||
{
|
||||
RootAlignItems = Align.FlexEnd,
|
||||
|
|
@ -61,6 +61,8 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
|
||||
private float2 _position = float2(0.5f);
|
||||
private float _viewSize = .5f;
|
||||
|
||||
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-sector-renderer");
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
|
@ -86,32 +88,15 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
|
||||
private void RenderZoneDetailsSurface(int zoneIndex)
|
||||
{
|
||||
var sectorZone = ResolveSectorZone(zoneIndex);
|
||||
var zoneDetails = ResolveZoneDetails(zoneIndex);
|
||||
var ownerFactionIndex = sectorZone?.OwnerFactionIndex ?? -1;
|
||||
var otherFactions = (sectorZone?.FactionIndices ?? Array.Empty<int>())
|
||||
.Where(index => index >= 0 && index != ownerFactionIndex)
|
||||
.Distinct()
|
||||
.Select(FormatFaction)
|
||||
.ToArray();
|
||||
var zoneFacts = AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(
|
||||
zoneDetails,
|
||||
ResolveHullType);
|
||||
var surface = ResolveZoneDetailsSurface(zoneIndex);
|
||||
if (surface == null)
|
||||
return;
|
||||
|
||||
_zoneDetailsSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
transform,
|
||||
_zoneDetailsSurfaceDocument,
|
||||
"Aetheria Sector Zone Details Surface",
|
||||
AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(
|
||||
ResolveZoneName(sectorZone, zoneDetails),
|
||||
ownerFactionIndex >= 0 ? FormatFaction(ownerFactionIndex) : "None",
|
||||
FormatValue((float)zoneFacts.Mass),
|
||||
FormatValue((float)zoneFacts.Radius),
|
||||
otherFactions,
|
||||
zoneFacts.Bodies,
|
||||
zoneFacts.Entities,
|
||||
zoneFacts.HasContents,
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
surface,
|
||||
HandleZoneDetailsSurfaceCommand,
|
||||
_zoneDetailsSurfaceChrome);
|
||||
}
|
||||
|
|
@ -141,105 +126,22 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument);
|
||||
}
|
||||
|
||||
private string ResolveZoneName(
|
||||
AetheriaRuntimeSectorMapZone sectorZone,
|
||||
AetheriaRuntimeZoneDetailsDocument zoneDetails)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(zoneDetails?.ZoneName))
|
||||
return zoneDetails.ZoneName;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sectorZone?.Name))
|
||||
return sectorZone.Name;
|
||||
|
||||
return sectorZone == null ? "Unknown" : $"Zone {sectorZone.ZoneIndex}";
|
||||
}
|
||||
|
||||
private AetheriaRuntimeSectorMapZone ResolveSectorZone(int zoneIndex)
|
||||
private AetheriaRuntimeSurfaceDocument ResolveZoneDetailsSurface(int zoneIndex)
|
||||
{
|
||||
if (zoneIndex < 0)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
var sectorMap = AetheriaUnityRuntimeClientProvider.CurrentSectorMap("unity-sector-renderer");
|
||||
return (sectorMap?.Zones ?? Array.Empty<AetheriaRuntimeSectorMapZone>())
|
||||
.FirstOrDefault(zone => zone.ZoneIndex == zoneIndex);
|
||||
return RuntimeState.ZoneDetailsSurface(zoneIndex).Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector map zone from local Verse state: {ex.Message}");
|
||||
Debug.LogWarning($"Failed to read Aetheria sector zone details surface from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatFaction(int factionIndex)
|
||||
{
|
||||
return factionIndex < 0 ? "None" : $"Faction {factionIndex}";
|
||||
}
|
||||
|
||||
private AetheriaRuntimeZoneDetailsDocument ResolveZoneDetails(int zoneIndex)
|
||||
{
|
||||
if (zoneIndex < 0)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentZoneDetails(zoneIndex, "unity-sector-renderer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector zone details from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private string ResolveHullType(string hullItemKey)
|
||||
{
|
||||
var typedHull = ResolveCatalog()?.FindItem(hullItemKey ?? "");
|
||||
return typedHull?.HullType ?? "";
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-sector-renderer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector catalog from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private AetheriaRuntimePlayerSettingsDocument ResolvePlayerSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-sector-renderer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector player settings from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private string FormatValue(float value)
|
||||
{
|
||||
var digits = ResolvePlayerSettings()?.SignificantDigits ?? 3;
|
||||
var magnitude = value == 0f ? 0 : (int)Math.Floor(Math.Log10(Math.Abs(value))) + 1;
|
||||
digits -= magnitude;
|
||||
if (digits < 0)
|
||||
digits = 0;
|
||||
|
||||
var formatted = value.ToString($"N{digits}");
|
||||
var decimalSeparator = Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
|
||||
return formatted.Contains(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)
|
||||
? formatted.TrimEnd('0').TrimEnd(decimalSeparator)
|
||||
: formatted;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_init = true;
|
||||
|
|
@ -259,7 +161,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentZoneState("unity-sector-renderer");
|
||||
return RuntimeState.CurrentZone.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -299,7 +201,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
{
|
||||
_outputTexture.Release();
|
||||
}
|
||||
_outputTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
|
||||
_outputTexture = new RenderTexture(_size.x, _size.y, 16, RenderTextureFormat.Default);
|
||||
SectorCamera.targetTexture = _outputTexture;
|
||||
_outputImage.material.SetTexture("_DetailTex", _outputTexture);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -28,6 +29,7 @@ public class TradeMenu : MonoBehaviour
|
|||
private string _targetCargoEntityKey = "";
|
||||
private int _targetCargoIndex = -1;
|
||||
private string _targetCargoLabel = "Docking Bay";
|
||||
private AetheriaClientState _runtimeState;
|
||||
private (ItemFilter filter, HardpointType type) _hardpointFilter;
|
||||
private (ItemFilter filter, SimpleCommodityCategory type) _commodityFilter;
|
||||
private (ItemFilter filter, CompoundCommodityCategory type) _compoundCommodityFilter;
|
||||
|
|
@ -46,6 +48,8 @@ public class TradeMenu : MonoBehaviour
|
|||
private AetheriaRuntimeTradeFilterSurfaceModel _filterSurfaceModel;
|
||||
private Action[] _rowActionCallbacks = Array.Empty<Action>();
|
||||
private AetheriaRuntimeTradeRowActionSurfaceModel _rowActionSurfaceModel;
|
||||
|
||||
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-trade");
|
||||
|
||||
public EquippedCargoBay Inventory { get; set; }
|
||||
|
||||
|
|
@ -504,7 +508,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentStationRefit("unity-trade");
|
||||
return RuntimeState.StationRefit.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -518,7 +522,7 @@ public class TradeMenu : MonoBehaviour
|
|||
docking = null;
|
||||
try
|
||||
{
|
||||
docking = AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-trade");
|
||||
docking = RuntimeState.CurrentDocking.Latest();
|
||||
return docking != null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -577,7 +581,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-trade");
|
||||
return RuntimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -590,7 +594,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-trade");
|
||||
return RuntimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue