Move inventory dropdown projection into runtime

This commit is contained in:
Meta Vens 2026-06-21 21:25:13 +01:00
commit 48c794de21
3 changed files with 360 additions and 197 deletions

View file

@ -5022,18 +5022,22 @@ static void RequireInventoryDropdownUseEveSurface(string root)
var requiredSymbols = new[]
{
"RenderDropdownSurface(",
"BuildDropdownCommands(",
"ProjectDropdownSurface(",
"_dropdownSurfaceProjection = ProjectDropdownSurface();",
"HandleDropdownSurfaceCommand(",
"ExecuteDropdownSelection(",
"AetheriaEveUnitySurfaceHost.RenderRuntime(",
"AetheriaEveUnitySurfaceHost.Hide(_dropdownSurfaceDocument)",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.Build(ProjectDropdownSurfaceState(",
"ProjectDropdownSurfaceState(",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.SaveLoadout",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.Build(_dropdownSurfaceProjection.State)",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.Project(",
"AetheriaRuntimeInventoryDropdownSurfaceCommands.TryRead(request, out var command)",
"AetheriaRuntimeInventoryDropdownCommandKind.Close",
"AetheriaRuntimeInventoryDropdownCommandKind.Select",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityEquipmentCommand(",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.LoadoutCommand(",
"_dropdownSurfaceProjection?.TryResolve(command.Command, out var selection) == true",
"AetheriaRuntimeInventoryDropdownSelectionKind.EntityBay",
"AetheriaRuntimeInventoryDropdownSelectionKind.Loadout",
"new AetheriaRuntimeInventoryDropdownEntityOption(",
"new AetheriaRuntimeInventoryDropdownLoadoutOption(",
"GameManager.TryGetObservedDockingBay(out var dockingBay)",
"GameManager.ObservedAvailableEntities()",
"GameManager.ObservedLoadoutTemplates()"
@ -5067,6 +5071,9 @@ static void RequireInventoryDropdownUseEveSurface(string root)
"ContextMenu.Show();",
"string.Equals(request.Command, AetheriaRuntimeInventoryDropdownSurfaceBuilder.Close",
"_dropdownCommands.TryGetValue(request.Command",
"private readonly Dictionary<string, Action> _dropdownCommands",
"BuildDropdownCommands(",
"ProjectDropdownSurfaceState(",
"GameManager.DockingBay",
"GameManager.AvailableEntities()",
"GameManager.LoadoutTemplates"
@ -5104,6 +5111,13 @@ static void RequireInventoryDropdownUseEveSurface(string root)
"AetheriaRuntimeInventoryDropdownSurfaceState",
"AetheriaRuntimeInventoryDropdownGroup",
"AetheriaRuntimeInventoryDropdownOption",
"AetheriaRuntimeInventoryDropdownEntityOption",
"AetheriaRuntimeInventoryDropdownBayOption",
"AetheriaRuntimeInventoryDropdownLoadoutOption",
"AetheriaRuntimeInventoryDropdownSelectionKind",
"AetheriaRuntimeInventoryDropdownSurfaceProjection",
"public static AetheriaRuntimeInventoryDropdownSurfaceProjection Project(",
"public bool TryResolve(",
"public static string EntityEquipmentCommand(",
"public static string EntityBayCommand(",
"public static string EntityCommand(",

View file

@ -83,7 +83,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
private int _clickCount;
private InventoryCell _clickCell;
private float _clickTime;
private readonly Dictionary<string, Action> _dropdownCommands = new Dictionary<string, Action>(StringComparer.Ordinal);
private AetheriaRuntimeInventoryDropdownSurfaceProjection _dropdownSurfaceProjection;
private readonly AetheriaEveUnitySurfaceChrome _dropdownSurfaceChrome = new AetheriaEveUnitySurfaceChrome
{
RootAlignItems = UIE.Align.FlexStart,
@ -179,94 +179,19 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
}
}
private (string text, Action action, bool enabled) LoadoutOption(AetheriaRuntimeLoadoutTemplateSnapshot template)
{
if (!AetheriaRuntimeDaemonTradeItemQueries.TryProjectLoadoutTemplatePrice(
template,
ActionGameManager.RuntimeCatalog,
GameManager.ObservedTradeValueSettings(),
out var price))
{
return ($"{template.Name} - unavailable", () => { }, false);
}
return ($"{template.Name} - {price:n0}", () =>
{
GameManager.RequestRuntimeLoadoutRestore(template);
}, true);
}
private void RenderDropdownSurface()
{
BuildDropdownCommands();
_dropdownSurfaceProjection = ProjectDropdownSurface();
_dropdownSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_dropdownSurfaceDocument,
"Aetheria Inventory Dropdown Surface",
AetheriaRuntimeInventoryDropdownSurfaceBuilder.Build(ProjectDropdownSurfaceState()),
AetheriaRuntimeInventoryDropdownSurfaceBuilder.Build(_dropdownSurfaceProjection.State),
HandleDropdownSurfaceCommand,
_dropdownSurfaceChrome);
}
private void BuildDropdownCommands()
{
_dropdownCommands.Clear();
foreach (var entityEntry in GameManager.ObservedAvailableEntities().Select((entity, entityIndex) => (entity, entityIndex)))
{
if (entityEntry.entity.CargoBays.Any())
{
if (entityEntry.entity != _displayedEntity)
{
var equipmentCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityEquipmentCommand(entityEntry.entityIndex);
_dropdownCommands[equipmentCommand] = () => Display(entityEntry.entity);
}
foreach (var bayEntry in entityEntry.entity.CargoBays
.Where(bay => bay != _displayedCargo)
.Select((bay, bayIndex) => (bay, bayIndex)))
{
var bayCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityBayCommand(
entityEntry.entityIndex,
bayEntry.bayIndex);
_dropdownCommands[bayCommand] = () => Display(bayEntry.bay);
}
}
else if (entityEntry.entity != _displayedEntity)
{
var entityCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityCommand(entityEntry.entityIndex);
_dropdownCommands[entityCommand] = () => Display(entityEntry.entity);
}
}
if (GameManager.TryGetObservedDockingBay(out var dockingBay) && _displayedCargo != dockingBay)
{
_dropdownCommands[AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay] = () => Display(dockingBay);
}
if (_displayedEntity != null)
{
_dropdownCommands[AetheriaRuntimeInventoryDropdownSurfaceBuilder.SaveLoadout] = () =>
{
GameManager.RequestLoadoutTemplateSave(_displayedEntity);
};
}
foreach (var loadoutEntry in GameManager.ObservedLoadoutTemplates().Select((template, templateIndex) => (template, templateIndex)))
{
var blueprint = GameManager.CreateEntityConstructionBlueprint(loadoutEntry.template);
if (blueprint == null)
continue;
var restoreCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.LoadoutCommand(loadoutEntry.templateIndex);
_dropdownCommands[restoreCommand] = () =>
{
GameManager.RequestRuntimeLoadoutRestore(loadoutEntry.template);
};
}
}
private void HandleDropdownSurfaceCommand(EveSurfaceCommandRequest request)
{
if (!AetheriaRuntimeInventoryDropdownSurfaceCommands.TryRead(request, out var command))
@ -282,9 +207,9 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
}
if (command.Kind == AetheriaRuntimeInventoryDropdownCommandKind.Select &&
_dropdownCommands.TryGetValue(command.Command, out var action))
_dropdownSurfaceProjection?.TryResolve(command.Command, out var selection) == true)
{
action();
ExecuteDropdownSelection(selection);
HideDropdownSurface();
return;
}
@ -292,6 +217,50 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
Debug.LogWarning($"Unknown inventory dropdown command: {request?.Command}");
}
private void ExecuteDropdownSelection(AetheriaRuntimeInventoryDropdownSelection selection)
{
var entities = GameManager.ObservedAvailableEntities().ToArray();
var loadouts = GameManager.ObservedLoadoutTemplates().ToArray();
switch (selection.Kind)
{
case AetheriaRuntimeInventoryDropdownSelectionKind.EntityEquipment:
case AetheriaRuntimeInventoryDropdownSelectionKind.Entity:
if (selection.EntityIndex >= 0 && selection.EntityIndex < entities.Length)
{
Display(entities[selection.EntityIndex]);
}
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.EntityBay:
if (selection.EntityIndex >= 0 &&
selection.EntityIndex < entities.Length &&
selection.BayIndex >= 0 &&
selection.BayIndex < entities[selection.EntityIndex].CargoBays.Count)
{
Display(entities[selection.EntityIndex].CargoBays[selection.BayIndex]);
}
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.DockingBay:
if (GameManager.TryGetObservedDockingBay(out var dockingBay))
{
Display(dockingBay);
}
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.SaveLoadout:
if (_displayedEntity != null)
{
GameManager.RequestLoadoutTemplateSave(_displayedEntity);
}
return;
case AetheriaRuntimeInventoryDropdownSelectionKind.Loadout:
if (selection.TemplateIndex >= 0 && selection.TemplateIndex < loadouts.Length)
{
GameManager.RequestRuntimeLoadoutRestore(loadouts[selection.TemplateIndex]);
}
return;
}
}
private void HideDropdownSurface()
{
if (_dropdownSurfaceDocument == null)
@ -300,121 +269,49 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
AetheriaEveUnitySurfaceHost.Hide(_dropdownSurfaceDocument);
}
private AetheriaRuntimeInventoryDropdownSurfaceState ProjectDropdownSurfaceState()
private AetheriaRuntimeInventoryDropdownSurfaceProjection ProjectDropdownSurface()
{
var groups = new List<AetheriaRuntimeInventoryDropdownGroup>();
foreach (var entityEntry in GameManager.ObservedAvailableEntities().Select((entity, entityIndex) => (entity, entityIndex)))
{
var options = new List<AetheriaRuntimeInventoryDropdownOption>();
var equipmentCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityEquipmentCommand(entityEntry.entityIndex);
if (_dropdownCommands.ContainsKey(equipmentCommand))
var entities = GameManager.ObservedAvailableEntities().ToArray();
var loadouts = GameManager.ObservedLoadoutTemplates().ToArray();
var entityOptions = entities
.Select((entity, entityIndex) => new AetheriaRuntimeInventoryDropdownEntityOption(
entityIndex,
entity.Name,
entity == _displayedEntity,
entity.CargoBays
.Select((bay, bayIndex) => new AetheriaRuntimeInventoryDropdownBayOption(
bayIndex,
$"Bay {bayIndex + 1}",
bay == _displayedCargo))
.ToArray()))
.ToArray();
var loadoutOptions = loadouts
.Select((template, templateIndex) =>
{
options.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.entity_{entityEntry.entityIndex}.equipment",
"Equipment",
equipmentCommand));
}
var canRestore =
GameManager.CreateEntityConstructionBlueprint(template) != null &&
AetheriaRuntimeDaemonTradeItemQueries.TryProjectLoadoutTemplatePrice(
template,
ActionGameManager.RuntimeCatalog,
GameManager.ObservedTradeValueSettings(),
out var price);
return new AetheriaRuntimeInventoryDropdownLoadoutOption(
templateIndex,
template.Name,
canRestore ? $"{price:n0}" : "",
canRestore);
})
.ToArray();
var hasDockingBay = GameManager.TryGetObservedDockingBay(out var dockingBay);
foreach (var bayEntry in entityEntry.entity.CargoBays.Select((bay, bayIndex) => (bay, bayIndex)))
{
var bayCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityBayCommand(
entityEntry.entityIndex,
bayEntry.bayIndex);
if (_dropdownCommands.ContainsKey(bayCommand))
{
options.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.entity_{entityEntry.entityIndex}.bay_{bayEntry.bayIndex}",
$"Bay {bayEntry.bayIndex + 1}",
bayCommand));
}
}
var entityCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityCommand(entityEntry.entityIndex);
if (_dropdownCommands.ContainsKey(entityCommand))
{
options.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.entity_{entityEntry.entityIndex}.select",
entityEntry.entity.Name,
entityCommand));
}
if (options.Count > 0)
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.entity_{entityEntry.entityIndex}.card",
entityEntry.entity.Name,
options));
}
}
if (_dropdownCommands.ContainsKey(AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay) &&
GameManager.TryGetObservedDockingBay(out var dockingBay))
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.dockingBay.card",
"Docking Bay",
new[]
{
new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.dockingBay.select",
dockingBay.Name,
AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay)
}));
}
var loadoutOptions = new List<AetheriaRuntimeInventoryDropdownOption>();
if (_dropdownCommands.ContainsKey(AetheriaRuntimeInventoryDropdownSurfaceBuilder.SaveLoadout))
{
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.loadouts.save",
"Save Loadout",
AetheriaRuntimeInventoryDropdownSurfaceBuilder.SaveLoadout));
}
foreach (var loadoutEntry in GameManager.ObservedLoadoutTemplates().Select((template, templateIndex) => (template, templateIndex)))
{
var restoreCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.LoadoutCommand(loadoutEntry.templateIndex);
if (!AetheriaRuntimeDaemonTradeItemQueries.TryProjectLoadoutTemplatePrice(
loadoutEntry.template,
ActionGameManager.RuntimeCatalog,
GameManager.ObservedTradeValueSettings(),
out var price))
{
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.loadouts.unavailable_{loadoutEntry.templateIndex}",
$"{loadoutEntry.template.Name} - unavailable",
""));
continue;
}
if (_dropdownCommands.ContainsKey(restoreCommand))
{
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.loadouts.restore_{loadoutEntry.templateIndex}",
$"{loadoutEntry.template.Name} - {price:n0}",
restoreCommand));
}
else
{
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.loadouts.locked_{loadoutEntry.templateIndex}",
$"{loadoutEntry.template.Name} - {price:n0} (unavailable)",
""));
}
}
if (loadoutOptions.Count > 0)
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.loadouts.card",
"Loadouts",
loadoutOptions));
}
return new AetheriaRuntimeInventoryDropdownSurfaceState(
return AetheriaRuntimeInventoryDropdownSurfaceBuilder.Project(
Title?.text ?? "None",
groups,
entityOptions,
hasDockingBay,
hasDockingBay ? dockingBay.Name : "",
hasDockingBay && dockingBay == _displayedCargo,
_displayedEntity != null,
loadoutOptions,
DateTime.UtcNow.ToString("O"));
}

View file

@ -54,6 +54,118 @@ namespace GameCult.Aetheria.State.Verse
public string UpdatedAtUtc { get; }
}
public sealed class AetheriaRuntimeInventoryDropdownEntityOption
{
public AetheriaRuntimeInventoryDropdownEntityOption(
int entityIndex,
string name,
bool isDisplayed,
IReadOnlyList<AetheriaRuntimeInventoryDropdownBayOption> bays)
{
EntityIndex = entityIndex;
Name = name ?? "";
IsDisplayed = isDisplayed;
Bays = bays ?? Array.Empty<AetheriaRuntimeInventoryDropdownBayOption>();
}
public int EntityIndex { get; }
public string Name { get; }
public bool IsDisplayed { get; }
public IReadOnlyList<AetheriaRuntimeInventoryDropdownBayOption> Bays { get; }
}
public sealed class AetheriaRuntimeInventoryDropdownBayOption
{
public AetheriaRuntimeInventoryDropdownBayOption(int bayIndex, string label, bool isDisplayed)
{
BayIndex = bayIndex;
Label = label ?? "";
IsDisplayed = isDisplayed;
}
public int BayIndex { get; }
public string Label { get; }
public bool IsDisplayed { get; }
}
public sealed class AetheriaRuntimeInventoryDropdownLoadoutOption
{
public AetheriaRuntimeInventoryDropdownLoadoutOption(
int templateIndex,
string name,
string priceLabel,
bool canRestore)
{
TemplateIndex = templateIndex;
Name = name ?? "";
PriceLabel = priceLabel ?? "";
CanRestore = canRestore;
}
public int TemplateIndex { get; }
public string Name { get; }
public string PriceLabel { get; }
public bool CanRestore { get; }
}
public enum AetheriaRuntimeInventoryDropdownSelectionKind
{
Unknown = 0,
EntityEquipment = 1,
EntityBay = 2,
Entity = 3,
DockingBay = 4,
SaveLoadout = 5,
Loadout = 6
}
public readonly struct AetheriaRuntimeInventoryDropdownSelection
{
public AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind kind,
string command,
int entityIndex = -1,
int bayIndex = -1,
int templateIndex = -1)
{
Kind = kind;
Command = command ?? "";
EntityIndex = entityIndex;
BayIndex = bayIndex;
TemplateIndex = templateIndex;
}
public AetheriaRuntimeInventoryDropdownSelectionKind Kind { get; }
public string Command { get; }
public int EntityIndex { get; }
public int BayIndex { get; }
public int TemplateIndex { get; }
}
public sealed class AetheriaRuntimeInventoryDropdownSurfaceProjection
{
public AetheriaRuntimeInventoryDropdownSurfaceProjection(
AetheriaRuntimeInventoryDropdownSurfaceState state,
IReadOnlyDictionary<string, AetheriaRuntimeInventoryDropdownSelection> selections)
{
State = state ?? new AetheriaRuntimeInventoryDropdownSurfaceState(
"",
Array.Empty<AetheriaRuntimeInventoryDropdownGroup>(),
"");
Selections = selections ?? new Dictionary<string, AetheriaRuntimeInventoryDropdownSelection>(StringComparer.Ordinal);
}
public AetheriaRuntimeInventoryDropdownSurfaceState State { get; }
public IReadOnlyDictionary<string, AetheriaRuntimeInventoryDropdownSelection> Selections { get; }
public bool TryResolve(
string command,
out AetheriaRuntimeInventoryDropdownSelection selection)
{
return Selections.TryGetValue(command ?? "", out selection);
}
}
public static class AetheriaRuntimeInventoryDropdownSurfaceBuilder
{
public const string SurfaceId = "aetheria.inventory.panel.dropdown";
@ -81,6 +193,146 @@ namespace GameCult.Aetheria.State.Verse
return $"{SurfaceId}.loadout_{templateIndex}";
}
public static AetheriaRuntimeInventoryDropdownSurfaceProjection Project(
string currentView,
IEnumerable<AetheriaRuntimeInventoryDropdownEntityOption> entities,
bool hasDockingBay,
string dockingBayLabel,
bool dockingBayDisplayed,
bool canSaveLoadout,
IEnumerable<AetheriaRuntimeInventoryDropdownLoadoutOption> loadouts,
string updatedAtUtc)
{
var groups = new List<AetheriaRuntimeInventoryDropdownGroup>();
var selections = new Dictionary<string, AetheriaRuntimeInventoryDropdownSelection>(StringComparer.Ordinal);
foreach (var entity in entities ?? Array.Empty<AetheriaRuntimeInventoryDropdownEntityOption>())
{
if (entity == null)
continue;
var options = new List<AetheriaRuntimeInventoryDropdownOption>();
var equipmentCommand = EntityEquipmentCommand(entity.EntityIndex);
if (entity.Bays.Count > 0 && !entity.IsDisplayed)
{
options.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{SurfaceId}.entity_{entity.EntityIndex}.equipment",
"Equipment",
equipmentCommand));
selections[equipmentCommand] = new AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind.EntityEquipment,
equipmentCommand,
entityIndex: entity.EntityIndex);
}
foreach (var bay in entity.Bays)
{
if (bay == null || bay.IsDisplayed)
continue;
var bayCommand = EntityBayCommand(entity.EntityIndex, bay.BayIndex);
options.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{SurfaceId}.entity_{entity.EntityIndex}.bay_{bay.BayIndex}",
string.IsNullOrWhiteSpace(bay.Label) ? $"Bay {bay.BayIndex + 1}" : bay.Label,
bayCommand));
selections[bayCommand] = new AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind.EntityBay,
bayCommand,
entityIndex: entity.EntityIndex,
bayIndex: bay.BayIndex);
}
if (entity.Bays.Count == 0 && !entity.IsDisplayed)
{
var entityCommand = EntityCommand(entity.EntityIndex);
options.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{SurfaceId}.entity_{entity.EntityIndex}.select",
entity.Name,
entityCommand));
selections[entityCommand] = new AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind.Entity,
entityCommand,
entityIndex: entity.EntityIndex);
}
if (options.Count > 0)
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{SurfaceId}.entity_{entity.EntityIndex}.card",
entity.Name,
options));
}
}
if (hasDockingBay && !dockingBayDisplayed)
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{SurfaceId}.dockingBay.card",
"Docking Bay",
new[]
{
new AetheriaRuntimeInventoryDropdownOption(
$"{SurfaceId}.dockingBay.select",
dockingBayLabel,
DockingBay)
}));
selections[DockingBay] = new AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind.DockingBay,
DockingBay);
}
var loadoutOptions = new List<AetheriaRuntimeInventoryDropdownOption>();
if (canSaveLoadout)
{
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{SurfaceId}.loadouts.save",
"Save Loadout",
SaveLoadout));
selections[SaveLoadout] = new AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind.SaveLoadout,
SaveLoadout);
}
foreach (var loadout in loadouts ?? Array.Empty<AetheriaRuntimeInventoryDropdownLoadoutOption>())
{
if (loadout == null)
continue;
var loadoutCommand = LoadoutCommand(loadout.TemplateIndex);
var priceSuffix = string.IsNullOrWhiteSpace(loadout.PriceLabel)
? "unavailable"
: loadout.PriceLabel;
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
$"{SurfaceId}.loadouts.{(loadout.CanRestore ? "restore" : "locked")}_{loadout.TemplateIndex}",
$"{loadout.Name} - {priceSuffix}{(loadout.CanRestore ? "" : " (unavailable)")}",
loadout.CanRestore ? loadoutCommand : ""));
if (loadout.CanRestore)
{
selections[loadoutCommand] = new AetheriaRuntimeInventoryDropdownSelection(
AetheriaRuntimeInventoryDropdownSelectionKind.Loadout,
loadoutCommand,
templateIndex: loadout.TemplateIndex);
}
}
if (loadoutOptions.Count > 0)
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{SurfaceId}.loadouts.card",
"Loadouts",
loadoutOptions));
}
return new AetheriaRuntimeInventoryDropdownSurfaceProjection(
new AetheriaRuntimeInventoryDropdownSurfaceState(
currentView,
groups,
updatedAtUtc),
selections);
}
public static AetheriaRuntimeSurfaceDocument Build(
AetheriaRuntimeInventoryDropdownSurfaceState state,
long version = 1)