diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index 193f1e9a6..021b6569c 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -772,6 +772,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks YmirMovesProjectileAndReportsStableContact, CompressedTerminusStopsAtAttentionBoundary, InstantWeaponRequestSurvivesLockAcquisition, + AutoWeaponRetriggersWhileHeldAndStopsOnRelease, GuidedWeaponPublishesPresentationProfileWithoutPhysicalAuthority, CombatLockSurvivesPublicFrameRestart, ConstantWeaponRunsOnDaemonThroughYmirBeamContact, @@ -3716,6 +3717,163 @@ internal sealed class AetheriaDaemonYmirSmokeChecks "Eve feedback must project the daemon lock-loss transition and its prior completed progress"); } + private static void AutoWeaponRetriggersWhileHeldAndStopsOnRelease() + { + var root = Path.Combine(Path.GetTempPath(), "aetheria-auto-weapon-" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + var statePath = Path.Combine(root, "world.cc"); + try + { + var source = Entity(0, 0, "player"); + source.DirectionX = 1; + source.TargetEntityIndex = 1; + source.Contacts = [new AetheriaRuntimeEntityContactCommit + { + TargetEntityIndex = 1, InfoGathered = 1, Hostile = true, Visible = true + }]; + source.WeaponGroups = [new[] { 0 }]; + source.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit + { ItemKey = "test-auto", Quality = 1, Durability = 1, Enabled = true } + }]; + var target = Entity(1, 50, "raider"); + var run = new AetheriaRuntimeRunCheckpointCommit + { + RunId = "auto-weapon-smoke", + CurrentZoneIndex = 0, + Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [source, target] }] + }; + run.CurrentEntityKey = run.EntityRecordKey(0, source.EntityIndex); + var payload = new AetheriaRuntimeBehaviorPayload(0, AetheriaRuntimeBehaviorKinds.AutoWeapon, 0, + [ + new AetheriaRuntimeBehaviorField(2, PerformanceStat(10)), + new AetheriaRuntimeBehaviorField(6, PerformanceStat(100)), + new AetheriaRuntimeBehaviorField(15, PerformanceStat(0)), + new AetheriaRuntimeBehaviorField(16, PerformanceStat(100)), + new AetheriaRuntimeBehaviorField(17, PerformanceStat(1)), + new AetheriaRuntimeBehaviorField(18, PerformanceStat(0)), + new AetheriaRuntimeBehaviorField(19, PerformanceStat(0.2)), + new AetheriaRuntimeBehaviorField(21, PerformanceStat(100)), + new AetheriaRuntimeBehaviorField(23, PerformanceStat(180)), + new AetheriaRuntimeBehaviorField(24, PerformanceStat(0)), + new AetheriaRuntimeBehaviorField(25, PerformanceStat(0)) + ]); + var catalog = new AetheriaRuntimeCatalogSnapshot( + [WearableWeaponCatalogItem("test-auto", payload)], [], []); + var press = AetheriaRuntimeDaemonCommandDocument.Create( + AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive, + "pilot", run.RunId, 0, run.CurrentEntityKey); + press.CommandId = "auto-weapon-press"; + press.WeaponGroup = 0; + press.ScalarValue = 1; + var pressed = AetheriaRuntimeDaemonOperations.Execute( + run, [press], new AetheriaRuntimeDaemonOperationContext()); + + AetheriaRuntimeDaemonSimulation.Step(run, pressed.Intents, 0.1, + AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, + NewPhysics(), catalog, 0, 0); + RequireEqual(1, run.ShotReceipts.Count, + "pressing an AutoWeapon group must commit its first burst exactly once"); + var state = source.WeaponStates.Single(value => + value.BehaviorKind == AetheriaRuntimeBehaviorKinds.AutoWeapon); + Require(state.CoolingDown && source.ActiveWeaponGroups.Single(), + "AutoWeapon cooldown and the held group latch must be durable daemon state"); + + using (var node = AetheriaStateNode.OpenAsync(statePath).GetAwaiter().GetResult()) + { + node.MutableDocument( + AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest) + .ReplaceAsync(AetheriaRuntimeDaemonFrameDocument.Create( + run, "smoke", "auto-weapon", 0, 0, 0.1)) + .GetAwaiter().GetResult(); + node.FlushAsync(soft: false).GetAwaiter().GetResult(); + } + + AetheriaRuntimeRunCheckpointCommit restoredRun; + using (var node = AetheriaStateNode.OpenAsync(statePath).GetAwaiter().GetResult()) + { + restoredRun = node.MutableDocument( + AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest) + .ReadAsync().GetAwaiter().GetResult()?.Run + ?? throw new InvalidOperationException("Durable AutoWeapon frame is missing."); + } + var restoredSource = restoredRun.Zones.Single().Entities.Single(value => value.EntityIndex == 0); + for (var frame = 1; frame <= 3; frame++) + AetheriaRuntimeDaemonSimulation.Step(restoredRun, new AetheriaRuntimeDaemonIntentState(), 0.1, + AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, + NewPhysics(), catalog, frame, frame * 0.1); + RequireEqual(2, restoredRun.ShotReceipts.Count, + "a held AutoWeapon must retrigger on the fixed step after its cooldown completes, including after restart"); + + var release = AetheriaRuntimeDaemonCommandDocument.Create( + AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive, + "pilot", restoredRun.RunId, 4, restoredRun.CurrentEntityKey); + release.CommandId = "auto-weapon-release"; + release.WeaponGroup = 0; + release.ScalarValue = 0; + var released = AetheriaRuntimeDaemonOperations.Execute( + restoredRun, [release], new AetheriaRuntimeDaemonOperationContext()); + for (var frame = 4; frame < 10; frame++) + AetheriaRuntimeDaemonSimulation.Step(restoredRun, + frame == 4 ? released.Intents : new AetheriaRuntimeDaemonIntentState(), 0.1, + AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, + NewPhysics(), catalog, frame, frame * 0.1); + RequireEqual(2, restoredRun.ShotReceipts.Count, + "releasing an AutoWeapon group must prevent every later automatic burst"); + Require(!restoredSource.ActiveWeaponGroups.Single() && + !restoredSource.WeaponStates.Single(value => + value.BehaviorKind == AetheriaRuntimeBehaviorKinds.AutoWeapon).TriggerPending, + "release must clear the only daemon input that authorizes AutoWeapon retriggering"); + + var ordinaryPayload = new AetheriaRuntimeBehaviorPayload( + payload.UnionKey, + AetheriaRuntimeBehaviorKinds.InstantWeapon, + payload.Group, + payload.Fields); + var ordinary = Entity(0, 0, "player"); + ordinary.DirectionX = 1; + ordinary.TargetEntityIndex = 1; + ordinary.Contacts = source.Contacts; + ordinary.WeaponGroups = [new[] { 0 }]; + ordinary.ActiveWeaponGroups = [true]; + ordinary.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit + { ItemKey = "test-instant-held", Quality = 1, Durability = 1, Enabled = true } + }]; + var ordinaryTarget = Entity(1, 50, "raider"); + var ordinaryRun = new AetheriaRuntimeRunCheckpointCommit + { + RunId = "ordinary-held-smoke", CurrentZoneIndex = 0, + CurrentEntityKey = "zone.0.entity.0", + Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [ordinary, ordinaryTarget] }] + }; + var ordinaryCatalog = new AetheriaRuntimeCatalogSnapshot( + [WearableWeaponCatalogItem("test-instant-held", ordinaryPayload)], [], []); + var pulse = new AetheriaRuntimeDaemonIntentState(); + pulse.WeaponGroups.Add(new AetheriaRuntimeDaemonWeaponGroupIntent + { + ActorEntityKey = ordinaryRun.CurrentEntityKey, + WeaponGroup = 0, + Fire = true, + Active = true + }); + for (var frame = 0; frame < 10; frame++) + AetheriaRuntimeDaemonSimulation.Step(ordinaryRun, + frame == 0 ? pulse : new AetheriaRuntimeDaemonIntentState(), 0.1, + AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, + NewPhysics(), ordinaryCatalog, frame, frame * 0.1); + RequireEqual(1, ordinaryRun.ShotReceipts.Count, + "an ordinary InstantWeapon must remain press-edge driven even while its group latch is held"); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + private static void GuidedWeaponPublishesPresentationProfileWithoutPhysicalAuthority() { var source = Entity(0, 0, "player"); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs index 8e132980d..0f4bcb807 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs @@ -520,8 +520,17 @@ namespace GameCult.Aetheria.State.Verse var weapons = ResolveWeapons(attacker, catalog, settings); foreach (var weapon in weapons) { + var autoTriggerReady = + string.Equals(weapon.State.BehaviorKind, AetheriaRuntimeBehaviorKinds.AutoWeapon, + StringComparison.Ordinal) && + requestedWeapons.Contains(weapon.State.OwnerIndex, weapon.State.BehaviorIndex) && + weapon.State.BurstRemaining <= 0 && + !weapon.State.CoolingDown && + !weapon.State.Reloading && + weapon.State.CooldownProgress <= 0; weapon.State.Firing = false; - if (requestedWeapons.ContainsPulse(weapon.State.OwnerIndex, weapon.State.BehaviorIndex)) + if (requestedWeapons.ContainsPulse(weapon.State.OwnerIndex, weapon.State.BehaviorIndex) || + autoTriggerReady) weapon.State.TriggerPending = true; if (weapon.State.Reloading) { diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 2978b601f..150b38c1e 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -110,8 +110,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. catalog rows. Weapon groups publish the fossil press/release lifecycle as generic `button-hold.v1` values routed to the daemon-owned `SetWeaponGroupActive` command. The entity snapshot owns the reconnectable - active-group latch: a press edge pulses instant/charged weapons once while - constant weapons remain selected until the release command clears the latch. + active-group latch: a press edge pulses ordinary instant/charged weapons once, + authored `AutoWeapon` payloads retrigger on the fixed step after their cooldown + completes while the latch remains held, and constant weapons remain selected + until the release command clears the latch. AutoWeapon retriggering consumes + the same lock, ammo, energy, heat, wear, visibility, shot, and damage path as + its first press; it is not a second combat authority. Generic clients send transitions, not frame-frequency keepalive commands. `FireWeaponGroup` remains a one-shot compatibility operation for autonomous agents and command buttons but is not the public binding contract. The provider diff --git a/docs/original-game-migration-matrix.md b/docs/original-game-migration-matrix.md index fa5442354..51cff10b0 100644 --- a/docs/original-game-migration-matrix.md +++ b/docs/original-game-migration-matrix.md @@ -24,7 +24,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or 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, constant, GuidedWeapon, and Launcher 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. Guided receipts additionally retain target-entity/look-direction mode, complete guidance/thrust/lift curves, evaluated thrust and top speed, and dodge frequency; these survive checkpoint restart and reach generic Eve shot facts. The fossil guided projectile only steered, split, faded, and selected hit visuals after the ordinary weapon event had committed damage, so the client path remains derived presentation rather than a Ymir gameplay body. `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 | generic guided trajectory lowering, provider split/fade asset parameters, and removal of ordinary projectile terminology from runtime contracts | | Shield/armor/equipment/hull damage | energy-funded shield, schematic armor cells, equipment and scalar hull | daemon canonical damage transaction | aggregate/exact armor grid, entity status, and layer-aware shot/damage receipts | schematic, meters, impacts, damage VFX | owner-exists; wired; exclusive; projected: daemon initializes armor/maximum-armor grids from hull plus hardpoint catalog topology; direct and deployable damage share one `shield -> armor cell -> equipment -> scalar hull` transaction; direct impacts use the fossil's full-width/full-height normalized-UV scaling to select a cell or complete hardpoint footprint before orthogonal spread and contiguous 0.5-cell penetration that stops at the first hull gap, while splash payloads select the source-facing hull half; rotated equipment interception shares the refit/thermal/schematic footprint owner; the fossil penetration infinite-loop defect is fixed; damage type is typed/pass-through without resistances because the fossil never applied them; Eve exposes aggregate and exact armor state, and each direct-shot receipt owns stable per-cell coordinates plus armor/equipment/hull application for presentation; fake Ymir contacts and presentation cannot decide damage | authoritative authored collider-UV topology input, orthogonal-spread/depth fixtures, and generic shield/equipment effect lifecycle | | Thermal/energy | cell conduction, capacitor/reactor/radiator network, and cockpit thermal exposure | daemon | ship/equipment power, temperature, medical state, risk and death feedback | schematic/post effects | owner-exists; wired; exclusive; projected; generic timing and native asset delivery lowered: catalog hull and installed-item shapes derive cell mass/conductivity/topology; local temperature derives thermal performance, wear potential and online state; all consumers share capacitor-first/reactor-residual transactions; powered radiators pump before reactor settlement; reactor heat then enters the same cell network before conduction/radiation; cockpit-cell temperature drives the fossil nonlinear heatstroke/hypothermia accumulation, linear recovery, severe-risk crossings, and ordinary exactly-once destruction with a typed cause; Eve exposes cockpit, risk, heatstroke source-weight, phasing and death-transition facts; EveUnity generically resolves the original severe pulse plus live/reconnect-safe cause-specific death crossfade; Aetheria deterministically translates the five legacy profiles into URP profiles, persists every override as a real profile sub-asset, advertises them by semantic role through CultMesh CDN, and binds them in the canonical client through a weight-only native sink; rotated equipment topology, parent/child radiation, schematic composition, legacy SSR/AO/roundness equivalents, and live/reconnect death-fade parity remain incomplete | multi-consumer ordering, multi-radiator visibility, rotated topology, generic schematic meters, renderer-feature parity, and live/reconnect death-fade screenshots | -| 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; successful instant, constant, charged, deployable, and turret-controlled transactions publish authored transient visibility and consume the owning equipment's temperature-derived wear, with charged visibility applying its authored multiplier and turret wear remaining exact-weapon scoped; GuidedWeapon and Launcher retain ordinary authoritative shot resolution while publishing their complete fossil steering profile as derived presentation; generic Eve `weapon.state` exposes charge hold/risk and feedback exposes readiness, commit, refusal, and malfunction chronology; committed direct damage now enters the shared daemon armor-cell transaction | remaining impact-distribution parity, generic guided/effect lowering, and Unity effect reconciliation | +| 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; ordinary instant weapons remain press-edge driven, while authored `AutoWeapon` payloads use the persisted generic hold latch to retrigger on the fixed step after cooldown completion and stop structurally on release, including across CultCache restart. 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; successful instant, automatic, constant, charged, deployable, and turret-controlled transactions publish authored transient visibility and consume the owning equipment's temperature-derived wear, with charged visibility applying its authored multiplier and turret wear remaining exact-weapon scoped; GuidedWeapon and Launcher retain ordinary authoritative shot resolution while publishing their complete fossil steering profile as derived presentation; generic Eve `weapon.state` exposes charge hold/risk and feedback exposes readiness, commit, refusal, and malfunction chronology; committed direct damage now enters the shared daemon armor-cell transaction | remaining impact-distribution parity, generic guided/effect lowering, and Unity effect reconciliation | | Destruction/drops | hull death, 25% equipment rolls, unconditional cargo drops, 25-unit launch, 30-second pickups | daemon | destruction identity, death/drop events, typed pickups | provider-advertised destruction effect and pickups | owner-exists; wired; exclusive; projected: direct and deployable lethal damage commit one deterministic destruction transaction, clear live references, retain only a non-rendered identity tombstone, and emit exact pickups/events; residual cell damage destroys installed equipment before hull, disables its behaviors immediately, and cockpit destruction kills with its fossil cause before scalar hull depletion; the reserved client `DestroyEntity` command is rejected; Aetheria advertises its original big explosion as `effect.feedback.entity.destroyed`, lowered generically by EveUnity | multiplayer reconnect chronology | | Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, pickup body and receipt | pickup world entity plus beam/interaction feedback | fossil 2/s power ramp and authored forward radius/traction/distance feed pickup bodies into the shared Ymir world; ship contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; Aetheria maps pickup collision only against ship bodies, so stations and other world bodies cannot become cargo writers; 30s daemon lifetime; instant cargo teleport deleted; current-zone pickups occupy ordinary rows in the shared Eve entity SoA body with stable logical identity and provider-owned assets; `pilot.scoop` advertises a generic `button-hold.v1` scalar contract, the released client sends `1` on press and `0` on release through `SetTractorPower`, both receipts reconcile, and daemon power returns exactly to zero; the provider build removes the fossil's embedded tractor object from ship prefabs, and `beam.presentation` attaches the sole standalone effect to the SoA ship; released warm witnesses prove successful exactly-once Ymir collection and controlled-player `cargo-capacity` rejection with unchanged cargo | polish provider beam shape/attachment | | Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon docking now preserves the fossil transaction: stable zone order selects the first entity with a real empty bay inside the fixed 25-unit XZ center radius; undock checks installed Cockpit, Thruster-or-AetherDrive, Reactor, then empty bay cargo in source order; rejection reasons survive committed command facts into generic Eve receipts; success removes parentage without moving, stopping, or rotating the ship. Accepted transitions additionally publish retained `ship.docked` / `ship.undocked` feedback with exact actor, parent, bay, frame and position; rejected operations publish no false transition. Docking clears held-group and transient weapon state, docked actors reject later fire commands, and combat subtracts docked child identities from both attacker iteration and target lookup, so stale input, forged pulses, and turret controllers cannot fire through a bay. Ymir world entities retain gravity/query bodies but do not invent ship/station rigidbody collision response that would make the 25-unit rule unreachable; ship/pickup Begin contacts remain enabled. The live generic Unity witness also proves advertised actions, bay assignment, dock-parent SoA inclusion and sensor sharing, camera retargeting, controlled-subject hiding, movement suppression, and restoration on undock | reconnect, docked inventory/trade surfaces, and authored dock-camera blend/effect lowering |