From f6a1650769a13d4ba8badcb05e678c9b922f4343 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 00:54:16 +0100 Subject: [PATCH] Replace ordinary projectiles with receipt trajectories --- Aetheria.State.Daemon.Smoke/Program.cs | 24 ++--- ...AetheriaRuntimeDaemonGameSurfaceBuilder.cs | 6 +- .../AetheriaRuntimeDaemonSimulation.cs | 99 +++++++------------ .../AetheriaRuntimeSnapshotDocuments.cs | 7 ++ docs/original-game-migration-matrix.md | 2 +- 5 files changed, 58 insertions(+), 80 deletions(-) diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index f6d700d6a..2d00ac55b 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -194,7 +194,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks new AetheriaYmirWorldPhysics(), new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), 0, 0); - Require(zone.Projectiles.Count == 0 && !run.GameEvents.Any(value => value.Kind == "projectile.launched"), + Require(zone.Projectiles.Count == 0 && !run.GameEvents.Any(value => value.Kind == "shot.committed"), "pressing an authored ChargedWeapon must not bypass charging through the instant weapon resolver"); Require(Math.Abs(Stat(target, "hull") - 100) < 0.000001, "charged weapon admission must not apply damage before a daemon-owned release commits the shot"); @@ -206,7 +206,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), frame, frame * 0.1); Require(state.Charging && state.Charged && state.Charge >= 1 && state.ChargeHoldSeconds > 0, "one semantic request must precharge without a firing solution and enter persisted hold state"); - Require(!run.GameEvents.Any(value => value.Kind == "projectile.launched"), + Require(!run.GameEvents.Any(value => value.Kind == "shot.committed"), "ready charged weapon must hold rather than invent a firing solution"); source.TargetEntityIndex = target.EntityIndex; AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, @@ -214,7 +214,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks new AetheriaYmirWorldPhysics(), new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), 11, 1.1); Require(run.GameEvents.Count(value => value.Kind == "weapon.charge.committed") == 1 && - run.GameEvents.Any(value => value.Kind == "projectile.launched" && + run.GameEvents.Any(value => value.Kind == "shot.committed" && value.ItemKey == "test-charged" && Math.Abs(value.ScalarValue - 40) < 0.000001), "stored full charge must commit automatically when a firing solution becomes available"); var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build( @@ -271,7 +271,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks Require(run.GameEvents.Count(value => value.Kind == "weapon.charge.malfunctioned" && value.SubjectKey == "hold-risk" && value.ItemKey == item.ItemKey) == 1, "charged hold risk must emit one authoritative malfunction event"); - Require(!run.GameEvents.Any(value => value.Kind == "projectile.launched"), + Require(!run.GameEvents.Any(value => value.Kind == "shot.committed"), "malfunction without a firing solution must never leak a projectile"); } @@ -927,7 +927,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var weapon = (agent.WeaponStates ?? Array.Empty()) .Single(value => value.OwnerKind == AetheriaRuntimeBehaviorStateProjector.EquipmentOwnerKind); sawPartialLock |= weapon.LockProgress > 0 && weapon.LockProgress < 0.99; - if (firstLaunchFrame < 0 && run.GameEvents.Any(value => value.Kind == "projectile.launched")) + if (firstLaunchFrame < 0 && run.GameEvents.Any(value => value.Kind == "shot.committed")) firstLaunchFrame = frame; if (string.Equals(run.AgentTasks.Single().Status, AetheriaRuntimeAgentTaskStatuses.Completed, StringComparison.Ordinal)) break; @@ -937,9 +937,9 @@ internal sealed class AetheriaDaemonYmirSmokeChecks Require(sawFireCommand, "attack agent must fire through the shared weapon-group command"); Require(sawPartialLock, "attack agent must acquire a persisted partial weapon lock before firing"); Require(firstLaunchFrame > 1, "accepted fire intent must not bypass progressive weapon lock acquisition"); - Require(run.GameEvents.Any(value => value.Kind == "projectile.launched" && value.SourceEntityIndex == agent.EntityIndex), - "accepted fire control must emit authoritative projectile launch chronology"); - Require(run.GameEvents.Any(value => value.Kind == "projectile.launched" && + Require(run.GameEvents.Any(value => value.Kind == "shot.committed" && value.SourceEntityIndex == agent.EntityIndex), + "accepted fire control must emit authoritative shot commitment chronology"); + Require(run.GameEvents.Any(value => value.Kind == "shot.committed" && value.ItemKey == "test-lock-cannon" && Math.Abs(value.ScalarValue - (7.0 / 3.0)) < 0.000001), "daemon combat must divide authored damage across the configured burst rounds"); Require((agent.WeaponStates ?? Array.Empty()).Any(value => value.OwnerKind == AetheriaRuntimeBehaviorStateProjector.EquipmentOwnerKind && @@ -953,8 +953,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks 0.000001, "two authored bursts must drain exactly their combined energy from canonical capacitor state"); RequireEqual(1, CargoQuantity(agent, "test-ammo"), "one empty magazine must consume exactly one reserve cargo commodity before reload"); - Require(run.GameEvents.Count(value => value.Kind == "projectile.launched" && value.ItemKey == "test-lock-cannon") >= 6, - "two authored bursts must emit all six due rounds through the projectile owner"); + Require(run.GameEvents.Count(value => value.Kind == "shot.committed" && value.ItemKey == "test-lock-cannon") >= 6, + "two authored bursts must commit all six due rounds through the shot resolver"); Require(run.ShotReceipts.Count(value => value.WeaponItemKey == "test-lock-cannon") >= 6 && run.ShotReceipts.All(value => value.Hit && value.AppliedDamage == value.NominalDamage), "zero-spread authored rounds must commit immutable certain-hit receipts before presentation travel"); @@ -967,8 +967,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var reloadStarted = run.GameEvents.Single(value => value.Kind == "weapon.reload.started").FrameId; var reloadCompleted = run.GameEvents.Single(value => value.Kind == "weapon.reload.completed").FrameId; Require(reloadCompleted > reloadStarted && !run.GameEvents.Any(value => - value.Kind == "projectile.launched" && value.FrameId > reloadStarted && value.FrameId < reloadCompleted), - "reload interval must be a projectile-free authoritative timeline, not a cosmetic client delay"); + value.Kind == "shot.committed" && value.FrameId > reloadStarted && value.FrameId < reloadCompleted), + "reload interval must be a shot-free authoritative timeline, not a cosmetic client delay"); Require(!target.IsActive, $"attack task must end through daemon shot resolution before presentation projectile contacts; hull={Stat(target, "hull"):0.###} " + $"agent={agent.PositionX:0.###},{agent.PositionZ:0.###} target={target.PositionX:0.###},{target.PositionZ:0.###} " + diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index febe792cf..d1890938b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -327,7 +327,11 @@ namespace GameCult.Aetheria.State.Verse ("hitRoll", FormatNumber(value.HitRoll)), ("hit", value.Hit ? "true" : "false"), ("nominalDamage", FormatNumber(value.NominalDamage)), - ("appliedDamage", FormatNumber(value.AppliedDamage)) + ("appliedDamage", FormatNumber(value.AppliedDamage)), + ("origin", string.Join(",", FormatNumber(value.OriginX), FormatNumber(value.OriginZ))), + ("endpoint", string.Join(",", FormatNumber(value.EndpointX), FormatNumber(value.EndpointZ))), + ("presentationDuration", FormatNumber(value.PresentationDurationSeconds)), + ("presentationKind", value.PresentationKind) })) .ToArray(); return Node("aetheria.daemon.game.shots", "shot.receipt-stream", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs index 9bb0e8bc0..489161a50 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs @@ -323,9 +323,9 @@ namespace GameCult.Aetheria.State.Verse } weapon.State.BurstRemaining--; weapon.State.BurstTimer -= weapon.State.BurstInterval; - var projectile = SpawnProjectile(zone, attacker, target, weapon, settings); - CommitShotResolution(run, zone, attacker, target, weapon, projectile.ProjectileId, frameId); - AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit { EventId = $"projectile:{projectile.ProjectileId}:launched", Kind = "projectile.launched", FrameId = frameId, ZoneIndex = zone.ZoneIndex, SourceEntityIndex = attacker.EntityIndex, TargetEntityIndex = target.EntityIndex, SubjectKey = projectile.ProjectileId, ItemKey = projectile.WeaponKind, ScalarValue = projectile.Damage, PositionX = projectile.PositionX, PositionZ = projectile.PositionZ }); + var shotId = NextShotId(zone, attacker, weapon); + CommitShotResolution(run, zone, attacker, target, weapon, shotId, frameId); + AppendShotCommittedEvent(run, zone, attacker, target, weapon, shotId, frameId); weapon.State.Firing = true; AetheriaRuntimeThermalSimulation.AddHeat(attacker, weapon.Heat); } @@ -481,16 +481,9 @@ namespace GameCult.Aetheria.State.Verse } state.BurstRemaining--; state.BurstTimer -= state.BurstInterval; - var projectile = SpawnProjectile(zone, attacker, solutionTarget, shot, settings); - CommitShotResolution(run, zone, attacker, solutionTarget, shot, projectile.ProjectileId, frameId); - AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit - { - EventId = $"projectile:{projectile.ProjectileId}:launched", Kind = "projectile.launched", - FrameId = frameId, ZoneIndex = zone.ZoneIndex, SourceEntityIndex = attacker.EntityIndex, - TargetEntityIndex = solutionTarget.EntityIndex, SubjectKey = projectile.ProjectileId, - ItemKey = projectile.WeaponKind, ScalarValue = projectile.Damage, - PositionX = projectile.PositionX, PositionZ = projectile.PositionZ - }); + var shotId = NextShotId(zone, attacker, shot); + CommitShotResolution(run, zone, attacker, solutionTarget, shot, shotId, frameId); + AppendShotCommittedEvent(run, zone, attacker, solutionTarget, shot, shotId, frameId); state.Firing = true; AetheriaRuntimeThermalSimulation.AddHeat(attacker, shot.Heat); } @@ -642,8 +635,9 @@ namespace GameCult.Aetheria.State.Verse weapon.State.LastRefusalReason = ""; AetheriaRuntimeThermalSimulation.AddHeat(attacker, weapon.Heat * deltaSeconds); var shot = weapon.ResolutionShot(deltaSeconds); - var shotId = $"shot:{zone.ZoneIndex}:{frameId}:{attacker.EntityIndex}:{weapon.State.OwnerIndex}:{weapon.State.BehaviorIndex}"; + var shotId = NextShotId(zone, attacker, shot); CommitShotResolution(run, zone, attacker, selectedTarget!, shot, shotId, frameId); + AppendShotCommittedEvent(run, zone, attacker, selectedTarget!, shot, shotId, frameId); } } @@ -922,7 +916,11 @@ namespace GameCult.Aetheria.State.Verse LockQuality = lockQuality, RangeFactor = rangeFactor, MotionFactor = motionFactor, DispersionFactor = dispersionFactor, HitProbability = probability, HitRoll = roll, Hit = hit, NominalDamage = weapon.Damage, AppliedDamage = appliedDamage, - Outcome = hit ? "hit" : "miss" + Outcome = hit ? "hit" : "miss", + OriginX = attacker.PositionX, OriginZ = attacker.PositionZ, + EndpointX = target.PositionX, EndpointZ = target.PositionZ, + PresentationDurationSeconds = distance / Math.Max(1, weapon.ProjectileSpeed), + PresentationKind = weapon.ItemKey }); AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit { @@ -951,6 +949,26 @@ namespace GameCult.Aetheria.State.Verse }); } + private static string NextShotId(AetheriaRuntimeZoneSnapshotCommit zone, + AetheriaRuntimeEntitySnapshotCommit attacker, ResolvedWeapon weapon) + { + weapon.State.ShotSequence++; + return $"shot:{zone.ZoneIndex}:{attacker.EntityIndex}:{weapon.State.OwnerIndex}:{weapon.State.BehaviorIndex}:{weapon.State.ShotSequence}"; + } + + private static void AppendShotCommittedEvent(AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeZoneSnapshotCommit zone, AetheriaRuntimeEntitySnapshotCommit attacker, + AetheriaRuntimeEntitySnapshotCommit target, ResolvedWeapon weapon, string shotId, long frameId) + { + AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit + { + EventId = $"shot:{shotId}:committed", Kind = "shot.committed", FrameId = frameId, + ZoneIndex = zone.ZoneIndex, SourceEntityIndex = attacker.EntityIndex, + TargetEntityIndex = target.EntityIndex, SubjectKey = shotId, ItemKey = weapon.ItemKey, + ScalarValue = weapon.Damage, PositionX = attacker.PositionX, PositionZ = attacker.PositionZ + }); + } + private static double ShotRoll(uint seed, string shotId, string salt) { unchecked @@ -1083,57 +1101,6 @@ namespace GameCult.Aetheria.State.Verse return state; } - private static AetheriaRuntimeProjectileCommit SpawnProjectile( - AetheriaRuntimeZoneSnapshotCommit zone, - AetheriaRuntimeEntitySnapshotCommit attacker, - AetheriaRuntimeEntitySnapshotCommit target, - ResolvedWeapon weapon, - AetheriaRuntimeDaemonSimulationSettings settings) - { - var direction = Normalize(target.PositionX - attacker.PositionX, target.PositionZ - attacker.PositionZ); - if (Math.Abs(direction.X) + Math.Abs(direction.Y) <= 0.0001) - direction = Normalize(attacker.DirectionX, attacker.DirectionY); - if (Math.Abs(direction.X) + Math.Abs(direction.Y) <= 0.0001) - direction = (0, 1); - - var projectiles = (zone.Projectiles ?? Array.Empty()) - .Where(projectile => projectile != null && projectile.Active) - .ToList(); - var projectile = new AetheriaRuntimeProjectileCommit - { - ProjectileId = CreateProjectileId(zone, attacker, target, projectiles.Count), - SourceEntityIndex = attacker.EntityIndex, - TargetEntityIndex = target.EntityIndex, - FactionKey = attacker.FactionKey ?? "", - PositionX = attacker.PositionX + direction.X * settings.ProjectileSpawnOffset, - PositionY = attacker.PositionY, - PositionZ = attacker.PositionZ + direction.Y * settings.ProjectileSpawnOffset, - DirectionX = direction.X, - DirectionY = direction.Y, - VelocityX = direction.X * weapon.ProjectileSpeed, - VelocityY = direction.Y * weapon.ProjectileSpeed, - Damage = weapon.Damage, - Radius = settings.ProjectileRadius, - LifetimeSeconds = settings.ProjectileLifetimeSeconds, - Guided = true, - Active = true, - WeaponKind = weapon.ItemKey - }; - projectiles.Add(projectile); - zone.Projectiles = projectiles.ToArray(); - return projectile; - } - - private static string CreateProjectileId( - AetheriaRuntimeZoneSnapshotCommit zone, - AetheriaRuntimeEntitySnapshotCommit attacker, - AetheriaRuntimeEntitySnapshotCommit target, - int ordinal) - { - var tick = Math.Max(0, (long)Math.Round(zone.SimulationTimeSeconds * 1000.0)); - return $"projectile:{zone.ZoneIndex}:{tick}:{attacker.EntityIndex}:{target.EntityIndex}:{ordinal}"; - } - private static double ResolveProjectileDamage( AetheriaRuntimeEntitySnapshotCommit attacker, AetheriaRuntimeDaemonSimulationSettings settings) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs index 952ef9603..cb6d79e0f 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs @@ -474,6 +474,12 @@ namespace GameCult.Aetheria.State.Verse [Key(16)] public double NominalDamage { get; set; } [Key(17)] public double AppliedDamage { get; set; } [Key(18)] public string Outcome { get; set; } = ""; + [Key(19)] public double OriginX { get; set; } + [Key(20)] public double OriginZ { get; set; } + [Key(21)] public double EndpointX { get; set; } + [Key(22)] public double EndpointZ { get; set; } + [Key(23)] public double PresentationDurationSeconds { get; set; } + [Key(24)] public string PresentationKind { get; set; } = ""; } [MessagePackObject] @@ -1148,6 +1154,7 @@ namespace GameCult.Aetheria.State.Verse [Key(20)] public double ChargeHoldSeconds { get; set; } [Key(21)] public int ChargeRiskChecks { get; set; } [Key(22)] public double ChargeMalfunctionRisk { get; set; } + [Key(23)] public long ShotSequence { get; set; } } [MessagePackObject] diff --git a/docs/original-game-migration-matrix.md b/docs/original-game-migration-matrix.md index 9769cc995..84207cba4 100644 --- a/docs/original-game-migration-matrix.md +++ b/docs/original-game-migration-matrix.md @@ -21,7 +21,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Flight intent | `Ship`, `Thruster`, `AetherDrive`, input paths | daemon intent + Ymir physics | analog movement/look/tractor | EveUnity input driver | movement intents feed Ymir-owned body integration; authored thrust allocation, torque, energy and heat remain simplified | prove original drive/equipment behavior ordering and runtime interpolation | | 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; daemon weapon lock now acquires and decays from facing, elapsed time, and observer-local contact confidence instead of granting an immediate perfect lock | target-switch reset, angular decay, visibility/nearest/explicit cases, and runtime lock feedback | -| Projectile flight | weapon/projectile classes | Eve presentation for ordinary tracers; Ymir for persistent physical payloads | derived trajectory/effect facts or persistent payload state | native projectile visual | ordinary instant/charged damage resolves from immutable daemon shot receipts at commitment; Ymir projectile contacts are feedback-only and cannot write damage; temporary projectile rows remain as presentation timing; Ymir.Core remains embedded for world integration, radial fields, circle contacts, pickups, and genuinely persistent/interceptable payloads | delete ordinary `IAetheriaRuntimeProjectilePhysics` after constant weapons and presentation trajectories consume receipts; retain Ymir for world physics and physical payloads | +| 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 | | Shield/hull damage | energy-funded shield, armor cells, equipment and hull | daemon | entity status + damage events | meters, impacts, damage VFX | bounded immutable shot receipts record stable identity, observer information, lock, range, motion, dispersion, probability, roll, outcome, and applied damage; daemon applies current scalar shield-then-hull damage at shot commitment; fake or later Ymir projectile contacts cannot emit damage/destruction | cognition/signature factors, named independent entropy dimensions, miss/impact distribution, typed armor/hull/equipment grids, penetration and damage types | | Thermal/energy | cell conduction and capacitor/reactor/radiator network | daemon | ship/equipment status and warnings | schematic/post effects | cell conduction/radiation wired; energy network and medical thresholds remain reference | capacitor/reactor/radiator ordering, shared energy and medical timelines | | Weapons | ServerShared behaviors + Unity effects | daemon plus Ymir geometry/kinematics | action capability, weapon state, shot/damage receipts | effects/audio/HUD | instant and constant resource/timing lifecycles are daemon-owned; charged weapons accept one semantic request, spool without requiring a solution, hold at full charge, commit automatically when a solution appears, and perform deterministic once-per-second malfunction hazard checks after the authored safe hold interval with increasing persisted risk; generic Eve `weapon.state` exposes charge hold/risk and feedback exposes readiness, commit, refusal, and malfunction chronology | replace projectile-contact damage with `deterministic-combat-resolution.md`, then guided persistent payloads, visibility/wear, penetration, impact distribution, and Unity effect reconciliation |