Aetheria/Assets/Scripts/UI/Menu/InventoryPanel.cs

652 lines
22 KiB
C#
Raw Normal View History

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections.Generic;
using System.Linq;
2026-06-21 09:37:54 +01:00
using GameCult.Aetheria.EveRuntime;
2026-06-21 09:54:15 +01:00
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
2026-06-30 19:14:49 +01:00
using GameCult.Mesh;
using TMPro;
using UniRx;
2026-06-30 19:14:49 +01:00
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.EventSystems;
2026-06-30 19:14:49 +01:00
using UnityEngine.UI;
using UIE = UnityEngine.UIElements;
public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
public ConfirmationDialog Dialog;
public RectTransform DragParent;
public bool Flip;
2021-01-08 12:44:10 +00:00
public GameSettings Settings;
public TextMeshProUGUI Title;
public Button Dropdown;
public Button EditName;
public Button Current;
public Button Thermal;
public Color ToggleEnabledColor;
public Color ToggleDisabledColor;
private Entity _displayedEntity;
private EquippedCargoBay _displayedCargo;
2026-06-25 18:09:33 +01:00
private string _displayedEntityKey = "";
private string _displayedCargoEntityKey = "";
private int _displayedCargoIndex = -1;
2026-06-30 19:14:49 +01:00
private bool _thermal;
private bool _hud;
2026-06-25 18:09:33 +01:00
private AetheriaUnityDragSession _dragSession;
2026-06-30 19:14:49 +01:00
private AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
private AetheriaClientState _runtimeState;
private AetheriaRuntimeSurfaceDocument _inventoryPanelSurface;
private UIE.UIDocument _inventoryPanelSurfaceDocument;
private AetheriaRuntimeSurfaceDocument _dropdownSurface;
private UIE.UIDocument _dropdownSurfaceDocument;
private readonly AetheriaEveUnitySurfaceChrome _inventoryPanelSurfaceChrome = new AetheriaEveUnitySurfaceChrome
2026-06-25 18:09:33 +01:00
{
2026-06-30 19:14:49 +01:00
RootAlignItems = UIE.Align.FlexStart,
RootJustifyContent = UIE.Justify.FlexStart,
RootPaddingTop = 0f,
Width = 520f,
MinWidth = 0f,
MaxWidth = 720f,
PaddingLeft = 16f,
PaddingRight = 16f,
PaddingTop = 14f,
PaddingBottom = 14f
};
2026-06-25 18:09:33 +01:00
2026-06-21 09:37:54 +01:00
private readonly AetheriaEveUnitySurfaceChrome _dropdownSurfaceChrome = new AetheriaEveUnitySurfaceChrome
{
RootAlignItems = UIE.Align.FlexStart,
RootJustifyContent = UIE.Justify.FlexStart,
RootPaddingTop = 0f,
Width = 420f,
MinWidth = 0f,
MaxWidth = 520f,
PaddingLeft = 18f,
PaddingRight = 18f,
PaddingTop = 18f,
PaddingBottom = 18f
};
2026-06-30 19:14:49 +01:00
public readonly Dictionary<int2, InventoryCell> CellInstances = new Dictionary<int2, InventoryCell>();
public Subject<PointerEventData> OnBackgroundClick = new Subject<PointerEventData>();
2026-06-30 19:14:49 +01:00
public InventoryPanelTarget Target =>
_displayedEntity != null ? InventoryPanelTarget.Equipment :
_displayedCargo != null ? InventoryPanelTarget.Cargo : InventoryPanelTarget.None;
2026-06-30 19:14:49 +01:00
private AetheriaUnityDragSession DragSession => _dragSession ??= new AetheriaUnityDragSession();
private AetheriaClientState RuntimeState =>
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-inventory");
public void SetDragSession(AetheriaUnityDragSession dragSession)
{
_dragSession = dragSession;
}
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
{
2026-06-30 19:14:49 +01:00
_presentationEntityIndex = presentationEntityIndex;
}
private void Awake()
{
if (Dropdown)
Dropdown.onClick.AddListener(RenderDropdownSurface);
if (Thermal)
Thermal.onClick.AddListener(() =>
{
2026-06-30 19:14:49 +01:00
if (_displayedEntity != null)
Display(_displayedEntity, _hud, !_thermal);
});
if (Current)
Current.onClick.AddListener(() =>
{
2026-06-30 19:14:49 +01:00
if (_displayedEntity is Ship ship && !IsCurrentEntity(_displayedEntity))
RequestDockedCurrentShip(ship);
});
if (EditName)
2026-06-30 19:14:49 +01:00
EditName.onClick.AddListener(() => ShowRenameDialog(_displayedEntity));
}
public void Clear()
{
HideDropdownSurface();
HideInventoryPanelSurface();
_displayedEntity = null;
_displayedCargo = null;
_displayedEntityKey = "";
_displayedCargoEntityKey = "";
_displayedCargoIndex = -1;
_thermal = false;
_hud = false;
CellInstances.Clear();
if (Title)
Title.text = "None";
}
public void Display(Entity entity, bool hud = false, bool thermal = false)
{
_displayedEntity = entity;
_displayedCargo = null;
_displayedCargoEntityKey = "";
_displayedCargoIndex = -1;
_displayedEntityKey = TryGetRecordKeyForPresentationEntity(entity, out var entityKey)
? entityKey
: "";
_hud = hud;
_thermal = thermal;
if (Title)
Title.text = entity?.Name ?? "";
RenderInventoryPanelSurface();
}
public void Display(EquippedCargoBay cargo)
{
_displayedEntity = null;
_displayedEntityKey = "";
_displayedCargo = cargo;
_displayedCargoEntityKey = "";
_displayedCargoIndex = -1;
_thermal = false;
_hud = false;
if (TryResolveCargoBay(cargo, out var entityKey, out var cargoIndex))
{
2026-06-30 19:14:49 +01:00
_displayedCargoEntityKey = entityKey;
_displayedCargoIndex = cargoIndex;
}
2026-06-30 19:14:49 +01:00
if (Title)
Title.text = cargo?.Name ?? "Cargo";
RenderInventoryPanelSurface();
}
public void RefreshCells()
{
RenderInventoryPanelSurface();
}
public void RefreshCells(IEnumerable<int2> cells)
{
RenderInventoryPanelSurface();
}
public Color GetColor(int2 position, bool selected = false)
{
return selected ? ToggleEnabledColor : Color.white;
}
public void OnPointerClick(PointerEventData eventData)
{
OnBackgroundClick.OnNext(eventData);
}
private void RenderInventoryPanelSurface()
{
_inventoryPanelSurface = ResolveInventoryPanelSurface();
if (_inventoryPanelSurface == null)
{
2026-06-30 19:14:49 +01:00
HideInventoryPanelSurface();
return;
}
2026-06-30 19:14:49 +01:00
_inventoryPanelSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_inventoryPanelSurfaceDocument,
"Aetheria Inventory Panel Surface",
_inventoryPanelSurface,
HandleInventoryPanelSurfaceCommand,
_inventoryPanelSurfaceChrome,
embeddedDocumentResolver: ResolveEmbeddedInventorySurface,
sortingOrder: 990);
}
private void RenderDropdownSurface()
{
2026-06-30 19:14:49 +01:00
_dropdownSurface = ResolveDropdownSurface();
if (_dropdownSurface == null)
{
HideDropdownSurface();
return;
}
2026-06-21 09:37:54 +01:00
_dropdownSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_dropdownSurfaceDocument,
"Aetheria Inventory Dropdown Surface",
2026-06-30 19:14:49 +01:00
_dropdownSurface,
2026-06-21 09:37:54 +01:00
HandleDropdownSurfaceCommand,
2026-06-30 19:14:49 +01:00
_dropdownSurfaceChrome,
sortingOrder: 1000);
}
private AetheriaRuntimeSurfaceDocument ResolveEmbeddedInventorySurface(EveEmbeddedDocumentSlot slot)
{
if (slot == null ||
!string.Equals(slot.SlotId, AetheriaRuntimeInventoryPanelSurfaceBuilder.DropdownSlotId, StringComparison.Ordinal))
{
return null;
}
return ResolveDropdownSurface();
}
private void HandleInventoryPanelSurfaceCommand(EveSurfaceCommandRequest request)
{
switch (request?.Command ?? "")
{
case AetheriaRuntimeInventoryPanelSurfaceBuilder.OpenNavigation:
RenderDropdownSurface();
return;
case AetheriaRuntimeInventoryPanelSurfaceBuilder.ToggleThermal:
if (_displayedEntity != null)
Display(_displayedEntity, _hud, !_thermal);
return;
case AetheriaRuntimeInventoryPanelSurfaceBuilder.SetCurrent:
if (_displayedEntity is Ship ship && !IsCurrentEntity(_displayedEntity))
RequestDockedCurrentShip(ship);
return;
case AetheriaRuntimeInventoryPanelSurfaceBuilder.EditName:
ShowRenameDialog(_displayedEntity);
return;
default:
Debug.LogWarning($"Unknown inventory panel command: {request?.Command}");
return;
}
}
private void HandleDropdownSurfaceCommand(EveSurfaceCommandRequest request)
{
2026-06-21 09:37:54 +01:00
if (!AetheriaRuntimeInventoryDropdownSurfaceCommands.TryRead(request, out var command))
{
Debug.LogWarning($"Unknown inventory dropdown command: {request?.Command}");
return;
}
if (command.Kind == AetheriaRuntimeInventoryDropdownCommandKind.Close)
{
HideDropdownSurface();
return;
}
2026-06-21 09:37:54 +01:00
if (command.Kind == AetheriaRuntimeInventoryDropdownCommandKind.Select &&
2026-06-30 19:14:49 +01:00
TryResolveDropdownSelection(request, command.Command, out var selection))
{
ExecuteDropdownSelection(selection);
HideDropdownSurface();
return;
}
2026-06-21 09:37:54 +01:00
Debug.LogWarning($"Unknown inventory dropdown command: {request?.Command}");
}
private void ExecuteDropdownSelection(AetheriaRuntimeInventoryDropdownSelection selection)
{
switch (selection.Kind)
{
case AetheriaRuntimeInventoryDropdownSelectionKind.EntityEquipment:
case AetheriaRuntimeInventoryDropdownSelectionKind.Entity:
2026-06-30 19:14:49 +01:00
if (TryResolveStationRefitEntity(selection.EntityKey, out var entity))
2026-06-25 18:09:33 +01:00
Display(entity);
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.EntityBay:
2026-06-30 19:14:49 +01:00
if (TryResolveStationRefitEntity(selection.EntityKey, out entity) &&
selection.BayIndex >= 0 &&
2026-06-25 18:09:33 +01:00
selection.BayIndex < entity.CargoBays.Count)
2026-06-21 09:37:54 +01:00
{
2026-06-25 18:09:33 +01:00
Display(entity.CargoBays[selection.BayIndex]);
}
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.DockingBay:
if (TryResolveCurrentDockingBay(out var dockingBay))
Display(dockingBay);
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.SaveLoadout:
2026-06-30 19:14:49 +01:00
if (!string.IsNullOrWhiteSpace(_displayedEntityKey))
RequestLoadoutTemplateSave(_displayedEntityKey);
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.Loadout:
2026-06-30 19:14:49 +01:00
if (TryResolveStationRefitLoadout(selection.TemplateIndex, out var loadout))
RequestRuntimeLoadoutRestore(loadout);
return;
}
}
2026-06-30 19:14:49 +01:00
private static bool TryResolveDropdownSelection(
EveSurfaceCommandRequest request,
string command,
out AetheriaRuntimeInventoryDropdownSelection selection)
{
2026-06-30 19:14:49 +01:00
selection = default;
if (request?.Payload == null)
return false;
var selectionKindText = PayloadValue(request, "selectionKind");
if (!Enum.TryParse(selectionKindText, out AetheriaRuntimeInventoryDropdownSelectionKind selectionKind) ||
selectionKind == AetheriaRuntimeInventoryDropdownSelectionKind.Unknown)
{
return false;
}
2026-06-30 19:14:49 +01:00
selection = new AetheriaRuntimeInventoryDropdownSelection(
selectionKind,
command,
PayloadValue(request, "entityKey"),
ParsePayloadInt(request, "entityIndex"),
ParsePayloadInt(request, "bayIndex"),
ParsePayloadInt(request, "templateIndex"));
return true;
}
2026-06-30 19:14:49 +01:00
private static string PayloadValue(EveSurfaceCommandRequest request, string key)
{
2026-06-30 19:14:49 +01:00
return request?.Payload?.GetString(key, "") ?? "";
}
2026-06-30 19:14:49 +01:00
private static int ParsePayloadInt(EveSurfaceCommandRequest request, string key)
{
2026-06-30 19:14:49 +01:00
return request?.Payload?.GetInt32(key, -1) ?? -1;
}
2026-06-30 19:14:49 +01:00
private void HideDropdownSurface()
2021-01-08 12:44:10 +00:00
{
2026-06-30 19:14:49 +01:00
if (_dropdownSurfaceDocument != null)
AetheriaEveUnitySurfaceHost.Hide(_dropdownSurfaceDocument);
2021-01-08 12:44:10 +00:00
}
2026-06-30 19:14:49 +01:00
private void HideInventoryPanelSurface()
{
2026-06-30 19:14:49 +01:00
if (_inventoryPanelSurfaceDocument != null)
AetheriaEveUnitySurfaceHost.Hide(_inventoryPanelSurfaceDocument);
}
2026-06-30 19:14:49 +01:00
private void ShowRenameDialog(Entity entity)
{
2026-06-30 19:14:49 +01:00
if (entity == null || Dialog == null)
return;
2026-06-30 19:14:49 +01:00
Dialog.Clear();
var entityName = entity.Name;
Dialog.AddField("Name", () => entityName, s => entityName = s);
Dialog.Show(() => RequestEntityName(entity, entityName));
Dialog.MoveToCursor();
2021-01-08 12:44:10 +00:00
}
2026-06-30 19:14:49 +01:00
private AetheriaRuntimeSurfaceDocument ResolveInventoryPanelSurface()
2021-01-08 12:44:10 +00:00
{
2026-06-30 19:14:49 +01:00
try
2021-01-08 12:44:10 +00:00
{
2026-06-30 19:14:49 +01:00
return RuntimeState.InventoryPanelSurface(BuildInventoryPanelSurfaceRequest()).Latest();
2021-01-08 12:44:10 +00:00
}
2026-06-30 19:14:49 +01:00
catch (Exception ex)
2021-01-08 12:44:10 +00:00
{
2026-07-06 01:29:53 +01:00
Debug.LogWarning($"Failed to read Aetheria inventory panel surface from managed Verse state: {ex.Message}");
2026-06-30 19:14:49 +01:00
return null;
2021-01-08 12:44:10 +00:00
}
}
2026-06-30 19:14:49 +01:00
private AetheriaRuntimeSurfaceDocument ResolveDropdownSurface()
{
2026-06-30 19:14:49 +01:00
try
2026-06-25 18:09:33 +01:00
{
2026-06-30 19:14:49 +01:00
return RuntimeState.InventoryDropdownSurface(BuildDropdownSurfaceRequest()).Latest();
2026-06-25 18:09:33 +01:00
}
2026-06-30 19:14:49 +01:00
catch (Exception ex)
{
2026-07-06 01:29:53 +01:00
Debug.LogWarning($"Failed to read Aetheria inventory dropdown surface from managed Verse state: {ex.Message}");
2026-06-30 19:14:49 +01:00
return null;
}
}
2026-06-30 19:14:49 +01:00
private AetheriaRuntimeInventoryPanelSurfaceRequest BuildInventoryPanelSurfaceRequest()
{
2026-06-30 19:14:49 +01:00
var request = new AetheriaRuntimeInventoryPanelSurfaceRequest
{
2026-06-30 19:14:49 +01:00
ViewTitle = Title?.text ?? "",
DisplayedEntityKey = _displayedEntityKey,
DisplayedCargoEntityKey = _displayedCargoEntityKey,
DisplayedCargoIndex = _displayedCargoIndex,
ThermalView = _thermal,
HudView = _hud
};
2026-06-30 19:14:49 +01:00
if (_displayedEntity != null)
request.DisplayedEntityIndex = _displayedEntity.DaemonEntityIndex;
if (_displayedCargo != null && TryResolveDisplayedCargoEntityIndex(out var displayedCargoEntityIndex))
request.DisplayedCargoEntityIndex = displayedCargoEntityIndex;
2026-06-30 19:14:49 +01:00
if (DragSession.TryGetDraggedItem(out var itemDragObject))
{
2026-06-30 19:14:49 +01:00
request.HasDragSession = true;
request.DragItemKey = itemDragObject.Item?.ItemKey ?? "";
request.DragOriginOffsetX = itemDragObject.OriginCellOffset.x;
request.DragOriginOffsetY = itemDragObject.OriginCellOffset.y;
request.DragRotation = itemDragObject.Item?.Rotation.ToString() ?? "";
}
2026-06-30 19:14:49 +01:00
return request;
}
2026-06-30 19:14:49 +01:00
private AetheriaRuntimeInventoryDropdownSurfaceRequest BuildDropdownSurfaceRequest()
{
2026-06-30 19:14:49 +01:00
return new AetheriaRuntimeInventoryDropdownSurfaceRequest
{
2026-06-30 19:14:49 +01:00
CurrentView = Title?.text ?? "",
DisplayedEntityKey = _displayedEntityKey,
DisplayedCargoEntityKey = _displayedCargoEntityKey,
DisplayedCargoIndex = _displayedCargoIndex,
CanSaveLoadout = !string.IsNullOrWhiteSpace(_displayedEntityKey)
};
}
2026-06-30 19:14:49 +01:00
private bool TryResolveDisplayedCargoEntityIndex(out int entityIndex)
{
entityIndex = -1;
if (string.IsNullOrWhiteSpace(_displayedCargoEntityKey))
return false;
2026-06-30 19:14:49 +01:00
var refit = StationRefitSnapshot();
if (refit == null)
return false;
2026-06-30 19:14:49 +01:00
if (string.Equals(refit.DockParentEntityKey, _displayedCargoEntityKey, StringComparison.Ordinal))
entityIndex = refit.DockParentEntityIndex;
else
2026-06-30 19:14:49 +01:00
entityIndex = (refit.AvailableEntities ?? Array.Empty<AetheriaRuntimeStationRefitEntityOption>())
.FirstOrDefault(option => string.Equals(option?.EntityKey ?? "", _displayedCargoEntityKey, StringComparison.Ordinal))
?.EntityIndex ?? -1;
return entityIndex >= 0;
}
2026-06-30 19:14:49 +01:00
private bool TryGetRecordKeyForPresentationEntity(Entity entity, out string recordKey)
{
2026-06-30 19:14:49 +01:00
recordKey = "";
return entity != null &&
_presentationEntityIndex != null &&
_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(entity, out recordKey);
}
2026-06-30 19:14:49 +01:00
private bool IsCurrentEntity(Entity entity)
{
2026-06-30 19:14:49 +01:00
return entity != null &&
TryGetRecordKeyForPresentationEntity(entity, out var entityKey) &&
string.Equals(entityKey, CurrentEntitySnapshot()?.EntityKey ?? "", StringComparison.Ordinal);
}
2026-06-30 19:14:49 +01:00
private bool TryResolveStationRefitEntity(string entityKey, out Entity entity)
{
entity = null;
return _presentationEntityIndex != null &&
!string.IsNullOrWhiteSpace(entityKey) &&
_presentationEntityIndex.TryGetPresentationEntityByRecordKey(entityKey, out entity);
}
2026-06-30 19:14:49 +01:00
private bool TryResolveCurrentDockingBay(out EquippedDockingBay dockingBay)
{
2026-06-30 19:14:49 +01:00
dockingBay = null;
var refit = StationRefitSnapshot();
return refit?.IsDocked == true &&
refit.DockingBayIndex >= 0 &&
!string.IsNullOrWhiteSpace(refit.DockParentEntityKey) &&
_presentationEntityIndex != null &&
_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
refit.DockParentEntityKey,
refit.DockingBayIndex,
out dockingBay) &&
dockingBay != null;
}
private bool TryResolveStationRefitLoadout(
int templateIndex,
out AetheriaRuntimeStationLoadoutRestoreOption loadout)
{
loadout = null;
if (templateIndex < 0)
return false;
2026-06-30 19:14:49 +01:00
loadout = (StationRefitSnapshot()?.LoadoutRestoreOptions ?? Array.Empty<AetheriaRuntimeStationLoadoutRestoreOption>())
.FirstOrDefault(option => option?.TemplateIndex == templateIndex);
return loadout != null;
}
2026-06-30 19:14:49 +01:00
private bool TryResolveCargoBay(EquippedCargoBay cargoBay, out string entityKey, out int cargoIndex)
{
2026-06-30 19:14:49 +01:00
entityKey = "";
cargoIndex = -1;
var entity = cargoBay?.Entity;
if (entity?.CargoBays == null ||
!TryGetRecordKeyForPresentationEntity(entity, out entityKey))
{
2026-06-30 19:14:49 +01:00
return false;
}
2026-06-30 19:14:49 +01:00
cargoIndex = entity.CargoBays.IndexOf(cargoBay);
return cargoIndex >= 0;
2026-06-25 18:09:33 +01:00
}
private void RequestDockedCurrentShip(Ship ship)
{
2026-06-30 19:14:49 +01:00
if (ship == null || !TryGetRecordKeyForPresentationEntity(ship, out var targetEntityKey))
2026-06-25 18:09:33 +01:00
return;
TrySubmitOperation(
operations => operations.SetDockedCurrentShip(targetEntityKey),
"docked current ship");
}
private void RequestEntityName(Entity entity, string name)
{
2026-06-30 19:14:49 +01:00
if (entity == null || !TryGetRecordKeyForPresentationEntity(entity, out var targetEntityKey))
2026-06-25 18:09:33 +01:00
return;
TrySubmitOperation(
operations => operations.SetEntityName(targetEntityKey, name ?? ""),
2026-06-30 19:14:49 +01:00
"entity rename");
2026-06-25 18:09:33 +01:00
}
private void RequestRuntimeLoadoutRestore(AetheriaRuntimeStationLoadoutRestoreOption loadout)
{
if (loadout == null ||
string.IsNullOrWhiteSpace(loadout.TargetEntityKey) ||
string.IsNullOrWhiteSpace(loadout.TemplateName))
{
return;
}
TrySubmitOperation(
operations => operations.RestoreLoadout(loadout.TargetEntityKey, loadout.TemplateName, loadout.Price),
"loadout restore");
}
2026-06-30 19:14:49 +01:00
private void RequestLoadoutTemplateSave(string targetEntityKey)
2026-06-25 18:09:33 +01:00
{
2026-06-30 19:14:49 +01:00
if (string.IsNullOrWhiteSpace(targetEntityKey))
2026-06-25 18:09:33 +01:00
return;
try
{
2026-06-30 19:14:49 +01:00
var loadout = RuntimeState.DaemonFrame.Latest().Run.CreateLoadoutTemplate(targetEntityKey ?? "");
AetheriaUnityRuntimeClientProvider
.Ui("unity-inventory")
.SaveLoadoutTemplateAsync(loadout, "unity-inventory")
2026-06-30 19:14:49 +01:00
.ConfigureAwait(false)
2026-06-25 18:09:33 +01:00
.GetAwaiter()
.GetResult();
}
catch (Exception ex)
{
2026-06-30 19:14:49 +01:00
Debug.LogWarning($"Failed to save Aetheria loadout template: {ex.Message}");
2026-06-25 18:09:33 +01:00
}
}
2026-06-30 19:14:49 +01:00
private bool TrySubmitOperation(Action<AetheriaControl> submit, string label)
2026-06-25 18:09:33 +01:00
{
if (submit == null)
return false;
try
{
submit(AetheriaUnityRuntimeClientProvider.Control("unity-inventory"));
2026-06-25 18:09:33 +01:00
return true;
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to send Aetheria daemon inventory {label} operation; operation not submitted: {ex.Message}");
return false;
}
}
2026-06-29 09:21:29 +01:00
private AetheriaRuntimeCurrentEntityDocument CurrentEntitySnapshot()
{
try
{
2026-06-30 19:14:49 +01:00
return RuntimeState.CurrentEntity.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria current entity for inventory panel: {ex.Message}");
return null;
}
}
2026-06-29 09:21:29 +01:00
private AetheriaRuntimeStationRefitDocument StationRefitSnapshot()
{
try
{
2026-06-30 19:14:49 +01:00
return RuntimeState.StationRefit.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria station refit for inventory panel: {ex.Message}");
return null;
}
}
2026-06-30 19:14:49 +01:00
private void OnDestroy()
{
2026-06-30 19:14:49 +01:00
if (_inventoryPanelSurfaceDocument != null)
{
2026-06-30 19:14:49 +01:00
AetheriaEveUnitySurfaceHost.DestroyDocument(_inventoryPanelSurfaceDocument);
_inventoryPanelSurfaceDocument = null;
}
if (_dropdownSurfaceDocument != null)
{
2026-06-21 09:37:54 +01:00
AetheriaEveUnitySurfaceHost.DestroyDocument(_dropdownSurfaceDocument);
_dropdownSurfaceDocument = null;
}
}
}
public enum InventoryPanelTarget
{
None,
2026-06-30 19:14:49 +01:00
Equipment,
Cargo
}