Publish exact equipment behavior levers

This commit is contained in:
Meta Vens 2026-07-17 03:37:49 +01:00
commit fa54847c39
5 changed files with 221 additions and 5 deletions

View file

@ -177,6 +177,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
BehaviorChainsGateAuthoritativeStatModifiers,
ResourceBehaviorsStopEquipmentChainsInAuthoredOrder,
ThermotoggleSeedsAndGatesFromDaemonOwnedTarget,
InputCapabilityPublishesExactBehaviorLevers,
ReflectorUsesSharedStellarLightFieldWithoutAccumulating,
SensorPingIsActorScopedEnergyGatedAndReconnectable,
TurretControllerAcquiresAimsAndTriggersExactWeapons,
@ -501,6 +502,116 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
}
}
private static void InputCapabilityPublishesExactBehaviorLevers()
{
var controls = CatalogItem("behavior-controls",
new AetheriaRuntimeBehaviorPayload(0, "Thruster", 0, []),
new AetheriaRuntimeBehaviorPayload(1, "Switch", 1, []),
new AetheriaRuntimeBehaviorPayload(2, "Trigger", 2, []),
new AetheriaRuntimeBehaviorPayload(3, "Thermotoggle", 3,
[
new AetheriaRuntimeBehaviorField(1, Number(300)),
new AetheriaRuntimeBehaviorField(2, BoolValue(false)),
new AetheriaRuntimeBehaviorField(3, BoolValue(true))
]),
new AetheriaRuntimeBehaviorPayload(4, "Thermotoggle", 4,
[
new AetheriaRuntimeBehaviorField(1, Number(350)),
new AetheriaRuntimeBehaviorField(2, BoolValue(false)),
new AetheriaRuntimeBehaviorField(3, BoolValue(false))
]));
controls.Name = "Climate Control";
var catalog = new AetheriaRuntimeCatalogSnapshot([controls], [], []);
var entity = Entity(0, 0, "player");
entity.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{ ItemKey = controls.ItemKey, Enabled = true, Durability = 1, Quality = 1 }
}];
AetheriaRuntimeBehaviorStateProjector.EnsureEquipmentBehaviorStates(entity, catalog);
entity.EquipmentStates = [new AetheriaRuntimeEquipmentStateCommit
{ EquipmentIndex = 0, Online = true }];
var run = new AetheriaRuntimeRunCheckpointCommit
{
RunId = "behavior-input-smoke",
CurrentZoneIndex = 0,
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [entity] }]
};
run.CurrentEntityKey = run.EntityRecordKey(0, entity.EntityIndex);
var frame = AetheriaRuntimeDaemonFrameDocument.Create(run, "smoke", "behavior-input", 1, 0.1, 0.1);
var capability = AetheriaRuntimeInputCapabilityDocument.FromFrame(frame, catalog: catalog);
RequireEqual("aetheria", capability.ProviderId,
"input capability must retain provider identity instead of substituting daemon service identity");
var actions = capability.Actions.Where(value => value.Category == "equipment").ToArray();
RequireEqual(3, actions.Length,
"input capability must omit non-interactive and fixed behaviors instead of activating behavior zero blindly");
var switchAction = actions.Single(value => value.ActionId == "equipment.0.behavior.1");
var triggerAction = actions.Single(value => value.ActionId == "equipment.0.behavior.2");
var thermostatAction = actions.Single(value => value.ActionId == "equipment.0.behavior.3");
RequireEqual("button-hold.v1", switchAction.InputValue?.Model ?? "",
"switch controls must advertise the fossil press/release input model");
RequireEqual("active", triggerAction.InputValue?.PayloadKey ?? "",
"trigger controls must route their input value into the typed active field");
RequireEqual("scalar.v1", thermostatAction.InputValue?.Model ?? "",
"adjustable thermostats must advertise a runtime-neutral scalar lever");
RequireEqual("300", thermostatAction.Payload["currentValue"],
"thermostat controls must publish the daemon-owned current target");
var switchRequest = new EveSurfaceCommandRequest(
capability.ProviderId,
AetheriaRuntimeDaemonGameSurfaceBuilder.PilotSurfaceId,
CultMesh.OperationInvocation(switchAction.Operation),
CultMesh.OperationPayload(
("entityId", run.CurrentEntityKey),
("equipmentIndex", "0"),
("behaviorIndex", "1"),
("active", "1")),
DateTimeOffset.UtcNow,
"behavior-input-smoke");
var switchTranslated = AetheriaRuntimeDaemonOperationsClient.TryCreateSurfaceCommandDocument(
switchRequest, frame, ".", "behavior-input-smoke", "behavior-input", out var switchCommand);
Require(switchTranslated &&
switchCommand?.Kind == AetheriaRuntimeDaemonCommandKinds.SetBehaviorActive &&
switchCommand.EquipmentIndex == 0 && switchCommand.BehaviorIndex == 1 &&
switchCommand.ScalarValue > 0.5,
$"the generic Eve action must translate into the exact typed switch command; accepted={switchTranslated}, kind={switchCommand?.Kind}, equipment={switchCommand?.EquipmentIndex}, behavior={switchCommand?.BehaviorIndex}, scalar={switchCommand?.ScalarValue}");
var switchResult = AetheriaRuntimeDaemonOperations.Execute(
run, [switchCommand!], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog });
AetheriaRuntimeBehaviorSimulation.Step(0, [entity], switchResult.Intents.Behaviors, catalog, 0.1);
Require(entity.BehaviorStates.Single(value => value.BehaviorIndex == 1).SwitchActivated,
"the advertised switch lever must reach the daemon behavior owner");
var thermostatRequest = new EveSurfaceCommandRequest(
capability.ProviderId,
AetheriaRuntimeDaemonGameSurfaceBuilder.PilotSurfaceId,
CultMesh.OperationInvocation(thermostatAction.Operation),
CultMesh.OperationPayload(
("entityId", run.CurrentEntityKey),
("targetEntityKey", run.CurrentEntityKey),
("equipmentIndex", "0"),
("behaviorIndex", "3"),
("scalarValue", "425")),
DateTimeOffset.UtcNow,
"behavior-input-smoke");
Require(AetheriaRuntimeDaemonOperationsClient.TryCreateSurfaceCommandDocument(
thermostatRequest, frame, ".", "behavior-input-smoke", "behavior-input", out var thermostatCommand) &&
thermostatCommand?.Kind == AetheriaRuntimeDaemonCommandKinds.SetThermotoggleTargetTemperature,
"the generic Eve scalar lever must translate into the typed thermostat command");
var thermostatResult = AetheriaRuntimeDaemonOperations.Execute(
run, [thermostatCommand!], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog });
RequireEqual(1, thermostatResult.AppliedCommandIds.Count,
"the translated thermostat command must pass daemon catalog authorization");
RequireNear(425, entity.BehaviorStates.Single(value => value.BehaviorIndex == 3)
.ThermotoggleTargetTemperature, 0.000001,
"the advertised scalar lever must mutate only daemon-owned thermostat state");
entity.EquipmentStates[0].Online = false;
var offline = AetheriaRuntimeInputCapabilityDocument.FromFrame(frame, catalog: catalog);
Require(offline.Actions.Where(value => value.Category == "equipment")
.All(value => value.Availability == "unavailable"),
"offline equipment must retain stable action identity while advertising current unavailability");
}
private static void DockedRefitSurfacePublishesGenericCommands()
{
var hull = HullCatalogItem("surface-hull", 9, 7, 100);

View file

@ -484,6 +484,19 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
frame,
ReadWeaponGroup(request),
ReadPayloadBool(request, "active", true)),
AetheriaRuntimeDaemonCommandKinds.SetBehaviorActive => client.SetBehaviorActive(
frame,
(int)ReadPayloadDouble(request, "equipmentIndex", -1),
(int)ReadPayloadDouble(request, "behaviorIndex", -1),
ReadPayloadBool(request, "active", true)),
AetheriaRuntimeDaemonCommandKinds.SetThermotoggleTargetTemperature =>
client.SetThermotoggleTargetTemperature(
frame,
ReadPayloadString(request, "targetEntityKey",
ReadPayloadString(request, "entityId", "")),
(int)ReadPayloadDouble(request, "equipmentIndex", -1),
(int)ReadPayloadDouble(request, "behaviorIndex", -1),
ReadPayloadDouble(request, "scalarValue", double.NaN)),
AetheriaRuntimeDaemonCommandKinds.SetTarget => client.SetTarget(
frame,
ReadPayloadString(request, "targetEntityId", ReadPayloadString(request, "entityId", ""))),

View file

@ -59,7 +59,7 @@ namespace GameCult.Aetheria.State.Verse
{
public const string SchemaId = "gamecult.eve.input_capability.v1";
[Key(0)] public string Schema { get; set; } = SchemaId;
[Key(1)] public string ProviderId { get; set; } = "aetheria.daemon";
[Key(1)] public string ProviderId { get; set; } = "aetheria";
[Key(2)] public string CapabilityId { get; set; } = "aetheria.pilot.input";
[Key(3)] public long Version { get; set; }
[Key(4)] public AetheriaRuntimeInputActionDocument[] Actions { get; set; } = Array.Empty<AetheriaRuntimeInputActionDocument>();
@ -92,7 +92,7 @@ namespace GameCult.Aetheria.State.Verse
if (entity != null)
{
actions.AddRange((entity.WeaponGroups ?? Array.Empty<IReadOnlyList<int>>()).Select((_, index) => Action($"weapon-group.{index}.fire", $"Fire Weapon Group {index + 1}", "FireWeaponGroup", "weapon-group", $"{run.CurrentEntityKey}#weapon-group/{index}", ("weaponGroup", index.ToString()))));
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(EquipmentBehaviorActions(run, entity, catalog));
actions.AddRange((entity.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>())
.SelectMany(bay => bay.Items)
.Where(slot => slot?.Item != null && AetheriaRuntimeConsumableSimulation.CanActivate(entity, catalog, slot.Item.ItemKey))
@ -108,6 +108,90 @@ namespace GameCult.Aetheria.State.Verse
return new AetheriaRuntimeInputCapabilityDocument { Version = frame?.FrameId ?? 0, Actions = actions.ToArray(), DefaultProfiles = BuildDefaultProfiles(actions) };
}
private static IEnumerable<AetheriaRuntimeInputActionDocument> EquipmentBehaviorActions(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeEntitySnapshotCommit entity,
AetheriaRuntimeCatalogSnapshot? catalog)
{
if (catalog == null)
yield break;
var states = (entity.BehaviorStates ?? Array.Empty<AetheriaRuntimeBehaviorStateCommit>())
.Where(value => value != null && string.Equals(value.OwnerKind,
AetheriaRuntimeBehaviorStateProjector.EquipmentOwnerKind, StringComparison.Ordinal))
.ToDictionary(value => (value.OwnerIndex, value.BehaviorIndex));
var online = (entity.EquipmentStates ?? Array.Empty<AetheriaRuntimeEquipmentStateCommit>())
.Where(value => value != null).ToDictionary(value => value.EquipmentIndex);
var equipment = entity.Equipment ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
for (var equipmentIndex = 0; equipmentIndex < equipment.Count; equipmentIndex++)
{
var installed = equipment[equipmentIndex]?.Item;
var item = catalog.FindItem(installed?.ItemKey ?? "");
if (installed == null || item == null)
continue;
var available = installed.Enabled && installed.Durability > 0.01 &&
(!online.TryGetValue(equipmentIndex, out var equipmentState) || equipmentState.Online);
var payloads = item.BehaviorPayloads ?? Array.Empty<AetheriaRuntimeBehaviorPayload>();
for (var behaviorIndex = 0; behaviorIndex < payloads.Count; behaviorIndex++)
{
var payload = payloads[behaviorIndex];
if (payload == null || !states.TryGetValue((equipmentIndex, behaviorIndex), out var state))
continue;
var source = $"{run.CurrentEntityKey}#equipment/{equipmentIndex}/behavior/{behaviorIndex}";
var actionId = $"equipment.{equipmentIndex}.behavior.{behaviorIndex}";
if (string.Equals(payload.Kind, "Switch", StringComparison.Ordinal) ||
string.Equals(payload.Kind, "Trigger", StringComparison.Ordinal))
{
var action = Action(
actionId,
$"{(payload.Kind == "Trigger" ? "Trigger" : "Activate")} {item.Name}",
"SetBehaviorActive",
"equipment",
source,
("equipmentIndex", equipmentIndex.ToString()),
("behaviorIndex", behaviorIndex.ToString()),
("active", "0"),
("currentValue", state.SwitchActivated ? "1" : "0"));
action.Availability = available ? "available" : "unavailable";
action.InputValue = new AetheriaRuntimeInputValueDocument
{
Model = "button-hold.v1",
PayloadKey = "active"
};
yield return action;
continue;
}
if (!string.Equals(payload.Kind, "Thermotoggle", StringComparison.Ordinal) ||
!ReadBool(payload, 3))
continue;
var thermostat = Action(
actionId,
$"Set {item.Name} Target Temperature",
"SetThermotoggleTargetTemperature",
"equipment",
source,
("targetEntityKey", run.CurrentEntityKey),
("equipmentIndex", equipmentIndex.ToString()),
("behaviorIndex", behaviorIndex.ToString()),
("scalarValue", state.ThermotoggleTargetTemperature.ToString("R", System.Globalization.CultureInfo.InvariantCulture)),
("currentValue", state.ThermotoggleTargetTemperature.ToString("R", System.Globalization.CultureInfo.InvariantCulture)),
("unit", "kelvin"));
thermostat.Availability = available ? "available" : "unavailable";
thermostat.InputValue = new AetheriaRuntimeInputValueDocument
{
Model = "scalar.v1",
PayloadKey = "scalarValue"
};
yield return thermostat;
}
}
}
private static bool ReadBool(AetheriaRuntimeBehaviorPayload payload, int key) =>
(payload.Fields ?? Array.Empty<AetheriaRuntimeBehaviorField>())
.FirstOrDefault(field => field != null && field.Key == key)?.Value?.BoolValue ?? false;
private static IEnumerable<AetheriaRuntimeInputActionDocument> TradeActions(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeEntitySnapshotCommit entity,

View file

@ -107,8 +107,16 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
methods instead of writing the input collections directly. The
action bar also uses typed runtime catalog category rows to reject
non-consumable inventory drops and creates consumable bindings around typed
catalog rows. Missing typed rows are rejected for consumable binding instead
of falling through to legacy DTO classification. Slot-binding drag/drop now
catalog rows. The provider input capability derives equipment controls from
exact installed payload indices: `Switch` and `Trigger` publish generic
`button-hold.v1` values, while adjustable `Thermotoggle` publishes a
`scalar.v1` Kelvin target with the daemon-owned current value. Fixed and
non-interactive behaviors publish no counterfeit action; offline equipment
retains stable action identity but is unavailable. Generic Eve requests for
both operations translate into their typed daemon commands. The capability
identifies provider `aetheria`; `aetheria.daemon.commands` remains only the
operation boundary and cannot replace provider identity. Missing typed rows
are rejected for consumable binding instead of falling through to legacy DTO classification. Slot-binding drag/drop now
routes through typed daemon operations, and rebuilt current-entity binds come from typed
action-bar descriptor rows instead of stale slot-local `Entity` references.
`AetheriaRuntimeConsumableSimulation` is the sole live owner of consumable

View file

@ -31,7 +31,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Wormhole travel | `ActionGameManager.EnterWormhole` plus `Ship` enter/exit state | daemon fixed-step transition plus Ymir exclusion | current-entity transition state and feedback chronology | provider-selected generic transition lowering | command acceptance no longer moves an entity immediately; player interact, explicit travel, and agent routing derive the same canonical adjacent-zone wormhole and proximity gate, then persist four-second `entering`, authoritative transfer, four-second `exiting`, and one-frame `completed` phases. The daemon owns smootherstep XZ motion, the fossil 1000-unit visual-depth lever, deterministic 20-unit exit direction, 50-unit exit radius, target-adjacency discovery, and exactly-once start/transfer/completion events. Flight and every world-physics implementation receive no transitioning body; Ymir resumes on the tick after completion. Smoke serializes and rehydrates mid-entry and proves agents traverse multi-edge routes through the same command boundary | generic provider transition effect/camera lowering and live multi-zone pilot witness |
| Inventory/equipment | `Entity.ItemFits`, `TryEquip`, `TryUnequip`, `EquippedCargoBay.ItemFits`/`TryStore`, inventory panels + ServerShared | daemon atomic inventory transactions | typed inventory/equipment state, commands, exact receipts | generic UI | generated cargo and docking bays now occupy their typed collections instead of masquerading as ordinary equipment; docked equip/reposition/store validates the complete destination on cloned state before committing either side, uses authored hull interior and hardpoint geometry, forces hardpoint rotation, rejects occupied cells and deployed ships, preserves exact item instance fields and weapon-group membership, routes bay categories with aligned content/assignment arrays, and refuses to unequip nonempty/occupied bays. Cargo transfer now uses the same plan-first rule with typed bay interiors, rotated item footprints, deterministic free-cell search, exact stack maxima, and no partial source/destination mutation on rejection; exact reasons reach generic Eve receipts | live generic refit controls, reconnect after accepted and rejected moves, commodity multi-stack chronology, and full fossil inventory feedback parity |
| Trade | trade UI/economy | daemon | stock, quote, purchase/sale commands | generic UI | daemon derives station, stock row, catalog item, current price, quantity, credits, target capacity, and hull-vs-cargo result; purchases ignore client opinions about price and destination kind. Docked sales identify only the source stack and quantity: the daemon derives station, instance-sensitive value, payout, deterministic typed stock placement, and commits cargo/credits atomically; generic Eve advertises available buy and sell actions. The generic Unity live witness receives an authoritative purchase receipt while paused | live sale receipt witness, quote expiry, contested stock, and full trade surface parity |
| Action bar/input | input shell and rebinding UI | daemon advertises actions; client owns bindings | input capability and action descriptors | universal binding UI | contracts wired; cargo actions are catalog-filtered to consumables the current actor can actually activate, including suppression of active non-stackable items | dynamic equipment behavior validity and runtime action-bar quantity/fill proof |
| Action bar/input | input shell and rebinding UI | daemon advertises actions; client owns bindings | input capability and action descriptors | universal binding UI | contracts wired; cargo actions are catalog-filtered to consumables the current actor can actually activate, including suppression of active non-stackable items. Equipment actions now derive from exact installed catalog payload/state pairs instead of blindly activating behavior zero: Switch and Trigger expose generic hold values, adjustable Thermotoggle exposes a scalar Kelvin target/current value, fixed/non-interactive rows are omitted, and offline rows retain identity as unavailable. Both action forms translate through generic Eve requests into typed daemon commands under provider identity `aetheria` | runtime action-bar quantity/fill proof and generic scalar-control lowering |
| Pilot camera | ARPG follow/dock cameras | Eve view semantics + runtime | camera rig and semantic view id | EveUnity camera rig | daemon dock state selects distinct contracts instead of collapsing both fossil cameras: undocked flight advertises the entity-forward `Third Person Rig` framing (distance 30, screen 0.64/0.19, FOV 60, lens 1-4096) and the shared `aim.presentation` convergence point as its look-at; Aetheria translates the fossil Cinemachine top-origin screen Y of `0.81` to Eve's bottom-origin viewport Y of `0.19`; EveUnity solves native pose while preserving both optical aim and advertised entity framing, without provider types; the retained dock projection remains separate | reproduce the dock camera's separate follow/look-at subjects, blend timeline, noise, and reconnect state |
| Render channels | Unity layers/culling masks | provider surface policy + runtime asset variant | semantic channel exclusions | EveUnity native layer mapping | wired, exclusive, and lowered: the pilot surface excludes the semantic `map` channel; the Unity asset variant maps `map` to its authored native layer; EveUnity subtracts that layer from the configured camera mask; portable state contains no Unity layer or mask; provider conversion preserves the source icon shader's unlit lighting model; the released witness proves the pilot camera excludes map glyphs while the map camera retains readable white glyphs without a scene light | preserve the channel proof while world presentation and transport continue to evolve |
| Minimap/tactical map | `ZoneRenderer`, map cameras | daemon world facts | explicit map projections | Unity and Electron | facts fragmented; generic lowerers absent | same state in both runtimes |