From ab74b0970a1d0aafde6631a296936bf4c07ba757 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 17 Jul 2026 01:52:36 +0100 Subject: [PATCH] Run fossil velocity controls in daemon --- Aetheria.State.Daemon.Smoke/Program.cs | 50 +++++++++++++++++++ .../Runtime/AetheriaRuntimeBehaviorKinds.cs | 3 ++ .../AetheriaRuntimeFlightSimulation.cs | 33 ++++++++++++ docs/aetheria-perfect-machine-map.md | 12 ++++- docs/original-game-migration-matrix.md | 2 +- 5 files changed, 98 insertions(+), 2 deletions(-) diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index adedc0e14..002ae5135 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -173,6 +173,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks RefitIsAtomicAndUsesTypedPlacement, CargoTransferUsesSpatialAtomicTransaction, DockedRefitSurfacePublishesGenericCommands, + FossilVelocityBehaviorsRunInDaemonFlightStep, TractorRampsAndPullsThroughYmirWithoutTeleportingCargo, PickupIsCapacityCheckedExactlyOnceAndExpires, TradePurchaseDerivesAcceptanceFromDaemonState, @@ -339,6 +340,55 @@ internal sealed class AetheriaDaemonYmirSmokeChecks }; } + private static void FossilVelocityBehaviorsRunInDaemonFlightStep() + { + var conversion = new AetheriaRuntimeBehaviorPayload( + 0, + AetheriaRuntimeBehaviorKinds.VelocityConversion, + 0, + [new AetheriaRuntimeBehaviorField(1, PerformanceStat(Math.Log(2)))]); + var limit = new AetheriaRuntimeBehaviorPayload( + 1, + AetheriaRuntimeBehaviorKinds.VelocityLimit, + 0, + [new AetheriaRuntimeBehaviorField(1, PerformanceStat(4))]); + var hull = HullCatalogItem("velocity-hull", 1, 1, 100); + var controller = CatalogItem("velocity-controller", conversion, limit); + var catalog = new AetheriaRuntimeCatalogSnapshot([hull, controller], [], []); + var ship = Entity(0, 0, "player"); + ship.HullItemKey = hull.ItemKey; + ship.DirectionX = 1; + ship.DirectionY = 0; + ship.VelocityX = 0; + ship.VelocityY = 10; + ship.Equipment = + [ + new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit + { + ItemKey = controller.ItemKey, + Quantity = 1, + Quality = 1, + Durability = 1, + Enabled = true + } + } + ]; + + AetheriaRuntimeBehaviorStateProjector.EnsureEquipmentBehaviorStates(ship, catalog); + AetheriaRuntimeFlightSimulation.Step([ship], [], catalog, 1, 1, 1, 0, 1); + + RequireNear(4, Math.Sqrt(ship.VelocityX * ship.VelocityX + ship.VelocityY * ship.VelocityY), 0.000001, + "VelocityLimit must clamp the post-conversion speed in the authoritative flight step"); + RequireNear(ship.VelocityX, ship.VelocityY, 0.000001, + "VelocityConversion must exponentially align velocity toward the ship direction before limiting"); + var limitState = ship.BehaviorStates.Single(state => + state.BehaviorKind == AetheriaRuntimeBehaviorKinds.VelocityLimit); + RequireNear(4, limitState.VelocityLimit, 0.000001, + "VelocityLimit must publish its evaluated runtime value for Eve and reconnect"); + } + private static void DockingUsesRealBaysAndFossilUndockRules() { var catalog = new AetheriaRuntimeCatalogSnapshot( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeBehaviorKinds.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeBehaviorKinds.cs index cd32d73dd..6a103d1fd 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeBehaviorKinds.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeBehaviorKinds.cs @@ -15,6 +15,9 @@ namespace GameCult.Aetheria.State.Verse public const string DeployableWeapon = "DeployableWeapon"; public const string AetherDrive = "AetherDrive"; public const string Thruster = "Thruster"; + public const string VelocityConversion = "VelocityConversion"; + public const string VelocityLimit = "VelocityLimit"; + public const string Reflector = "Reflector"; private static readonly ISet WeaponKinds = new HashSet(StringComparer.Ordinal) { diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeFlightSimulation.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeFlightSimulation.cs index 2e990418e..6fbd8f2fa 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeFlightSimulation.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeFlightSimulation.cs @@ -54,6 +54,39 @@ namespace GameCult.Aetheria.State.Verse StepAetherDrive(entity, drive, mass, deltaSeconds, catalog, aetherTorqueMultiplier, aetherHeatMultiplier); ApplyHullDrag(entity, catalog, deltaSeconds); + ApplyVelocityBehaviors(entity, catalog, deltaSeconds); + } + } + + private static void ApplyVelocityBehaviors( + AetheriaRuntimeEntitySnapshotCommit entity, + AetheriaRuntimeCatalogSnapshot catalog, + double deltaSeconds) + { + foreach (var behavior in Online(entity, catalog, AetheriaRuntimeBehaviorKinds.VelocityConversion)) + { + var speed = Math.Sqrt(entity.VelocityX * entity.VelocityX + entity.VelocityY * entity.VelocityY); + var direction = Normalize(entity.DirectionX, entity.DirectionY, 0, 1); + var targetX = direction.X * speed; + var targetY = direction.Y * speed; + var lambda = Math.Max(0, behavior.EvaluateStat( + 1, ThermalPerformance(entity, behavior.EquipmentIndex))); + var blend = 1 - Math.Exp(-lambda * deltaSeconds); + entity.VelocityX += (targetX - entity.VelocityX) * blend; + entity.VelocityY += (targetY - entity.VelocityY) * blend; + } + + foreach (var behavior in Online(entity, catalog, AetheriaRuntimeBehaviorKinds.VelocityLimit)) + { + var limit = Math.Max(0, behavior.EvaluateStat( + 1, ThermalPerformance(entity, behavior.EquipmentIndex))); + behavior.State.VelocityLimit = limit; + var speed = Math.Sqrt(entity.VelocityX * entity.VelocityX + entity.VelocityY * entity.VelocityY); + if (speed <= limit || speed <= 0.000001) + continue; + var scale = limit / speed; + entity.VelocityX *= scale; + entity.VelocityY *= scale; } } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 13b4f9e46..b4b044ac6 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -997,6 +997,13 @@ projectile lead, hardpoint gating, progressive lock, and target destruction. - Outputs: actual entity direction and velocity, persistent helm/look state, typed Thruster/AetherDrive behavior state, equipment heat, plume visibility, and the Ymir-integrated body pose. +- Velocity-controller invariant: after thrust, drive force, and hull drag, each + operational `VelocityConversion` exponentially aligns the existing velocity + magnitude toward hull direction with the fossil `1 - exp(-lambda * delta)` + damp factor. Operational `VelocityLimit` behaviors then clamp that resulting + magnitude and publish the evaluated limit in durable behavior state. The + daemon owns both mutations before Ymir integrates the body; the client only + renders their consequences and controls their ordinary equipment state. - Ordinary-flight invariant: standard ships fly through directional thrusters. The daemon clears and reallocates their axes each tick using the fossil forward/reverse/left/right rotation groups, symmetric lateral-torque @@ -1047,7 +1054,10 @@ projectile lead, hardpoint gating, progressive lock, and target destruction. thrusters, placement-derived torque/thrust state, funded heat and plume, unfunded no-motion/no-plume behavior, progressive hardware turning before weapon lock, autonomous navigation and cross-zone travel through Ymir, and - isolated rare AetherDrive spool/force on a modified-hull fixture. Canonical + isolated rare AetherDrive spool/force on a modified-hull fixture. It also + proves the fossil exponential velocity-conversion equation runs before the + evaluated velocity limit and that the limit survives in reconnectable + behavior state. Canonical catalog assertions lock the restored common hull identities and the `Traction`/`LonginusX` rarity boundary; a 2,000-loadout deterministic witness proves rare candidates remain possible without becoming the default path. diff --git a/docs/original-game-migration-matrix.md b/docs/original-game-migration-matrix.md index 2f899d807..c98fae042 100644 --- a/docs/original-game-migration-matrix.md +++ b/docs/original-game-migration-matrix.md @@ -18,7 +18,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Run/session state | `ServerShared`, `ActionGameManager` | Aetheria daemon/CultCache | provider/session advertisement plus run lifecycle bindings | all clients | active/failed lifecycle is daemon-owned and restart-stable: controlled-entity destruction commits the fossil cause, terminal frame, one `run.failed` fact, releases control, rejects later gameplay commands, and freezes the world; Eve receives terminal presentation/input levers without becoming an owner. Docked, travelling, fighting, mining, looting, and refitting remain derived world conditions rather than counterfeit durable phases | full-daemon death/restart witness, multi-client convergence, and a source-backed game-mode completion rule; the fossil supplied no victory transition | | Entity identity/loadout | `ServerShared/Entity*` | daemon | typed entity and inventory surfaces | EveUnity/Electron | owner-exists; wired; projected; not proven | loadout round trip and reconnect | | Loadout generation | map/faction availability, item cost, hull hardpoints and role constraints | daemon using canonical galaxy, faction knowledge/economy and typed catalog | generated loadout plus provenance/availability facts | Eve inspection and refit surfaces | daemon now uses the fossil candidate filter and seeded weighted selection: manufacturer must be present and allied, ally weight decays by home-zone graph distance, price uses the authored exponent, and hardpoints require matching semantic type, rotated footprint containment, and controller role; the April 2021 catalog fossil restores the distinct common `Longinus`, rare AetherDrive-compatible `LonginusX`, and `Djinni` rows with their original IDs, shapes, hardpoints, prices, drag, and prefabs, plus missing Thruster rows required to fill their authored mounts; typed `rarity:rare` tags apply a 0.05 generation multiplier to `LonginusX` and AetherDrive equipment; the generator owns one mutable CultMath stream, fixing the readonly-struct defensive-copy bug that restarted every weighted draw; placement rotation survives durable state and reconnect; generation fills the largest compatible footprint before economic weighting; cargo/capacitor plus station docking equipment must fit remaining hull space; stations pack faction-available inventory largest-first; ordinary ships begin without invented scenario cargo; every generated entity persists a source/selection receipt that reaches Eve as `loadout.item` semantics | multi-zone generated-world parity and exact root-to-zone stream sequencing against the fossil | -| Flight intent | `Ship`, `Thruster`, `AetherDrive`, input paths | daemon actuator simulation + Ymir integration | analog local helm/look/tractor plus actuator state | generic Eve input and scene lowerers | direct faction-speed velocity ownership is deleted; daemon persists local strafe/forward helm and desired look, allocates ordinary directional thruster banks by authored rotation, derives torque from hull/item placement, compensates lateral torque, gates execution through the shared energy ledger, deposits equipment-cell heat, publishes plume visibility and actuator state, applies hull drag, and gives resulting velocity/direction to Ymir. Autonomous tasks translate world travel into the same local helm axes and issue look commands instead of mutating heading. AetherDrive rotor/coupling simulation is additive and explicitly non-default: common `Longinus` and `Djinni` hulls use ordinary thrusters; the rare `LonginusX` replaces those mounts with the single rare `Traction` AetherDrive path | hardpoint-transform direction parity, exact behavior execution ordering, CultMath/float32 parity harness, live production-frequency evidence, generic thrust/turn feedback lowering, and live handling screenshots | +| Flight intent | `Ship`, `Thruster`, `AetherDrive`, `VelocityConversion`, `VelocityLimit`, input paths | daemon actuator simulation + Ymir integration | analog local helm/look/tractor plus actuator state | generic Eve input and scene lowerers | direct faction-speed velocity ownership is deleted; daemon persists local strafe/forward helm and desired look, allocates ordinary directional thruster banks by authored rotation, derives torque from hull/item placement, compensates lateral torque, gates execution through the shared energy ledger, deposits equipment-cell heat, publishes plume visibility and actuator state, applies hull drag, then runs operational velocity conversion with the fossil exponential damp equation and clamps the result through evaluated velocity limits before giving velocity/direction to Ymir. The evaluated limit remains in durable behavior state for reconnect and Eve inspection. Autonomous tasks translate world travel into the same local helm axes and issue look commands instead of mutating heading. AetherDrive rotor/coupling simulation is additive and explicitly non-default: common `Longinus` and `Djinni` hulls use ordinary thrusters; the rare `LonginusX` replaces those mounts with the single rare `Traction` AetherDrive path | hardpoint-transform direction parity, exact cross-equipment behavior execution ordering, CultMath/float32 parity harness, live production-frequency evidence, generic thrust/turn feedback lowering, and live handling screenshots | | Collision | Unity physics and entity handlers | Ymir | collision/result facts | visual interpolation only | Ymir.Core world stepping wired for entity bodies, radial fields and contacts; missing-owner negative proof passes | publish authoritative collision events and prove Unity cannot write transforms back | | Targeting/contacts | sensors + `ActionGameManager` | daemon | contact/target semantics | target HUD and indicators | simplified owner wired/projected; every authored instant lock behavior now evaluates on every daemon step independently of trigger/burst selection, so an idle weapon cannot retain a stale completed lock; acquisition and decay derive from facing, elapsed time, and observer-local contact confidence instead of granting an immediate perfect lock; target changes and invalid targets clear the daemon state; `weapon.lock.started`, `weapon.lock.acquired`, and `weapon.lock.lost` publish stable one-time chronology with target, weapon identity, reason, and prior/current progress through the generic feedback stream; the provider cockpit and generic combat reticle consume the same continuous selected-target lock without client smoothing or reconstruction | angular loss fixture, visibility/nearest/explicit targeting cases, provider audio/effect roles, and authored reticle parity | | Projectile flight | weapon/projectile classes | Eve presentation for ordinary tracers; Ymir for persistent physical payloads | receipt trajectory/effect facts or persistent payload state | native projectile visual | ordinary instant, charged, and constant execution creates no projectile body; each weapon state owns a stable shot sequence and receipts carry origin, endpoint, nominal duration, and effect identity for Eve presentation; `SpawnProjectile` and its alternate writer are deleted; Ymir projectile contacts are feedback-only for explicitly persisted payload rows and cannot write damage; Ymir.Core remains embedded for world integration, radial fields, circle contacts, pickups, and genuinely persistent/interceptable payloads | split/rename the remaining physical-payload interface and remove ordinary projectile terminology from runtime contracts |