From 6a6a19d08f46e3a54ec48fab13688642eda5b84a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 15:47:15 +0100 Subject: [PATCH] Persist lock weapon state in typed snapshots --- .voidbot/state/aetheria.cc | Bin 86679 -> 85513 bytes Aetheria.State.Smoke/Program.cs | 17 ++++++++++++++++ Aetheria.State.Unity.Smoke/Program.cs | 19 ++++++++++++++++-- .../AetheriaRuntimeCommitLogApplier.cs | 12 ++++++++--- .../AetheriaRuntimeStateDocuments.cs | 6 ++++++ Assets/Scripts/Gameplay/ActionGameManager.cs | 15 ++++++++++---- .../ServerShared/Behaviors/LockWeapon.cs | 4 ++++ .../Runtime/AetheriaRuntimeCatalogSnapshot.cs | 8 +++++++- .../Runtime/AetheriaRuntimeCatalogStore.cs | 8 ++++++-- .../AetheriaRuntimeStateCommitDocument.cs | 6 ++++++ docs/aetheria-perfect-machine-map.md | 8 ++++++-- 11 files changed, 89 insertions(+), 14 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 9e23691720084b851c7fe634d766c40a494b598c..3a6966779db7b06bbc255b65359183ecab0e0023 100644 GIT binary patch delta 1483 zcmaKs&x;gC6vydZjXw@Kxhe+X<={cs8E1$6AsdCPqsByGlXXSdi_}!VnXYV4Ra;d( z<0OYMcnY~h8ks|aCrw-lB!VL35{P(3h_2e((D}@B7~H z_V(|8-u}lg6T4?;7i)9X+FWhzdN7qep7>#OGUrd!OoxpsKl!^7Kx zqYED$VrV1Of>mP0*DF0_iINp#nZ;r9VNlODPkcORoTIyo{t65lBa{UH2}sq0CdNv( z4Oj)XpI``i5HOM@CQ=r(>Y3_o9y8H-`FbUlz$4`Ai4xKpU`c{9gt6?<5*UYL@djl; zr^-iL1gGdrt=gL80HXlzV3p}M+EdaB+y7jKcm;$6ozi;;fvZkOSO^tQJ4l(Q!D=Q= zOff^J{rv!EvG0E8Oin2&IE#V)qQGTc!>7lBg9A9Zx@@YyT9l5;%gt3!fV0G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-}$#ntZwsqbCV_byNAKkzaA{pM&JnzO$5e0dG#Jh(1l zAQQX;@DnUrdzW&|`^OYal2AKFMizo_ni3X3MLP(Sro6!b92#P*D*fq0bxL9|V&2P= z-o5y&{%w8Y*!@+jdZO~gGD?Y%R6?nI#EOhS^*{}X7^1t;eznfGv(BrR-zenU4f?$>7@MXt-Z zTa34MmM%O=0DCRp`2yYI72x)8NMJ?YTh-57Eo6 z)`HlLLz;k&jCgwd&Y0#OjA-@=>b$k!j8l3*L%l6O_;DGq)FJ)AhRg))T3Cp2CZkC~ zICxz-oRS-`2eTSBp8ZU3{x?24v)KLM&*?vh zpXz?>XQ$1_zEfIue(i? states) + IReadOnlyList? states, + string runId, + int zoneIndex) { return (states ?? Array.Empty()) .Select(state => new AetheriaWeaponStateSnapshot @@ -513,7 +515,11 @@ public static class AetheriaRuntimeCommitLogApplier Charge = state.Charge, Reloading = state.Reloading, ReloadProgress = state.ReloadProgress, - AmmoIntervalProgress = state.AmmoIntervalProgress + AmmoIntervalProgress = state.AmmoIntervalProgress, + LockProgress = state.LockProgress, + LockTargetEntityKey = state.LockTargetEntityIndex >= 0 + ? EntityKey(runId, zoneIndex, state.LockTargetEntityIndex).ToString() + : "" }) .ToArray(); } diff --git a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs index ffc55f8b6..5627cc911 100644 --- a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs +++ b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs @@ -636,6 +636,12 @@ public sealed class AetheriaWeaponStateSnapshot [Key(16)] public double AmmoIntervalProgress { get; set; } + + [Key(17)] + public double LockProgress { get; set; } + + [Key(18)] + public string LockTargetEntityKey { get; set; } = ""; } [MessagePackObject] diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 4e7593fc1..1ca57ff5c 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -795,7 +795,7 @@ public class ActionGameManager : MonoBehaviour StatGrids = ProjectEntityStatGrids(entity), ActiveConsumables = ProjectActiveConsumables(entity), BehaviorProgress = ProjectBehaviorProgress(entity), - WeaponStates = ProjectWeaponStates(entity), + WeaponStates = ProjectWeaponStates(zone, entity), BehaviorStates = ProjectBehaviorStates(entity) }; } @@ -896,21 +896,22 @@ public class ActionGameManager : MonoBehaviour } } - private static AetheriaRuntimeWeaponStateCommit[] ProjectWeaponStates(Entity entity) + private static AetheriaRuntimeWeaponStateCommit[] ProjectWeaponStates(Zone zone, Entity entity) { var states = new List(); for (var ownerIndex = 0; ownerIndex < entity.Equipment.Count; ownerIndex++) - states.AddRange(ProjectWeaponStates("equipment", ownerIndex, entity.Equipment[ownerIndex].Behaviors)); + states.AddRange(ProjectWeaponStates(zone, "equipment", ownerIndex, entity.Equipment[ownerIndex].Behaviors)); var activeConsumables = entity.ActiveConsumables; for (var ownerIndex = 0; ownerIndex < activeConsumables.Count; ownerIndex++) - states.AddRange(ProjectWeaponStates("active_consumable", ownerIndex, activeConsumables[ownerIndex].Behaviors)); + states.AddRange(ProjectWeaponStates(zone, "active_consumable", ownerIndex, activeConsumables[ownerIndex].Behaviors)); return states.ToArray(); } private static IEnumerable ProjectWeaponStates( + Zone zone, string ownerKind, int ownerIndex, IReadOnlyList behaviors) @@ -956,6 +957,12 @@ public class ActionGameManager : MonoBehaviour state.AmmoIntervalProgress = constant.AmmoIntervalProgress; } + if (weapon is LockWeapon lockWeapon) + { + state.LockProgress = lockWeapon.LockProgress; + state.LockTargetEntityIndex = lockWeapon.LockTarget == null ? -1 : zone.Entities.IndexOf(lockWeapon.LockTarget); + } + yield return state; } } diff --git a/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs index a9c2b3a04..77fa0fdb8 100644 --- a/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs @@ -58,6 +58,10 @@ public class LockWeapon : InstantWeapon get => saturate(_lock); } + public float LockProgress => saturate(_lock); + + public Entity LockTarget => _target; + public LockWeapon(LockWeaponData data, EquippedItem item) : base(data, item) { _data = data; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index cdb8439d0..cfcbcccd5 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -1019,7 +1019,9 @@ namespace GameCult.Aetheria.State.Unity double charge, bool reloading, double reloadProgress, - double ammoIntervalProgress) + double ammoIntervalProgress, + double lockProgress, + string lockTargetEntityKey) { OwnerKind = ownerKind; OwnerIndex = ownerIndex; @@ -1038,6 +1040,8 @@ namespace GameCult.Aetheria.State.Unity Reloading = reloading; ReloadProgress = reloadProgress; AmmoIntervalProgress = ammoIntervalProgress; + LockProgress = lockProgress; + LockTargetEntityKey = lockTargetEntityKey; } public string OwnerKind { get; } @@ -1057,6 +1061,8 @@ namespace GameCult.Aetheria.State.Unity public bool Reloading { get; } public double ReloadProgress { get; } public double AmmoIntervalProgress { get; } + public double LockProgress { get; } + public string LockTargetEntityKey { get; } } public sealed class AetheriaRuntimeBehaviorStateSnapshot diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs index 76da4267b..dd9934efe 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs @@ -821,7 +821,9 @@ namespace GameCult.Aetheria.State.Unity var reloading = ReadFieldBool(ref reader, weaponFields, 14); var reloadProgress = ReadFieldDouble(ref reader, weaponFields, 15); var ammoIntervalProgress = ReadFieldDouble(ref reader, weaponFields, 16); - SkipRemaining(ref reader, weaponFields, 17); + var lockProgress = ReadFieldDouble(ref reader, weaponFields, 17); + var lockTargetEntityKey = ReadFieldString(ref reader, weaponFields, 18); + SkipRemaining(ref reader, weaponFields, 19); weaponStates[weapon] = new AetheriaRuntimeWeaponStateSnapshot( ownerKind, ownerIndex, @@ -839,7 +841,9 @@ namespace GameCult.Aetheria.State.Unity charge, reloading, reloadProgress, - ammoIntervalProgress); + ammoIntervalProgress, + lockProgress, + lockTargetEntityKey); } return weaponStates; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs index 6eb706a2c..15064495a 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs @@ -685,6 +685,12 @@ namespace GameCult.Aetheria.State.Unity [Key(16)] public double AmmoIntervalProgress { get; set; } + + [Key(17)] + public double LockProgress { get; set; } + + [Key(18)] + public int LockTargetEntityIndex { get; set; } = -1; } [MessagePackObject] diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 70751b7f6..658c1c9c6 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -164,8 +164,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. `IProgressBehavior` now publish typed progress rows keyed by owner kind, owner index, behavior index, behavior kind, and progress value. Weapon behaviors now also publish typed runtime rows for firing state, ammo, - burst timing, cooldown progress, charged-weapon charging/charge state, and - constant-weapon reload/ammo-interval state. + burst timing, cooldown progress, charged-weapon charging/charge state, + constant-weapon reload/ammo-interval state, and lock-weapon lock progress + plus target entity reference. Sensor, radiator, reactor, and capacitor behaviors publish typed state rows for ping state, radiator temperature/throughput, reactor draw/load, and capacitor charge/capacity/efficiency. @@ -794,6 +795,9 @@ First Aetheria surfaces to publish: - Done: extend run checkpoint commits and smoke coverage to carry typed weapon behavior state rows for instant, charged, and constant weapon runtime internals. + - Done: extend weapon behavior state rows for lock-weapon progress and + target entity references, so lock acquisition state no longer evaporates + at the commit boundary. - Done: extend run checkpoint commits and smoke coverage to carry typed behavior state rows for sensor ping state plus radiator, reactor, and capacitor runtime internals.