Publish CultMesh-native Aetheria Eve surfaces
This commit is contained in:
parent
59e783f6a0
commit
f220057ccf
35 changed files with 1993 additions and 1247 deletions
|
|
@ -14,13 +14,13 @@ namespace GameCult.Aetheria.State.Verse
|
|||
string baseUri = "cultmesh://aetheria.local/assets")
|
||||
{
|
||||
var entries = new Dictionary<string, AetheriaRuntimeAssetManifestEntry>(StringComparer.Ordinal);
|
||||
Add(entries, MapIcon("entity.player", "Player", "Sprites/Map/player"));
|
||||
Add(entries, MapIcon("entity.ship", "Ship", "Sprites/Map/ship"));
|
||||
Add(entries, MapIcon("entity.orbital", "Orbital", "Sprites/Map/orbital"));
|
||||
Add(entries, MapIcon("entity.station", "Station", "Sprites/Map/station"));
|
||||
Add(entries, MapIcon("body.planet", "Planet", "Sprites/Map/planet"));
|
||||
Add(entries, MapIcon("body.sun", "Sun", "Sprites/Map/sun"));
|
||||
Add(entries, MapIcon("body.asteroid", "Asteroid", "Sprites/Map/asteroid"));
|
||||
Add(entries, MapIcon("entity.player", "Player", "Sprites/Icons/Stroked/Ship"));
|
||||
Add(entries, MapIcon("entity.ship", "Ship", "Sprites/Icons/Stroked/Ship"));
|
||||
Add(entries, MapIcon("entity.orbital", "Orbital", "Sprites/Icons/Stroked/orbital"));
|
||||
Add(entries, MapIcon("entity.station", "Station", "Sprites/Icons/station1"));
|
||||
Add(entries, MapIcon("body.planet", "Planet", "Sprites/Icons/Stroked/Planet"));
|
||||
Add(entries, MapIcon("body.sun", "Sun", "Sprites/Icons/Stroked/Sun"));
|
||||
Add(entries, MapIcon("body.asteroid", "Asteroid", "Sprites/Icons/Stroked/Planet"));
|
||||
foreach (var inventoryAsset in InventoryUiAssets())
|
||||
Add(entries, inventoryAsset);
|
||||
|
||||
|
|
@ -56,15 +56,27 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public static AetheriaRuntimeAssetRef ResolveEntityIcon(AetheriaRuntimeRtsViewportObject? obj)
|
||||
{
|
||||
if (obj?.Controlled == true)
|
||||
return Sprite("map.entity.player", "Sprites/Map/player");
|
||||
return Sprite("map.entity.player", "Sprites/Icons/Stroked/Ship");
|
||||
|
||||
var kind = (obj?.Kind ?? "").Trim().ToLowerInvariant();
|
||||
if (kind.IndexOf("station", StringComparison.Ordinal) >= 0)
|
||||
return Sprite("map.entity.station", "Sprites/Map/station");
|
||||
return Sprite("map.entity.station", "Sprites/Icons/station1");
|
||||
if (kind.IndexOf("orbital", StringComparison.Ordinal) >= 0)
|
||||
return Sprite("map.entity.orbital", "Sprites/Map/orbital");
|
||||
return Sprite("map.entity.orbital", "Sprites/Icons/Stroked/orbital");
|
||||
|
||||
return Sprite("map.entity.ship", "Sprites/Map/ship");
|
||||
return Sprite("map.entity.ship", "Sprites/Icons/Stroked/Ship");
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeAssetRef ResolveBodyIcon(AetheriaRuntimeRtsBodyView? body)
|
||||
{
|
||||
var kind = (body?.Kind ?? "").Trim().ToLowerInvariant();
|
||||
if (kind.IndexOf("sun", StringComparison.Ordinal) >= 0 ||
|
||||
kind.IndexOf("star", StringComparison.Ordinal) >= 0)
|
||||
return Sprite("map.body.sun", "Sprites/Icons/Stroked/Sun");
|
||||
if (kind.IndexOf("asteroid", StringComparison.Ordinal) >= 0)
|
||||
return Sprite("map.body.asteroid", "Sprites/Icons/Stroked/Planet");
|
||||
|
||||
return Sprite("map.body.planet", "Sprites/Icons/Stroked/Planet");
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeAssetRef AssetRefFromCatalogIcon(
|
||||
|
|
@ -78,11 +90,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var assetKey = string.IsNullOrWhiteSpace(fallbackAssetKey)
|
||||
? $"catalog.{resourcePath}".Replace('/', '.').Replace('\\', '.')
|
||||
: fallbackAssetKey;
|
||||
return AetheriaRuntimeAssetRef.FromKey(
|
||||
return CultMeshAssetRef(
|
||||
assetKey,
|
||||
AetheriaRuntimeAssetKinds.Texture,
|
||||
$"resources://{resourcePath}",
|
||||
AetheriaRuntimeAssetTransports.Resources,
|
||||
resourcePath,
|
||||
"image/*");
|
||||
}
|
||||
|
||||
|
|
@ -143,24 +154,51 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
private static AetheriaRuntimeAssetRef Sprite(string key, string resourcePath)
|
||||
{
|
||||
return AetheriaRuntimeAssetRef.FromKey(
|
||||
return CultMeshAssetRef(
|
||||
key,
|
||||
AetheriaRuntimeAssetKinds.Sprite,
|
||||
$"resources://{NormalizeResourcePath(resourcePath)}",
|
||||
AetheriaRuntimeAssetTransports.Resources,
|
||||
resourcePath,
|
||||
"image/*");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAssetRef Texture(string key, string resourcePath)
|
||||
{
|
||||
return AetheriaRuntimeAssetRef.FromKey(
|
||||
return CultMeshAssetRef(
|
||||
key,
|
||||
AetheriaRuntimeAssetKinds.Texture,
|
||||
$"resources://{NormalizeResourcePath(resourcePath)}",
|
||||
AetheriaRuntimeAssetTransports.Resources,
|
||||
resourcePath,
|
||||
"image/*");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAssetRef CultMeshAssetRef(
|
||||
string key,
|
||||
string kind,
|
||||
string resourcePath,
|
||||
string mimeType)
|
||||
{
|
||||
var normalizedResourcePath = NormalizeResourcePath(resourcePath);
|
||||
return new AetheriaRuntimeAssetRef
|
||||
{
|
||||
AssetKey = key ?? "",
|
||||
Kind = kind ?? "",
|
||||
Uri = CultMeshAssetUri(key),
|
||||
Transport = AetheriaRuntimeAssetTransports.CultMesh,
|
||||
MimeType = mimeType ?? "",
|
||||
Metadata = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["resourcePath"] = normalizedResourcePath,
|
||||
["sourceUri"] = $"resources://{normalizedResourcePath}",
|
||||
["sourceTransport"] = AetheriaRuntimeAssetTransports.Resources
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static string CultMeshAssetUri(string key)
|
||||
{
|
||||
var path = (key ?? "").Trim().Replace('.', '/').Replace('\\', '/').Trim('/');
|
||||
return $"cultmesh://aetheria/assets/{path}";
|
||||
}
|
||||
|
||||
private static string NormalizeResourcePath(string path)
|
||||
{
|
||||
path ??= "";
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
new System.Collections.Generic.Dictionary<string, string>(StringComparer.Ordinal),
|
||||
Array.Empty<AetheriaRuntimeSurfaceComponent>());
|
||||
|
||||
writer.WriteArrayHeader(6);
|
||||
writer.WriteArrayHeader(8);
|
||||
writer.Write(component.Id ?? "");
|
||||
writer.Write(component.Kind ?? "");
|
||||
writer.WriteMapHeader(component.Props?.Count ?? 0);
|
||||
|
|
@ -154,6 +154,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
writer.Write(route.Kind.ToString());
|
||||
writer.Write(route.Description ?? "");
|
||||
}
|
||||
|
||||
WriteStringMap(ref writer, component.Layout);
|
||||
WriteStringMap(ref writer, component.Style);
|
||||
}
|
||||
|
||||
private static void WriteSurfaceCommands(
|
||||
|
|
@ -173,6 +176,18 @@ namespace GameCult.Aetheria.State.Verse
|
|||
}
|
||||
}
|
||||
|
||||
private static void WriteStringMap(
|
||||
ref MessagePackWriter writer,
|
||||
System.Collections.Generic.IReadOnlyDictionary<string, string> values)
|
||||
{
|
||||
writer.WriteMapHeader(values?.Count ?? 0);
|
||||
foreach (var value in values ?? new System.Collections.Generic.Dictionary<string, string>(StringComparer.Ordinal))
|
||||
{
|
||||
writer.Write(value.Key ?? "");
|
||||
writer.Write(value.Value ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
internal static AetheriaRuntimeSurfaceDocument ReadRuntimeSurfaceDocument(byte[] payload)
|
||||
{
|
||||
var reader = new MessagePackReader(payload);
|
||||
|
|
@ -255,12 +270,14 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var children = ReadFieldSurfaceComponents(ref reader, componentFields, 3);
|
||||
var stateBindings = ReadFieldSurfaceStateBindings(ref reader, componentFields, 4);
|
||||
var embeddedDocuments = ReadFieldEmbeddedDocumentSlots(ref reader, componentFields, 5);
|
||||
for (var field = 6; field < componentFields; field++)
|
||||
var layout = ReadFieldStringMap(ref reader, componentFields, 6);
|
||||
var style = ReadFieldStringMap(ref reader, componentFields, 7);
|
||||
for (var field = 8; field < componentFields; field++)
|
||||
{
|
||||
reader.Skip();
|
||||
}
|
||||
|
||||
return new AetheriaRuntimeSurfaceComponent(id, kind, props, children, stateBindings, embeddedDocuments);
|
||||
return new AetheriaRuntimeSurfaceComponent(id, kind, props, children, stateBindings, embeddedDocuments, layout, style);
|
||||
}
|
||||
|
||||
private static System.Collections.Generic.IReadOnlyList<AetheriaRuntimeEmbeddedDocumentSlot> ReadFieldEmbeddedDocumentSlots(
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public const string GravityViewport = "gamecult.aetheria.gravity_viewport.v1";
|
||||
public const string RenderSplatsViewport = "gamecult.aetheria.render_splats_viewport.v1";
|
||||
public const string AssetManifest = "gamecult.aetheria.asset_manifest.v1";
|
||||
public const string CultMeshCdnAssetBlob = "gamecult.cultmesh.cdn.asset_blob.v1";
|
||||
public const string CurrentZone = "gamecult.aetheria.current_zone.v1";
|
||||
public const string CurrentEntity = "gamecult.aetheria.current_entity.v1";
|
||||
public const string CurrentDocking = "gamecult.aetheria.current_docking.v1";
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
Card(
|
||||
$"{SurfaceId}.summary",
|
||||
viewTitle,
|
||||
Layout(("gridArea", "summary")),
|
||||
PanelStyle(),
|
||||
Metric($"{SurfaceId}.summary.mode", "Mode", request.ThermalView ? "Thermal" : "Inventory"),
|
||||
Metric($"{SurfaceId}.summary.entity", "Entity", ResolveEntityName(stationRefit, request)),
|
||||
Metric($"{SurfaceId}.summary.current", "Current Ship", IsCurrentEntity(currentEntity, request) ? "Yes" : "No"),
|
||||
|
|
@ -83,6 +85,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
children.Add(ButtonRow(
|
||||
$"{SurfaceId}.actions",
|
||||
Layout(("gridArea", "actions"), ("display", "flex"), ("flexWrap", "wrap"), ("gap", "8"), ("alignSelf", "start")),
|
||||
Style(),
|
||||
Button($"{SurfaceId}.actions.navigate", "Navigate", OpenNavigation),
|
||||
Button($"{SurfaceId}.actions.thermal", request.ThermalView ? "Inventory" : "Thermal", ToggleThermal),
|
||||
Button($"{SurfaceId}.actions.current", "Set Current", SetCurrent),
|
||||
|
|
@ -104,7 +108,15 @@ namespace GameCult.Aetheria.State.Verse
|
|||
$"{SurfaceId}.root",
|
||||
"surface",
|
||||
Array.Empty<(string Key, string Value)>(),
|
||||
children.ToArray()),
|
||||
children.ToArray(),
|
||||
Layout(
|
||||
("display", "grid"),
|
||||
("gridTemplateColumns", "minmax(260px, 320px) minmax(190px, 240px) minmax(360px, 1fr) minmax(320px, 0.9fr)"),
|
||||
("gridTemplateRows", "auto minmax(240px, 1fr)"),
|
||||
("gridTemplateAreas", "\"summary actions drag dropdown\" \"grid grid drag dropdown\""),
|
||||
("gap", "10"),
|
||||
("alignItems", "start")),
|
||||
Style()),
|
||||
Array.Empty<AetheriaRuntimeSurfaceStyleToken>()),
|
||||
commands: new[]
|
||||
{
|
||||
|
|
@ -146,6 +158,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var props = new List<(string Key, string Value)>
|
||||
{
|
||||
("count", "0"),
|
||||
("columns", "6"),
|
||||
("rows", "3"),
|
||||
("cellSize", "72"),
|
||||
("cellGap", "4"),
|
||||
("cellSpriteMode", "bitmask8"),
|
||||
("cellSpriteColumns", "16"),
|
||||
("cellSpriteRows", "16")
|
||||
|
|
@ -166,7 +182,29 @@ namespace GameCult.Aetheria.State.Verse
|
|||
id,
|
||||
"inventory.grid",
|
||||
props,
|
||||
cells);
|
||||
cells,
|
||||
Layout(
|
||||
("gridArea", "grid"),
|
||||
("alignSelf", "stretch"),
|
||||
("minHeight", "260"),
|
||||
("sectionLabel.margin", "0 0 8px"),
|
||||
("board.overflow", "auto"),
|
||||
("board.padding", "4"),
|
||||
("cell.minWidth", "0"),
|
||||
("cell.minHeight", "0")),
|
||||
Style(
|
||||
("background", "rgba(7, 25, 24, 0.72)"),
|
||||
("borderWidth", "1"),
|
||||
("borderStyle", "solid"),
|
||||
("borderColor", "var(--line)"),
|
||||
("borderRadius", "6"),
|
||||
("sectionLabel.color", "var(--quiet)"),
|
||||
("sectionLabel.font", "700 10px var(--font-mono)"),
|
||||
("sectionLabel.textTransform", "uppercase"),
|
||||
("cell.background", "rgba(10, 36, 35, 0.42)"),
|
||||
("cell.borderWidth", "1"),
|
||||
("cell.borderStyle", "solid"),
|
||||
("cell.borderColor", "rgba(103, 240, 228, 0.12)")));
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent DragSession(
|
||||
|
|
@ -188,7 +226,35 @@ namespace GameCult.Aetheria.State.Verse
|
|||
("rotation", request.DragRotation ?? ""),
|
||||
("hoverCellX", request.HoverCellX.ToString(CultureInfo.InvariantCulture)),
|
||||
("hoverCellY", request.HoverCellY.ToString(CultureInfo.InvariantCulture))
|
||||
});
|
||||
},
|
||||
Array.Empty<AetheriaRuntimeSurfaceComponent>(),
|
||||
Layout(
|
||||
("gridArea", "drag"),
|
||||
("minHeight", "320"),
|
||||
("sectionLabel.margin", "0 0 8px"),
|
||||
("dragChip.width", "max-content"),
|
||||
("dragChip.maxWidth", "100%"),
|
||||
("dragChip.padding", "6px 8px")),
|
||||
Style(
|
||||
("background", "rgba(7, 25, 24, 0.92)"),
|
||||
("borderWidth", "1"),
|
||||
("borderStyle", "solid"),
|
||||
("borderColor", "var(--line)"),
|
||||
("borderRadius", "6"),
|
||||
("sectionLabel.color", "var(--quiet)"),
|
||||
("sectionLabel.font", "700 10px var(--font-mono)"),
|
||||
("sectionLabel.textTransform", "uppercase"),
|
||||
("empty.color", "var(--text)"),
|
||||
("empty.font", "600 12px var(--font-mono)"),
|
||||
("meta.color", "var(--text)"),
|
||||
("meta.font", "600 12px var(--font-mono)"),
|
||||
("dragChip.background", "rgba(10, 36, 35, 0.96)"),
|
||||
("dragChip.borderWidth", "1"),
|
||||
("dragChip.borderStyle", "solid"),
|
||||
("dragChip.borderColor", "var(--line-hot)"),
|
||||
("dragChip.borderRadius", "4"),
|
||||
("dragChip.color", "var(--accent)"),
|
||||
("dragChip.font", "700 12px var(--font-mono)")));
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent EmbeddedDropdownSlot(
|
||||
|
|
@ -213,7 +279,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
dropdownSurfaceDocumentId ?? "",
|
||||
"gamecult.aetheria.runtime_surface.v1",
|
||||
"inventory.dropdown")
|
||||
});
|
||||
},
|
||||
Layout(("gridArea", "dropdown")),
|
||||
Style());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent ItemCell(
|
||||
|
|
@ -239,7 +307,51 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return Node(
|
||||
$"{gridId}.item.{SafeId(item.ItemKey)}.{item.SourceIndex}.{item.X}.{item.Y}",
|
||||
"inventory.item",
|
||||
props);
|
||||
props,
|
||||
Array.Empty<AetheriaRuntimeSurfaceComponent>(),
|
||||
Layout(
|
||||
("width", "72"),
|
||||
("height", "72"),
|
||||
("minWidth", "0"),
|
||||
("minHeight", "0"),
|
||||
("position", "relative"),
|
||||
("display", "grid"),
|
||||
("placeItems", "center"),
|
||||
("cursor", "pointer"),
|
||||
("icon.display", "grid"),
|
||||
("icon.placeItems", "center"),
|
||||
("icon.width", "28"),
|
||||
("icon.height", "28"),
|
||||
("label.position", "absolute"),
|
||||
("label.right", "4"),
|
||||
("label.bottom", "3"),
|
||||
("label.left", "4"),
|
||||
("quantity.position", "absolute"),
|
||||
("quantity.top", "2"),
|
||||
("quantity.right", "4")),
|
||||
Style(
|
||||
("background", "rgba(10, 36, 35, 0.96)"),
|
||||
("borderWidth", "1"),
|
||||
("borderStyle", "solid"),
|
||||
("borderColor", "var(--line-hot)"),
|
||||
("borderRadius", "4"),
|
||||
("color", "var(--text-bright)"),
|
||||
("font", "700 11px var(--font-mono)"),
|
||||
("icon.borderWidth", "1"),
|
||||
("icon.borderStyle", "solid"),
|
||||
("icon.borderColor", "rgba(255, 184, 79, 0.34)"),
|
||||
("icon.borderRadius", "50%"),
|
||||
("icon.color", "var(--accent)"),
|
||||
("icon.background", "rgba(1, 7, 7, 0.62)"),
|
||||
("icon.fontSize", "14"),
|
||||
("label.overflow", "hidden"),
|
||||
("label.color", "var(--quiet)"),
|
||||
("label.fontSize", "9"),
|
||||
("label.textAlign", "center"),
|
||||
("label.textOverflow", "ellipsis"),
|
||||
("label.whiteSpace", "nowrap"),
|
||||
("quantity.color", "var(--accent)"),
|
||||
("quantity.fontSize", "10")));
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAssetRef ResolveItemIconAsset(
|
||||
|
|
@ -324,9 +436,11 @@ namespace GameCult.Aetheria.State.Verse
|
|||
private static AetheriaRuntimeSurfaceComponent Card(
|
||||
string id,
|
||||
string title,
|
||||
IReadOnlyDictionary<string, string> layout,
|
||||
IReadOnlyDictionary<string, string> style,
|
||||
params AetheriaRuntimeSurfaceComponent[] children)
|
||||
{
|
||||
return Node(id, "card", new[] { ("title", title ?? "") }, children);
|
||||
return Node(id, "card", new[] { ("title", title ?? "") }, children, layout, style);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Metric(string id, string label, string value)
|
||||
|
|
@ -336,14 +450,22 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
private static AetheriaRuntimeSurfaceComponent Button(string id, string label, string command)
|
||||
{
|
||||
return Node(id, "control.button", new[] { ("label", label ?? ""), ("command", command ?? "") });
|
||||
return Node(
|
||||
id,
|
||||
"control.button",
|
||||
new[] { ("label", label ?? ""), ("command", command ?? "") },
|
||||
Array.Empty<AetheriaRuntimeSurfaceComponent>(),
|
||||
Layout(("minWidth", "96"), ("minHeight", "42")),
|
||||
Style());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent ButtonRow(
|
||||
string id,
|
||||
IReadOnlyDictionary<string, string> layout,
|
||||
IReadOnlyDictionary<string, string> style,
|
||||
params AetheriaRuntimeSurfaceComponent[] children)
|
||||
{
|
||||
return Node(id, "row", Array.Empty<(string Key, string Value)>(), children);
|
||||
return Node(id, "row", Array.Empty<(string Key, string Value)>(), children, layout, style);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Node(
|
||||
|
|
@ -352,7 +474,18 @@ namespace GameCult.Aetheria.State.Verse
|
|||
IEnumerable<(string Key, string Value)> props,
|
||||
params AetheriaRuntimeSurfaceComponent[] children)
|
||||
{
|
||||
return Node(id, kind, props, children, Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>());
|
||||
return Node(id, kind, props, children, Style(), Style());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Node(
|
||||
string id,
|
||||
string kind,
|
||||
IEnumerable<(string Key, string Value)> props,
|
||||
IReadOnlyList<AetheriaRuntimeSurfaceComponent> children,
|
||||
IReadOnlyDictionary<string, string> layout,
|
||||
IReadOnlyDictionary<string, string> style)
|
||||
{
|
||||
return Node(id, kind, props, children, Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>(), layout, style);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Node(
|
||||
|
|
@ -362,16 +495,55 @@ namespace GameCult.Aetheria.State.Verse
|
|||
IReadOnlyList<AetheriaRuntimeSurfaceComponent> children,
|
||||
IReadOnlyList<AetheriaRuntimeEmbeddedDocumentSlot> embeddedDocuments)
|
||||
{
|
||||
return Node(id, kind, props, children, embeddedDocuments, Style(), Style());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Node(
|
||||
string id,
|
||||
string kind,
|
||||
IEnumerable<(string Key, string Value)> props,
|
||||
IReadOnlyList<AetheriaRuntimeSurfaceComponent> children,
|
||||
IReadOnlyList<AetheriaRuntimeEmbeddedDocumentSlot> embeddedDocuments,
|
||||
IReadOnlyDictionary<string, string> layout,
|
||||
IReadOnlyDictionary<string, string> style)
|
||||
{
|
||||
var propMap = (props ?? Array.Empty<(string Key, string Value)>())
|
||||
.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal);
|
||||
return new AetheriaRuntimeSurfaceComponent(
|
||||
id ?? "",
|
||||
kind ?? "",
|
||||
(props ?? Array.Empty<(string Key, string Value)>())
|
||||
.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal),
|
||||
propMap,
|
||||
children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>(),
|
||||
AetheriaRuntimeSurfaceStateBindings.FromProps(
|
||||
(props ?? Array.Empty<(string Key, string Value)>())
|
||||
.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal)),
|
||||
embeddedDocuments ?? Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>());
|
||||
AetheriaRuntimeSurfaceStateBindings.FromProps(propMap),
|
||||
embeddedDocuments ?? Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>(),
|
||||
layout ?? Style(),
|
||||
style ?? Style());
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, string> Layout(params (string Key, string Value)[] values)
|
||||
{
|
||||
return Map(values);
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, string> Style(params (string Key, string Value)[] values)
|
||||
{
|
||||
return Map(values);
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, string> PanelStyle()
|
||||
{
|
||||
return Style(
|
||||
("background", "rgba(7, 25, 24, 0.92)"),
|
||||
("borderWidth", "1"),
|
||||
("borderStyle", "solid"),
|
||||
("borderColor", "var(--line)"),
|
||||
("borderRadius", "6"));
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, string> Map(params (string Key, string Value)[] values)
|
||||
{
|
||||
return (values ?? Array.Empty<(string Key, string Value)>())
|
||||
.ToDictionary(value => value.Key, value => value.Value ?? "", StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
private static string SafeId(string value)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using GameCult.Mesh;
|
||||
using EveUiCommandRequest = GameCult.Eve.Surface.EveSurfaceCommandRequest;
|
||||
|
|
@ -51,6 +52,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
hasAuthoritativeDaemonFrame: false,
|
||||
daemonRunId: "",
|
||||
daemonFrameId: -1,
|
||||
gravityField: AetheriaMainMenuGravityField.Default(),
|
||||
updatedAtUtc,
|
||||
version);
|
||||
}
|
||||
|
|
@ -77,6 +79,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
hasAuthoritativeDaemonFrame: daemonFrame != null,
|
||||
daemonFrame?.Run?.RunId ?? "",
|
||||
daemonFrame?.FrameId ?? -1,
|
||||
gravityField: AetheriaMainMenuGravityField.FromDaemonFrame(daemonFrame),
|
||||
updatedAtUtc,
|
||||
version);
|
||||
}
|
||||
|
|
@ -103,6 +106,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
hasAuthoritativeDaemonFrame: sectorMap != null,
|
||||
sectorMap?.RunId ?? "",
|
||||
sectorMap?.FrameId ?? -1,
|
||||
gravityField: AetheriaMainMenuGravityField.Default(),
|
||||
updatedAtUtc,
|
||||
version);
|
||||
}
|
||||
|
|
@ -148,48 +152,80 @@ namespace GameCult.Aetheria.State.Verse
|
|||
bool hasAuthoritativeDaemonFrame,
|
||||
string daemonRunId,
|
||||
long daemonFrameId,
|
||||
AetheriaMainMenuGravityField gravityField,
|
||||
string updatedAtUtc,
|
||||
long version)
|
||||
{
|
||||
var verseLabel = VerseLabel(verseTitle, verseId);
|
||||
var targetLine = TargetLine(targetLabel, targetKind, targetSource);
|
||||
var daemonLine = hasAuthoritativeDaemonFrame
|
||||
? $"Run {daemonRunId} / frame {daemonFrameId}"
|
||||
: "No daemon frame";
|
||||
var transportLine = string.IsNullOrWhiteSpace(verseCultMeshAddress)
|
||||
? verseVisibility
|
||||
: $"{verseVisibility} / {verseCultMeshAddress}";
|
||||
gravityField = gravityField.IsEmpty ? AetheriaMainMenuGravityField.Default() : gravityField;
|
||||
var actions = new List<AetheriaRuntimeSurfaceComponent>();
|
||||
if (!inGame)
|
||||
actions.Add(MenuButton($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.continue", "Continue", AetheriaRuntimeMainMenuCommands.ContinueRun));
|
||||
actions.Add(MenuButton($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.newGame", "New Game", AetheriaRuntimeMainMenuCommands.NewGame));
|
||||
actions.Add(MenuButton($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.settings", "Settings", AetheriaRuntimeMainMenuCommands.ShowSettings));
|
||||
actions.Add(MenuButton($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.quit", "Quit", AetheriaRuntimeMainMenuCommands.Quit));
|
||||
|
||||
var builder = MainMenuSurface(
|
||||
var root = Node(
|
||||
$"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.root",
|
||||
"surface",
|
||||
Array.Empty<(string Key, string Value)>(),
|
||||
Layout(
|
||||
("position", "relative"),
|
||||
("overflow", "hidden"),
|
||||
("width", "100%"),
|
||||
("height", "100vh"),
|
||||
("minHeight", "100vh")),
|
||||
Style(("background", "#020606")),
|
||||
GravitySurface($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.gravity", gravityField),
|
||||
Node(
|
||||
$"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.menu",
|
||||
"column",
|
||||
Array.Empty<(string Key, string Value)>(),
|
||||
Layout(
|
||||
("position", "relative"),
|
||||
("padding", "7.25rem 0 0 6.75rem"),
|
||||
("gap", "1.1rem"),
|
||||
("width", "44rem"),
|
||||
("maxWidth", "calc(100vw - 3rem)"),
|
||||
("minHeight", "100vh"),
|
||||
("alignItems", "flex-start")),
|
||||
Style(("color", "#e9fbff")),
|
||||
Text($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.title", "AETHERIA", "text.title",
|
||||
Layout(("margin", "0 0 -1.6rem 0")),
|
||||
Style(
|
||||
("font", "100 5.9rem/0.98 Montserrat, sans-serif"),
|
||||
("color", "rgba(232, 250, 255, 0.94)"),
|
||||
("whiteSpace", "nowrap"))),
|
||||
Text($"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.subtitle", "TERMINUS", "text.subtitle",
|
||||
Layout(("margin", "0 0 0.35rem 16.8rem")),
|
||||
Style(
|
||||
("font", "100 2.6rem/1 Montserrat, sans-serif"),
|
||||
("color", "rgba(232, 250, 255, 0.9)"),
|
||||
("whiteSpace", "nowrap"))),
|
||||
Node(
|
||||
$"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.actions",
|
||||
"column",
|
||||
Array.Empty<(string Key, string Value)>(),
|
||||
Layout(("gap", "0.18rem"), ("alignItems", "flex-start")),
|
||||
Style(("color", "#e8fbff")),
|
||||
actions.ToArray())));
|
||||
|
||||
return new AetheriaRuntimeSurfaceDocument(
|
||||
ProviderId,
|
||||
ProviderKind,
|
||||
"Aetheria Terminus",
|
||||
version,
|
||||
updatedAtUtc,
|
||||
new AetheriaRuntimeSurfaceTree(
|
||||
AetheriaRuntimeMainMenuCommands.RootSurfaceId,
|
||||
"Aetheria Terminus",
|
||||
updatedAtUtc,
|
||||
version)
|
||||
.TitleSubtitle("AETHERIA", "TERMINUS")
|
||||
.ButtonColumn(
|
||||
$"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.actions",
|
||||
actions =>
|
||||
{
|
||||
if (!inGame)
|
||||
{
|
||||
actions.Button(
|
||||
"Continue",
|
||||
Operation(AetheriaRuntimeMainMenuCommands.ContinueRun, "Continue"));
|
||||
}
|
||||
|
||||
actions.Button("New Game", Operation(AetheriaRuntimeMainMenuCommands.NewGame, "New Game"));
|
||||
actions.Button("Settings", Operation(AetheriaRuntimeMainMenuCommands.ShowSettings, "Settings"));
|
||||
actions.Button("Quit", Operation(AetheriaRuntimeMainMenuCommands.Quit, "Quit"));
|
||||
})
|
||||
.Form(
|
||||
$"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.verse",
|
||||
form => form
|
||||
.Metric("Verse", verseLabel)
|
||||
.Metric("Target", targetLine)
|
||||
.Metric("Daemon", daemonLine)
|
||||
.Metric("Transport", transportLine));
|
||||
|
||||
return AetheriaRuntimeSurfaceDocuments.FromPortableSurface(builder.Build());
|
||||
root,
|
||||
MainMenuStyleTokens()),
|
||||
new[]
|
||||
{
|
||||
Command(AetheriaRuntimeMainMenuCommands.ContinueRun, "Continue"),
|
||||
Command(AetheriaRuntimeMainMenuCommands.NewGame, "New Game"),
|
||||
Command(AetheriaRuntimeMainMenuCommands.ShowSettings, "Settings"),
|
||||
Command(AetheriaRuntimeMainMenuCommands.Quit, "Quit")
|
||||
});
|
||||
}
|
||||
|
||||
private static string VerseLabel(string verseTitle, string verseId)
|
||||
|
|
@ -386,9 +422,14 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return Text(id, value, "text");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Text(string id, string value, string kind)
|
||||
private static AetheriaRuntimeSurfaceComponent Text(
|
||||
string id,
|
||||
string value,
|
||||
string kind,
|
||||
IReadOnlyDictionary<string, string>? layout = null,
|
||||
IReadOnlyDictionary<string, string>? style = null)
|
||||
{
|
||||
return Node(id, kind, new[] { ("value", value ?? "") });
|
||||
return Node(id, kind, new[] { ("value", value ?? "") }, layout, style);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Button(string id, string label, string command)
|
||||
|
|
@ -416,11 +457,463 @@ namespace GameCult.Aetheria.State.Verse
|
|||
IEnumerable<(string Key, string Value)> props,
|
||||
params AetheriaRuntimeSurfaceComponent[] children)
|
||||
{
|
||||
return Node(id, kind, props, null, null, children);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent Node(
|
||||
string id,
|
||||
string kind,
|
||||
IEnumerable<(string Key, string Value)> props,
|
||||
IReadOnlyDictionary<string, string>? layout,
|
||||
IReadOnlyDictionary<string, string>? style,
|
||||
params AetheriaRuntimeSurfaceComponent[] children)
|
||||
{
|
||||
var normalizedProps = props.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal);
|
||||
return new AetheriaRuntimeSurfaceComponent(
|
||||
id,
|
||||
kind,
|
||||
props.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal),
|
||||
children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>());
|
||||
normalizedProps,
|
||||
children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>(),
|
||||
AetheriaRuntimeSurfaceStateBindings.FromProps(normalizedProps),
|
||||
Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>(),
|
||||
layout,
|
||||
style);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent GravitySurface(
|
||||
string id,
|
||||
AetheriaMainMenuGravityField gravityField)
|
||||
{
|
||||
var viewport = MainMenuViewport();
|
||||
var renderSplatsDocumentId = ViewportDocumentId("aetheria.viewport.render_splats", viewport);
|
||||
var gravityDocumentId = ViewportDocumentId("aetheria.viewport.gravity", viewport);
|
||||
var objectsDocumentId = ViewportDocumentId("aetheria.viewport.objects", viewport);
|
||||
var props = new[]
|
||||
{
|
||||
("label", "Aetheria level field surface"),
|
||||
("minX", F(viewport.MinX)),
|
||||
("minY", F(viewport.MinY)),
|
||||
("maxX", F(viewport.MaxX)),
|
||||
("maxY", F(viewport.MaxY)),
|
||||
("fieldModel", "aetheria.fields2d.v1"),
|
||||
("scalarField", "gravity.height"),
|
||||
("scalarFieldSlot", "gravity"),
|
||||
("scalarFieldSchemaId", AetheriaRuntimeDaemonSchemas.GravityViewport),
|
||||
("scalarFieldDefaultVisualizer", "isolines.branchless"),
|
||||
("scalarFieldVisualizers", "isolines.branchless,height-shade,probe"),
|
||||
("scalarFieldLineInterval", "11.4398025"),
|
||||
("scalarFieldBaseColor", "0.002,0.006,0.012"),
|
||||
("scalarFieldGlowColor", "0.018,0.050,0.075"),
|
||||
("scalarFieldLowLineColor", "0.000,0.340,0.520"),
|
||||
("scalarFieldHighLineColor", "1.450,0.300,0.050"),
|
||||
("scalarFieldLowAngleColor", "0.060,0.160,0.240"),
|
||||
("scalarFieldHighAngleColor", "1.100,0.240,0.040"),
|
||||
("vectorField", "nebula.tint"),
|
||||
("vectorFieldSlot", "renderSplats"),
|
||||
("vectorFieldLayer", AetheriaRuntimeRenderSplatLayerKeys.FogTint),
|
||||
("vectorFieldSchemaId", AetheriaRuntimeDaemonSchemas.RenderSplatsViewport),
|
||||
("vectorFieldDefaultVisualizer", "color.powerpulse"),
|
||||
("vectorFieldVisualizers", "color.powerpulse,probe"),
|
||||
("vectorFieldTintScale", "0.45"),
|
||||
("objectFieldSlot", "objects"),
|
||||
("objectFieldSchemaId", AetheriaRuntimeDaemonSchemas.ObjectsViewport),
|
||||
("bodyIconMinPx", "24"),
|
||||
("sunIconMinPx", "34"),
|
||||
("bodyIconScale", "0.48"),
|
||||
("sunIconScale", "0.72"),
|
||||
("bodyLabelColor", "rgba(226, 244, 255, 0.82)"),
|
||||
("objectLabelFont", "700 12px Ubuntu, system-ui, sans-serif"),
|
||||
("objectLabelStroke", "rgba(0, 0, 0, 0.72)"),
|
||||
("objectLabelStrokeWidth", "3"),
|
||||
("objectControlledColor", "rgba(122, 240, 255, {alpha})"),
|
||||
("objectRaiderColor", "rgba(255, 143, 74, {alpha})"),
|
||||
("objectNeutralColor", "rgba(232, 232, 224, {alpha})"),
|
||||
("objectDefaultColor", "rgba(214, 244, 255, {alpha})"),
|
||||
("shipIconSizePx", "22"),
|
||||
("remoteShipIconSizePx", "18"),
|
||||
("stationIconSizePx", "34"),
|
||||
("renderSplatsDocumentId", renderSplatsDocumentId),
|
||||
("renderSplatsSchemaId", AetheriaRuntimeDaemonSchemas.RenderSplatsViewport),
|
||||
("gravityDocumentId", gravityDocumentId),
|
||||
("gravitySchemaId", AetheriaRuntimeDaemonSchemas.GravityViewport),
|
||||
("objectsDocumentId", objectsDocumentId),
|
||||
("objectsSchemaId", AetheriaRuntimeDaemonSchemas.ObjectsViewport),
|
||||
("samplesX", "196"),
|
||||
("shader", "aetheria.field-surface2d.v1"),
|
||||
("stateRefreshMs", "50")
|
||||
};
|
||||
var normalizedProps = props.ToDictionary(prop => prop.Item1, prop => prop.Item2 ?? "", StringComparer.Ordinal);
|
||||
return new AetheriaRuntimeSurfaceComponent(
|
||||
id,
|
||||
"field.surface2d",
|
||||
normalizedProps,
|
||||
Array.Empty<AetheriaRuntimeSurfaceComponent>(),
|
||||
AetheriaRuntimeSurfaceStateBindings.FromProps(normalizedProps),
|
||||
new[]
|
||||
{
|
||||
new AetheriaRuntimeEmbeddedDocumentSlot(
|
||||
"renderSplats",
|
||||
renderSplatsDocumentId,
|
||||
AetheriaRuntimeDaemonSchemas.RenderSplatsViewport,
|
||||
"data"),
|
||||
new AetheriaRuntimeEmbeddedDocumentSlot(
|
||||
"gravity",
|
||||
gravityDocumentId,
|
||||
AetheriaRuntimeDaemonSchemas.GravityViewport,
|
||||
"data"),
|
||||
new AetheriaRuntimeEmbeddedDocumentSlot(
|
||||
"objects",
|
||||
objectsDocumentId,
|
||||
AetheriaRuntimeDaemonSchemas.ObjectsViewport,
|
||||
"data")
|
||||
},
|
||||
Layout(
|
||||
("position", "absolute"),
|
||||
("top", "0"),
|
||||
("right", "0"),
|
||||
("bottom", "0"),
|
||||
("left", "0"),
|
||||
("width", "100%"),
|
||||
("height", "100%")),
|
||||
null);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRtsViewportBounds MainMenuViewport()
|
||||
{
|
||||
return new AetheriaRuntimeRtsViewportBounds
|
||||
{
|
||||
MinX = -1500,
|
||||
MinY = -1000,
|
||||
MaxX = 1500,
|
||||
MaxY = 1000
|
||||
};
|
||||
}
|
||||
|
||||
private static string ViewportDocumentId(string prefix, AetheriaRuntimeRtsViewportBounds viewport)
|
||||
{
|
||||
var normalized = AetheriaRuntimeRtsDocuments.Normalize(viewport);
|
||||
return string.Join(
|
||||
".",
|
||||
prefix,
|
||||
ViewportToken(normalized.MinX),
|
||||
ViewportToken(normalized.MinY),
|
||||
ViewportToken(normalized.MaxX),
|
||||
ViewportToken(normalized.MaxY));
|
||||
}
|
||||
|
||||
private static string ViewportToken(double value)
|
||||
{
|
||||
return value
|
||||
.ToString("0.###", CultureInfo.InvariantCulture)
|
||||
.Replace('-', 'n')
|
||||
.Replace('.', 'p');
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent MenuButton(string id, string label, string command)
|
||||
{
|
||||
return Node(
|
||||
id,
|
||||
"control.button",
|
||||
new[] { ("label", label), ("command", command) },
|
||||
Layout(("minWidth", "0"), ("padding", "0.04rem 0")),
|
||||
Style(
|
||||
("background", "rgba(0, 0, 0, 0)"),
|
||||
("borderWidth", "0"),
|
||||
("borderStyle", "solid"),
|
||||
("boxShadow", "none"),
|
||||
("font", "400 1.55rem/1.2 Ubuntu, sans-serif"),
|
||||
("color", "#e8fbff"),
|
||||
("textAlign", "left")),
|
||||
Array.Empty<AetheriaRuntimeSurfaceComponent>());
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, string> Layout(params (string Key, string Value)[] values)
|
||||
{
|
||||
return values.ToDictionary(value => value.Key, value => value.Value ?? "", StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, string> Style(params (string Key, string Value)[] values)
|
||||
{
|
||||
return Layout(values);
|
||||
}
|
||||
|
||||
private static string F(double value)
|
||||
{
|
||||
return value.ToString("0.###", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private static string GravityBodies(IReadOnlyList<AetheriaMainMenuGravityBody> bodies)
|
||||
{
|
||||
return string.Join(
|
||||
";",
|
||||
(bodies ?? Array.Empty<AetheriaMainMenuGravityBody>())
|
||||
.Select(body => string.Join(
|
||||
"|",
|
||||
body.Key,
|
||||
body.Kind,
|
||||
F(body.X),
|
||||
F(body.Y),
|
||||
F(body.Radius),
|
||||
F(body.Depth),
|
||||
F(body.Exponent),
|
||||
F(body.WaveRadius),
|
||||
F(body.WaveDepth),
|
||||
F(body.WaveSpeed),
|
||||
body.IconAssetUri,
|
||||
body.TintSplatAssetUri)));
|
||||
}
|
||||
|
||||
private static string GravityObjects(IReadOnlyList<AetheriaMainMenuGravityObject> objects)
|
||||
{
|
||||
return string.Join(
|
||||
";",
|
||||
(objects ?? Array.Empty<AetheriaMainMenuGravityObject>())
|
||||
.Select(obj => string.Join(
|
||||
"|",
|
||||
S(obj.Key),
|
||||
S(obj.Kind),
|
||||
S(obj.Label),
|
||||
F(obj.X),
|
||||
F(obj.Y),
|
||||
F(obj.DirectionX),
|
||||
F(obj.DirectionY),
|
||||
S(obj.FactionKey),
|
||||
obj.Controlled ? "1" : "0",
|
||||
F(obj.Visibility),
|
||||
S(obj.IconAssetUri))));
|
||||
}
|
||||
|
||||
private static string S(string value)
|
||||
{
|
||||
return (value ?? "").Replace("|", "/").Replace(";", ",");
|
||||
}
|
||||
}
|
||||
|
||||
internal readonly struct AetheriaMainMenuGravityField
|
||||
{
|
||||
public AetheriaMainMenuGravityField(
|
||||
double viewRadius,
|
||||
double terrainRadius,
|
||||
double terrainDepth,
|
||||
double terrainDepthExponent,
|
||||
double terrainWaveFrequency,
|
||||
double simulationTimeSeconds,
|
||||
IReadOnlyList<AetheriaMainMenuGravityBody> bodies,
|
||||
IReadOnlyList<AetheriaMainMenuGravityObject>? objects = null)
|
||||
{
|
||||
ViewRadius = viewRadius;
|
||||
TerrainRadius = terrainRadius;
|
||||
TerrainDepth = terrainDepth;
|
||||
TerrainDepthExponent = terrainDepthExponent <= 0 ? 1.0 : terrainDepthExponent;
|
||||
TerrainWaveFrequency = terrainWaveFrequency;
|
||||
SimulationTimeSeconds = simulationTimeSeconds;
|
||||
Bodies = bodies ?? Array.Empty<AetheriaMainMenuGravityBody>();
|
||||
Objects = objects ?? Array.Empty<AetheriaMainMenuGravityObject>();
|
||||
}
|
||||
|
||||
public double ViewRadius { get; }
|
||||
public double TerrainRadius { get; }
|
||||
public double TerrainDepth { get; }
|
||||
public double TerrainDepthExponent { get; }
|
||||
public double TerrainWaveFrequency { get; }
|
||||
public double SimulationTimeSeconds { get; }
|
||||
public IReadOnlyList<AetheriaMainMenuGravityBody> Bodies { get; }
|
||||
public IReadOnlyList<AetheriaMainMenuGravityObject> Objects { get; }
|
||||
public bool IsEmpty => Bodies == null || Bodies.Count == 0;
|
||||
|
||||
public static AetheriaMainMenuGravityField Default()
|
||||
{
|
||||
return new AetheriaMainMenuGravityField(
|
||||
1200,
|
||||
1200,
|
||||
-8,
|
||||
1.2,
|
||||
0.6,
|
||||
0,
|
||||
new[]
|
||||
{
|
||||
new AetheriaMainMenuGravityBody("terminus-sun", "Sun", 0, 0, 900, -80, 3, 450, 10, 2),
|
||||
new AetheriaMainMenuGravityBody("anchor-moon", "Planet", 360, -180, 260, -22, 2.2, 180, 4, 1.4)
|
||||
},
|
||||
new[]
|
||||
{
|
||||
new AetheriaMainMenuGravityObject("anchor-station", "station", "Anchor Station", -220, -90, 1, 0, "player", true, 1),
|
||||
new AetheriaMainMenuGravityObject("vanguard-one", "ship", "Vanguard One", -60, -40, 1, 0.2, "player", true, 1),
|
||||
new AetheriaMainMenuGravityObject("ash-raider", "ship", "Ash Raider", 420, 180, -0.8, -0.1, "raider", false, 1)
|
||||
});
|
||||
}
|
||||
|
||||
public static AetheriaMainMenuGravityField FromDaemonFrame(AetheriaRuntimeDaemonFrameDocument? frame)
|
||||
{
|
||||
var run = frame?.Run;
|
||||
var zones = run?.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>();
|
||||
var currentZone = zones.FirstOrDefault(zone => zone != null && zone.ZoneIndex == run?.CurrentZoneIndex)
|
||||
?? zones.FirstOrDefault(zone => zone != null);
|
||||
if (currentZone == null)
|
||||
return Default();
|
||||
|
||||
var bodies = (currentZone.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>())
|
||||
.Where(body => body != null)
|
||||
.Select(body => new AetheriaMainMenuGravityBody(
|
||||
string.IsNullOrWhiteSpace(body.BodyKey) ? body.Name : body.BodyKey,
|
||||
body.Kind,
|
||||
double.IsNaN(body.GravityInfluenceCenterX) ? 0 : body.GravityInfluenceCenterX,
|
||||
double.IsNaN(body.GravityInfluenceCenterZ) ? 0 : body.GravityInfluenceCenterZ,
|
||||
body.GravityInfluenceRadius > 0 ? body.GravityInfluenceRadius : Math.Max(160, body.GravityRadiusMultiplier * 220),
|
||||
body.GravityWellDepth,
|
||||
body.GravityDepthExponent <= 0 ? 1.0 : body.GravityDepthExponent,
|
||||
body.GravityWaveRadius,
|
||||
body.GravityWaveDepth,
|
||||
body.GravityWaveSpeed))
|
||||
.ToArray();
|
||||
var objects = (currentZone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
|
||||
.Where(entity => entity != null && entity.IsActive)
|
||||
.Select(entity =>
|
||||
{
|
||||
var entityKey = AetheriaRuntimeRunCheckpointCommit.EntityRecordKey(run?.RunId ?? "local-rts", currentZone.ZoneIndex, entity.EntityIndex);
|
||||
return new AetheriaMainMenuGravityObject(
|
||||
entityKey,
|
||||
entity.Kind,
|
||||
string.IsNullOrWhiteSpace(entity.Name) ? $"entity {entity.EntityIndex.ToString(CultureInfo.InvariantCulture)}" : entity.Name,
|
||||
entity.PositionX,
|
||||
entity.PositionZ,
|
||||
entity.DirectionX,
|
||||
entity.DirectionY,
|
||||
entity.FactionKey,
|
||||
string.Equals(entity.FactionKey, "player", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(entityKey, run?.CurrentEntityKey, StringComparison.Ordinal),
|
||||
entity.Visibility <= 0 ? 1 : entity.Visibility);
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
return new AetheriaMainMenuGravityField(
|
||||
Math.Max(900, AutoViewRadius(currentZone, bodies, objects)),
|
||||
currentZone.GravityTerrainRadius > 0 ? currentZone.GravityTerrainRadius : 1200,
|
||||
currentZone.GravityTerrainDepth == 0 ? -8 : currentZone.GravityTerrainDepth,
|
||||
currentZone.GravityTerrainDepthExponent <= 0 ? 1.0 : currentZone.GravityTerrainDepthExponent,
|
||||
currentZone.GravityTerrainWaveFrequency,
|
||||
currentZone.SimulationTimeSeconds,
|
||||
bodies.Length == 0 ? Default().Bodies : bodies,
|
||||
objects);
|
||||
}
|
||||
|
||||
private static double AutoViewRadius(
|
||||
AetheriaRuntimeZoneSnapshotCommit currentZone,
|
||||
IReadOnlyList<AetheriaMainMenuGravityBody> bodies,
|
||||
IReadOnlyList<AetheriaMainMenuGravityObject> objects)
|
||||
{
|
||||
var radius = currentZone.GravityTerrainRadius > 0 ? currentZone.GravityTerrainRadius : 1200;
|
||||
foreach (var body in bodies ?? Array.Empty<AetheriaMainMenuGravityBody>())
|
||||
radius = Math.Max(radius, Math.Max(Math.Abs(body.X), Math.Abs(body.Y)) + body.Radius * 1.1);
|
||||
foreach (var obj in objects ?? Array.Empty<AetheriaMainMenuGravityObject>())
|
||||
radius = Math.Max(radius, Math.Max(Math.Abs(obj.X), Math.Abs(obj.Y)) + 220);
|
||||
return radius;
|
||||
}
|
||||
}
|
||||
|
||||
internal readonly struct AetheriaMainMenuGravityBody
|
||||
{
|
||||
public AetheriaMainMenuGravityBody(
|
||||
string key,
|
||||
string kind,
|
||||
double x,
|
||||
double y,
|
||||
double radius,
|
||||
double depth,
|
||||
double exponent,
|
||||
double waveRadius,
|
||||
double waveDepth,
|
||||
double waveSpeed)
|
||||
{
|
||||
Key = key ?? "";
|
||||
Kind = string.IsNullOrWhiteSpace(kind) ? "Body" : kind;
|
||||
X = x;
|
||||
Y = y;
|
||||
Radius = radius <= 0 ? 1 : radius;
|
||||
Depth = depth;
|
||||
Exponent = exponent <= 0 ? 1.0 : exponent;
|
||||
WaveRadius = waveRadius;
|
||||
WaveDepth = waveDepth;
|
||||
WaveSpeed = waveSpeed;
|
||||
IconAssetUri = $"cultmesh://aetheria/assets/icons/ui/{IconKind(Kind)}";
|
||||
TintSplatAssetUri = "cultmesh://aetheria/assets/textures/tint_splat";
|
||||
}
|
||||
|
||||
public string Key { get; }
|
||||
public string Kind { get; }
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Radius { get; }
|
||||
public double Depth { get; }
|
||||
public double Exponent { get; }
|
||||
public double WaveRadius { get; }
|
||||
public double WaveDepth { get; }
|
||||
public double WaveSpeed { get; }
|
||||
public string IconAssetUri { get; }
|
||||
public string TintSplatAssetUri { get; }
|
||||
|
||||
private static string IconKind(string kind)
|
||||
{
|
||||
var normalized = kind?.ToLowerInvariant() ?? "";
|
||||
if (normalized.Contains("sun") || normalized.Contains("star"))
|
||||
return "sun";
|
||||
if (normalized.Contains("gas"))
|
||||
return "gasgiant";
|
||||
if (normalized.Contains("moon"))
|
||||
return "moon";
|
||||
if (normalized.Contains("orbital") || normalized.Contains("station") || normalized.Contains("colony"))
|
||||
return "orbital";
|
||||
if (normalized.Contains("wormhole"))
|
||||
return "wormhole";
|
||||
return "planet";
|
||||
}
|
||||
}
|
||||
|
||||
internal readonly struct AetheriaMainMenuGravityObject
|
||||
{
|
||||
public AetheriaMainMenuGravityObject(
|
||||
string key,
|
||||
string kind,
|
||||
string label,
|
||||
double x,
|
||||
double y,
|
||||
double directionX,
|
||||
double directionY,
|
||||
string factionKey,
|
||||
bool controlled,
|
||||
double visibility)
|
||||
{
|
||||
Key = key ?? "";
|
||||
Kind = string.IsNullOrWhiteSpace(kind) ? "object" : kind;
|
||||
Label = label ?? "";
|
||||
X = x;
|
||||
Y = y;
|
||||
DirectionX = directionX;
|
||||
DirectionY = directionY;
|
||||
FactionKey = factionKey ?? "";
|
||||
Controlled = controlled;
|
||||
Visibility = visibility <= 0 ? 1 : visibility;
|
||||
IconAssetUri = $"cultmesh://aetheria/assets/icons/ui/{IconKind(Kind)}";
|
||||
}
|
||||
|
||||
public string Key { get; }
|
||||
public string Kind { get; }
|
||||
public string Label { get; }
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double DirectionX { get; }
|
||||
public double DirectionY { get; }
|
||||
public string FactionKey { get; }
|
||||
public bool Controlled { get; }
|
||||
public double Visibility { get; }
|
||||
public string IconAssetUri { get; }
|
||||
|
||||
private static string IconKind(string kind)
|
||||
{
|
||||
var normalized = kind?.ToLowerInvariant() ?? "";
|
||||
if (normalized.Contains("station") || normalized.Contains("colony"))
|
||||
return "orbital";
|
||||
return "ship";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -852,7 +852,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
private static AetheriaRuntimeRtsBodyView ToBodyView(AetheriaRuntimeBodySnapshotCommit body)
|
||||
{
|
||||
return new AetheriaRuntimeRtsBodyView
|
||||
var view = new AetheriaRuntimeRtsBodyView
|
||||
{
|
||||
BodyKey = body.BodyKey ?? "",
|
||||
OrbitKey = body.OrbitKey ?? "",
|
||||
|
|
@ -864,6 +864,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
IsAsteroidBelt = (body.Kind ?? "").IndexOf("asteroid", StringComparison.OrdinalIgnoreCase) >= 0,
|
||||
Body = body
|
||||
};
|
||||
view.IconAsset = AetheriaRuntimeAssets.ResolveBodyIcon(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRtsGravityInfluence ToGravityInfluence(AetheriaRuntimeBodySnapshotCommit body)
|
||||
|
|
|
|||
|
|
@ -1494,5 +1494,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
[Key(8)]
|
||||
public AetheriaRuntimeBodySnapshotCommit Body { get; set; } =
|
||||
new AetheriaRuntimeBodySnapshotCommit();
|
||||
|
||||
[Key(9)]
|
||||
public AetheriaRuntimeAssetRef IconAsset { get; set; } =
|
||||
AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Sprite);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
IReadOnlyDictionary<string, string> props,
|
||||
IReadOnlyList<AetheriaRuntimeSurfaceComponent> children,
|
||||
IReadOnlyList<CultMeshStateBindingDescriptor> stateBindings,
|
||||
IReadOnlyList<AetheriaRuntimeEmbeddedDocumentSlot> embeddedDocuments)
|
||||
IReadOnlyList<AetheriaRuntimeEmbeddedDocumentSlot> embeddedDocuments,
|
||||
IReadOnlyDictionary<string, string>? layout = null,
|
||||
IReadOnlyDictionary<string, string>? style = null)
|
||||
{
|
||||
Id = id ?? "";
|
||||
Kind = kind ?? "";
|
||||
|
|
@ -252,6 +254,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
Children = children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>();
|
||||
StateBindings = stateBindings ?? Array.Empty<CultMeshStateBindingDescriptor>();
|
||||
EmbeddedDocuments = embeddedDocuments ?? Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>();
|
||||
Layout = layout ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
Style = style ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
[Key(0)]
|
||||
|
|
@ -271,6 +275,12 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
[Key(5)]
|
||||
public IReadOnlyList<AetheriaRuntimeEmbeddedDocumentSlot> EmbeddedDocuments { get; }
|
||||
|
||||
[Key(6)]
|
||||
public IReadOnlyDictionary<string, string> Layout { get; }
|
||||
|
||||
[Key(7)]
|
||||
public IReadOnlyDictionary<string, string> Style { get; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -496,7 +506,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
props,
|
||||
component.Children.Select(ToEveSurfaceComponent).ToArray(),
|
||||
component.StateBindings.Select(ToCultMeshStateBinding).ToArray(),
|
||||
component.EmbeddedDocuments.Select(ToEveEmbeddedDocumentSlot).ToArray());
|
||||
component.EmbeddedDocuments.Select(ToEveEmbeddedDocumentSlot).ToArray(),
|
||||
new Dictionary<string, string>(component.Layout, StringComparer.Ordinal),
|
||||
new Dictionary<string, string>(component.Style, StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
private static EveUiEmbeddedDocumentSlot ToEveEmbeddedDocumentSlot(AetheriaRuntimeEmbeddedDocumentSlot slot)
|
||||
|
|
@ -534,7 +546,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
props,
|
||||
ResolveStateRefs(component.Children, resolveStateRef),
|
||||
component.StateBindings,
|
||||
component.EmbeddedDocuments);
|
||||
component.EmbeddedDocuments,
|
||||
component.Layout,
|
||||
component.Style);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<EveUiSurfaceComponent> ResolveStateRefs(
|
||||
|
|
@ -558,7 +572,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
new Dictionary<string, string>(component.Props, StringComparer.Ordinal),
|
||||
component.Children.Select(FromPortableComponent).ToArray(),
|
||||
component.StateBindings.Select(FromPortableStateBinding).ToArray(),
|
||||
component.EmbeddedDocuments.Select(FromPortableEmbeddedDocumentSlot).ToArray());
|
||||
component.EmbeddedDocuments.Select(FromPortableEmbeddedDocumentSlot).ToArray(),
|
||||
new Dictionary<string, string>(component.Layout, StringComparer.Ordinal),
|
||||
new Dictionary<string, string>(component.Style, StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeEmbeddedDocumentSlot FromPortableEmbeddedDocumentSlot(
|
||||
|
|
|
|||
|
|
@ -781,7 +781,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
{
|
||||
return AetheriaRuntimeMainMenuSurfaceBuilder.BuildRoot(
|
||||
stateBoot,
|
||||
TryCurrentSectorMap(),
|
||||
TryCurrentDaemonFrame(),
|
||||
TryCurrentVerseHostSettings(),
|
||||
TryCurrentPlayerSettings(),
|
||||
canOpenRuntimeInputScreen,
|
||||
|
|
@ -847,12 +847,11 @@ namespace GameCult.Aetheria.State.Verse
|
|||
}
|
||||
}
|
||||
|
||||
AetheriaRuntimeSectorMapDocument? TryCurrentSectorMap()
|
||||
AetheriaRuntimeDaemonFrameDocument? TryCurrentDaemonFrame()
|
||||
{
|
||||
try
|
||||
{
|
||||
var frame = latestFrameDocument.Latest();
|
||||
return frame == null ? null : AetheriaRuntimeRtsDocuments.SectorMap(frame);
|
||||
return latestFrameDocument.Latest();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"displayName": "Aetheria State Runtime",
|
||||
"version": "0.1.0",
|
||||
"unity": "2021.3",
|
||||
"description": "Unity runtime boundary for Aetheria typed CultCache state and future CultMesh catalog boot.",
|
||||
"description": "Unity runtime boundary for Aetheria typed CultCache/CultMesh state.",
|
||||
"dependencies": {
|
||||
"com.gamecult.brokkr": "0.1.0",
|
||||
"org.gamecult.eve.surface": "0.1.0"
|
||||
|
|
|
|||
Loading…
Reference in a new issue