Publish portable Eve entity and input state

This commit is contained in:
Meta Vens 2026-07-12 23:29:14 +01:00
commit 88629e0c45
9 changed files with 131 additions and 32 deletions

View file

@ -1390,8 +1390,8 @@ static async Task PublishDaemonApiDocumentsAsync(
await node.MutableDocument<AetheriaRuntimeStarbridgeSessionSummaryDocument>(AetheriaRuntimeVerseRecordKeys.StarbridgeSessionSummary)
.ReplaceAsync(result.StarbridgeSessionSummary)
.ConfigureAwait(false);
await node.MutableDocument<AetheriaRuntimeInputCapabilityDocument>(AetheriaRuntimeVerseRecordKeys.PilotInputCapability)
.ReplaceAsync(AetheriaRuntimeInputCapabilityDocument.FromFrame(result.Frame))
await node.MutableDocument<EveInputCapabilityDocument>(AetheriaRuntimeVerseRecordKeys.PilotInputCapability)
.ReplaceAsync(AetheriaRuntimeInputCapabilityDocument.FromFrame(result.Frame).ToEveDocument())
.ConfigureAwait(false);
var mainMenuState = await node.MutableDocument<AetheriaMainMenuState>(AetheriaStateNode.MainMenuStateKey)
.ReadAsync()

View file

@ -5,16 +5,18 @@
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Description>Typed CultCache and CultMesh state spine for Aetheria.</Description>
<EveUnityRoot Condition="'$(EveUnityRoot)' == ''">$(MSBuildThisFileDirectory)..\..\EveUnity</EveUnityRoot>
<CultLibRoot Condition="'$(CultLibRoot)' == ''">$(MSBuildThisFileDirectory)..\..\CultLib</CultLibRoot>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\*.cs" Link="Runtime\%(Filename)%(Extension)" />
<ProjectReference Include="..\..\CultLib\src\GameCult.Caching\GameCult.Caching.csproj" />
<ProjectReference Include="..\..\CultLib\src\GameCult.Caching.MessagePack\GameCult.Caching.MessagePack.csproj" />
<ProjectReference Include="..\..\CultLib\src\GameCult.Mesh\GameCult.Mesh.csproj" />
<ProjectReference Include="..\..\CultLib\src\GameCult.Networking\GameCult.Networking.csproj" />
<ProjectReference Include="$(CultLibRoot)\src\GameCult.Caching\GameCult.Caching.csproj" />
<ProjectReference Include="$(CultLibRoot)\src\GameCult.Caching.MessagePack\GameCult.Caching.MessagePack.csproj" />
<ProjectReference Include="$(CultLibRoot)\src\GameCult.Mesh\GameCult.Mesh.csproj" />
<ProjectReference Include="$(CultLibRoot)\src\GameCult.Networking\GameCult.Networking.csproj" />
<ProjectReference Include="..\..\CultMath\src\CultMath\CultMath.csproj" />
<ProjectReference Include="..\..\EveUnity\packages\org.gamecult.eve.surface\GameCult.Eve.Surface.csproj" />
<ProjectReference Include="$(EveUnityRoot)\packages\org.gamecult.eve.surface\GameCult.Eve.Contracts.csproj" />
<ProjectReference Include="..\..\EvePlugins\plugins\eve-plugin-fields\GameCult.Eve.PluginFields.csproj" />
</ItemGroup>
</Project>

View file

@ -60,7 +60,7 @@ public static class AetheriaDocumentRegistry
typeof(AetheriaRuntimeStarbridgeScenarioDocument),
typeof(AetheriaRuntimeStarbridgeSessionDocument),
typeof(AetheriaRuntimeStarbridgeSessionSummaryDocument),
typeof(AetheriaRuntimeInputCapabilityDocument),
typeof(EveInputCapabilityDocument),
typeof(AetheriaRuntimeDaemonSoaViewDocument),
typeof(AetheriaRuntimeVerseAuthorityPolicyDocument),
typeof(AetheriaRuntimeAuthorityLeaseDocument),

View file

@ -8,6 +8,17 @@ namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeAssets
{
public static string ResolveEntityPrefabAssetRef(AetheriaRuntimeEntitySnapshotCommit entity)
{
if (entity == null) return "";
var kind = (entity.Kind ?? "").Trim().ToLowerInvariant();
if (kind.Contains("station")) return "prefab.entity.station";
if (kind.Contains("projectile")) return "prefab.entity.projectile";
if (kind.Contains("orbital")) return "prefab.entity.orbital";
return string.Equals(entity.FactionKey, "player", StringComparison.OrdinalIgnoreCase)
? "prefab.entity.player"
: "prefab.entity.ship";
}
public static AetheriaRuntimeAssetManifestDocument ProjectManifest(
AetheriaRuntimeCatalogSnapshot? catalog,
string runId = "",

View file

@ -576,6 +576,7 @@ namespace GameCult.Aetheria.State.Verse
["zoneRenderPointerId"] = AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest.ToString(),
["zoneRenderSchema"] = AetheriaRuntimeDaemonSchemas.ZoneRender,
["assetManifest"] = AetheriaRuntimeVerseRecordKeys.EveAssetCatalog.ToString(),
["inputCapability"] = AetheriaRuntimeVerseRecordKeys.PilotInputCapability.ToString(),
["inputProfile"] = "arpg.pointer-keyboard.v1",
["cameraRig"] = "arpg.orbital-follow.v1",
["viewId"] = "pilot",
@ -878,21 +879,7 @@ namespace GameCult.Aetheria.State.Verse
}
private static string PlayableWorldAssetRef(AetheriaRuntimeEntitySnapshotCommit entity)
{
if (entity == null)
return "";
var kind = (entity.Kind ?? "").Trim().ToLowerInvariant();
if (kind.Contains("station"))
return "prefab.entity.station";
if (kind.Contains("projectile"))
return "prefab.entity.projectile";
if (kind.Contains("orbital"))
return "prefab.entity.orbital";
if (string.Equals(entity.FactionKey, "player", StringComparison.OrdinalIgnoreCase))
return "prefab.entity.player";
return "prefab.entity.ship";
}
=> AetheriaRuntimeAssets.ResolveEntityPrefabAssetRef(entity);
private static double PlayableWorldRadius(AetheriaRuntimeEntitySnapshotCommit entity)
{

View file

@ -97,6 +97,10 @@ namespace GameCult.Aetheria.State.Verse
public IReadOnlyList<AetheriaRuntimeDaemonRenderGroupDocument> RenderGroups { get; set; } =
Array.Empty<AetheriaRuntimeDaemonRenderGroupDocument>();
[Key(13)]
public IReadOnlyList<AetheriaRuntimeDaemonSoaIdentityDocument> Identities { get; set; } =
Array.Empty<AetheriaRuntimeDaemonSoaIdentityDocument>();
public static AetheriaRuntimeDaemonSoaViewDocument Create(
string daemonId,
string sessionId,
@ -108,7 +112,8 @@ namespace GameCult.Aetheria.State.Verse
string backend = AetheriaRuntimeDaemonSoaBackends.CultCache,
string synchronizationMode = AetheriaRuntimeDaemonSoaSynchronizationModes.ImmutableFrame,
bool isAuthoritative = true,
IReadOnlyList<AetheriaRuntimeDaemonRenderGroupDocument>? renderGroups = null)
IReadOnlyList<AetheriaRuntimeDaemonRenderGroupDocument>? renderGroups = null,
IReadOnlyList<AetheriaRuntimeDaemonSoaIdentityDocument>? identities = null)
{
return new AetheriaRuntimeDaemonSoaViewDocument
{
@ -125,11 +130,25 @@ namespace GameCult.Aetheria.State.Verse
Buffers = buffers ?? Array.Empty<AetheriaRuntimeDaemonSoaBufferDocument>(),
Columns = columns ?? Array.Empty<AetheriaRuntimeDaemonSoaColumnDocument>(),
DirtyRanges = dirtyRanges ?? Array.Empty<AetheriaRuntimeDaemonSoaDirtyRangeDocument>(),
RenderGroups = renderGroups ?? Array.Empty<AetheriaRuntimeDaemonRenderGroupDocument>()
RenderGroups = renderGroups ?? Array.Empty<AetheriaRuntimeDaemonRenderGroupDocument>(),
Identities = identities ?? Array.Empty<AetheriaRuntimeDaemonSoaIdentityDocument>()
};
}
}
[MessagePackObject]
public sealed class AetheriaRuntimeDaemonSoaIdentityDocument
{
[Key(0)] public int EntityIndex { get; set; } = -1;
[Key(1)] public string EntityId { get; set; } = "";
[Key(2)] public string Kind { get; set; } = "";
[Key(3)] public string Label { get; set; } = "";
[Key(4)] public string Faction { get; set; } = "";
[Key(5)] public bool Selectable { get; set; } = true;
[Key(6)] public bool Controllable { get; set; }
[Key(7)] public string AssetRef { get; set; } = "";
}
[MessagePackObject]
public sealed class AetheriaRuntimeDaemonRenderGroupDocument
{

View file

@ -76,7 +76,18 @@ namespace GameCult.Aetheria.State.Verse
layout.CreateDirtyRanges(count, generation),
backend: AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile,
synchronizationMode: AetheriaRuntimeDaemonSoaSynchronizationModes.ImmutableFrame,
renderGroups: CreateRenderGroups(entities));
renderGroups: CreateRenderGroups(entities),
identities: entities.Select(entity => new AetheriaRuntimeDaemonSoaIdentityDocument
{
EntityIndex = entity.EntityIndex,
EntityId = entity.EntityId,
Kind = entity.Kind,
Label = entity.Name,
Faction = entity.FactionKey,
Selectable = true,
Controllable = string.Equals(entity.EntityId, run.CurrentEntityKey, StringComparison.Ordinal),
AssetRef = AetheriaRuntimeAssets.ResolveEntityPrefabAssetRef(entity)
}).ToArray());
return view;
}

View file

@ -70,6 +70,18 @@ namespace GameCult.Aetheria.State.Verse
ShadowMode = group.ShadowMode,
ReceiveShadows = group.ReceiveShadows,
Lod = group.Lod
}).ToArray(),
Identities = (source.Identities ?? Array.Empty<AetheriaRuntimeDaemonSoaIdentityDocument>())
.Select(identity => new EveEntitySoaIdentity
{
EntityIndex = identity.EntityIndex,
EntityId = identity.EntityId,
Kind = identity.Kind,
Label = identity.Label,
Faction = identity.Faction,
Selectable = identity.Selectable,
Controllable = identity.Controllable,
AssetRef = identity.AssetRef
}).ToArray()
};
}

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using GameCult.Caching;
using GameCult.Eve.Surface;
using MessagePack;
namespace GameCult.Aetheria.State.Verse
@ -45,7 +46,6 @@ namespace GameCult.Aetheria.State.Verse
[Key(2)] public AetheriaRuntimeInputBindingDocument[] Bindings { get; set; } = Array.Empty<AetheriaRuntimeInputBindingDocument>();
}
[CultDocument("gamecult.eve.input_capability", "gamecult.eve.input_capability.v1")]
[MessagePackObject]
public sealed class AetheriaRuntimeInputCapabilityDocument
{
@ -69,12 +69,11 @@ namespace GameCult.Aetheria.State.Verse
actions.AddRange((entity.Equipment ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>()).Where(slot => slot?.Item != null).Select((slot, index) => Action($"equipment.{index}.activate", $"Activate {slot.Item.ItemKey}", "SetBehaviorActive", "equipment", $"{run.CurrentEntityKey}#equipment/{index}", ("equipmentIndex", index.ToString()), ("behaviorIndex", "0"), ("active", "true"))));
actions.AddRange((entity.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>()).SelectMany(bay => bay.Items).Where(slot => slot?.Item != null).Select((slot, index) => Action($"cargo.{slot.Item.ItemKey}.{index}.use", $"Use {slot.Item.ItemKey}", "ActivateConsumable", "consumable", $"{run.CurrentEntityKey}#cargo/{index}", ("itemKey", slot.Item.ItemKey))));
}
return new AetheriaRuntimeInputCapabilityDocument { Version = frame?.FrameId ?? 0, Actions = actions.ToArray(), DefaultProfiles = BuildDefaultProfiles() };
return new AetheriaRuntimeInputCapabilityDocument { Version = frame?.FrameId ?? 0, Actions = actions.ToArray(), DefaultProfiles = BuildDefaultProfiles(actions) };
}
private static IEnumerable<AetheriaRuntimeInputActionDocument> CoreActions()
{
yield return Action("pilot.fire", "Fire", "FireWeaponGroup", "combat", "pilot", ("weaponGroup", "0"));
yield return Action("pilot.scoop", "Scoop", "SetTractorPower", "ship", "pilot", ("scalarValue", "1"));
yield return Action("pilot.dock", "Dock", "DockNearest", "ship", "pilot");
yield return Action("pilot.undock", "Undock", "Undock", "ship", "pilot");
@ -84,10 +83,68 @@ namespace GameCult.Aetheria.State.Verse
private static AetheriaRuntimeInputActionDocument Action(string id, string label, string operation, string category, string source, params (string Key, string Value)[] payload) =>
new AetheriaRuntimeInputActionDocument { ActionId = id, Label = label, Operation = "aetheria.daemon.commands." + operation, Category = category, SourceRef = source, Payload = payload.ToDictionary(entry => entry.Key, entry => entry.Value, StringComparer.Ordinal) };
private static AetheriaRuntimeInputProfileDocument[] BuildDefaultProfiles() => new[]
private static AetheriaRuntimeInputProfileDocument[] BuildDefaultProfiles(IReadOnlyCollection<AetheriaRuntimeInputActionDocument> actions)
{
Profile("keyboard-mouse", "keyboard-mouse", Binding("fire.mouse", "pilot.fire", "direct", "mouse.primary"), Binding("scoop.shift", "pilot.scoop", "direct", "keyboard.leftShift"), Binding("dock.r", "pilot.dock", "direct", "keyboard.r")),
Profile("gamepad", "gamepad", Binding("fire.trigger", "pilot.fire", "direct", "gamepad.rightTrigger"), Binding("scoop.sequence", "pilot.scoop", "sequence", "gamepad.dpad.down", "gamepad.dpad.right"), Binding("dock.sequence", "pilot.dock", "sequence", "gamepad.dpad.down", "gamepad.dpad.up"))
return new[]
{
Profile("keyboard-mouse", "keyboard-mouse", DefaultBindings(actions, "mouse.primary", "gamepad.rightTrigger", keyboard: true)),
Profile("gamepad", "gamepad", DefaultBindings(actions, "mouse.primary", "gamepad.rightTrigger", keyboard: false))
};
}
private static AetheriaRuntimeInputBindingDocument[] DefaultBindings(
IReadOnlyCollection<AetheriaRuntimeInputActionDocument> actions,
string keyboardFireControl,
string gamepadFireControl,
bool keyboard)
{
var bindings = new List<AetheriaRuntimeInputBindingDocument>();
var fire = actions.FirstOrDefault(action => string.Equals(action.Category, "weapon-group", StringComparison.Ordinal));
if (fire != null)
bindings.Add(Binding("fire.default", fire.ActionId, "direct", keyboard ? keyboardFireControl : gamepadFireControl));
bindings.Add(keyboard
? Binding("scoop.shift", "pilot.scoop", "direct", "keyboard.leftShift")
: Binding("scoop.sequence", "pilot.scoop", "sequence", "gamepad.dpad.down", "gamepad.dpad.right"));
bindings.Add(keyboard
? Binding("dock.r", "pilot.dock", "direct", "keyboard.r")
: Binding("dock.sequence", "pilot.dock", "sequence", "gamepad.dpad.down", "gamepad.dpad.up"));
return bindings.ToArray();
}
public EveInputCapabilityDocument ToEveDocument() => new EveInputCapabilityDocument
{
ProviderId = ProviderId,
CapabilityId = CapabilityId,
Version = Version,
Actions = Actions.Select(action => new EveInputActionDocument
{
ActionId = action.ActionId,
Label = action.Label,
Operation = action.Operation,
Context = action.Context,
Category = action.Category,
Availability = action.Availability,
SourceRef = action.SourceRef,
Payload = new Dictionary<string, string>(action.Payload, StringComparer.Ordinal)
}).ToArray(),
DefaultProfiles = DefaultProfiles.Select(profile => new EveInputProfileDocument
{
ProfileId = profile.ProfileId,
DeviceClass = profile.DeviceClass,
Bindings = profile.Bindings.Select(binding => new EveInputBindingDocument
{
BindingId = binding.BindingId,
ActionId = binding.ActionId,
ActionBar = binding.ActionBar,
Gesture = new EveInputGestureDocument
{
Kind = binding.Gesture.Kind,
Controls = binding.Gesture.Controls,
MaxStepIntervalMs = binding.Gesture.MaxStepIntervalMs,
CompletionControl = binding.Gesture.CompletionControl
}
}).ToArray()
}).ToArray()
};
private static AetheriaRuntimeInputProfileDocument Profile(string id, string device, params AetheriaRuntimeInputBindingDocument[] bindings) => new AetheriaRuntimeInputProfileDocument { ProfileId = id, DeviceClass = device, Bindings = bindings };