diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 9e2369172..3a6966779 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State.Smoke/Program.cs b/Aetheria.State.Smoke/Program.cs index 70f665cfe..261cf273a 100644 --- a/Aetheria.State.Smoke/Program.cs +++ b/Aetheria.State.Smoke/Program.cs @@ -238,6 +238,19 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s EquipmentIndices = [0] } ], + WeaponStates = + [ + new AetheriaWeaponStateSnapshot + { + OwnerKind = "equipment", + OwnerIndex = 0, + BehaviorIndex = 1, + BehaviorKind = "LockWeapon", + Ammo = 1, + LockProgress = 0.65, + LockTargetEntityKey = entityKey.ToString() + } + ], StatGrids = [ new AetheriaEntityStatGrid @@ -495,6 +508,10 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether entitySnapshot.DockingBayAssignments.Length != 1 || entitySnapshot.DockingBayAssignments[0] != -1 || entitySnapshot.WeaponGroups.Length != 1 || + entitySnapshot.WeaponStates.Length != 1 || + entitySnapshot.WeaponStates[0].BehaviorKind != "LockWeapon" || + entitySnapshot.WeaponStates[0].LockProgress != 0.65 || + entitySnapshot.WeaponStates[0].LockTargetEntityKey != entityKey.ToString() || entitySnapshot.StatGrids.Length != 1 || entitySnapshot.StatGrids[0].Values.Length != 4) { diff --git a/Aetheria.State.Unity.Smoke/Program.cs b/Aetheria.State.Unity.Smoke/Program.cs index 134401f27..5f67eb775 100644 --- a/Aetheria.State.Unity.Smoke/Program.cs +++ b/Aetheria.State.Unity.Smoke/Program.cs @@ -425,6 +425,16 @@ try Reloading = true, ReloadProgress = 0.4, AmmoIntervalProgress = 0.6 + }, + new AetheriaRuntimeWeaponStateCommit + { + OwnerKind = "equipment", + OwnerIndex = 2, + BehaviorIndex = 1, + BehaviorKind = "LockWeapon", + Ammo = 1, + LockProgress = 0.65, + LockTargetEntityIndex = 0 } }, BehaviorStates = new[] @@ -574,7 +584,7 @@ try entity.BehaviorProgress[0].Progress == 0.5 && entity.BehaviorProgress[1].OwnerKind == "active_consumable" && entity.BehaviorProgress[1].Progress == 0.75 && - entity.WeaponStates.Length == 3 && + entity.WeaponStates.Length == 4 && entity.WeaponStates[0].BehaviorKind == "InstantWeapon" && entity.WeaponStates[0].Firing && entity.WeaponStates[0].Ammo == 2 && @@ -588,6 +598,9 @@ try entity.WeaponStates[2].BehaviorKind == "ConstantWeapon" && entity.WeaponStates[2].Reloading && entity.WeaponStates[2].AmmoIntervalProgress == 0.6 && + entity.WeaponStates[3].BehaviorKind == "LockWeapon" && + entity.WeaponStates[3].LockProgress == 0.65 && + entity.WeaponStates[3].LockTargetEntityKey == "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" && entity.BehaviorStates.Length == 4 && entity.BehaviorStates[0].BehaviorKind == "Sensor" && entity.BehaviorStates[0].Pinging && @@ -651,8 +664,10 @@ try packageEntities[0].DockingBayAssignments[0] != -1 || packageEntities[0].ActiveConsumables[0].ItemKey != "aetheria.item_definition:legacy:smoke:consumable" || packageEntities[0].BehaviorProgress.Count != 2 || - packageEntities[0].WeaponStates.Count != 3 || + packageEntities[0].WeaponStates.Count != 4 || packageEntities[0].WeaponStates[2].AmmoIntervalProgress != 0.6 || + packageEntities[0].WeaponStates[3].LockProgress != 0.65 || + packageEntities[0].WeaponStates[3].LockTargetEntityKey != "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" || packageEntities[0].BehaviorStates.Count != 4 || packageEntities[0].BehaviorStates[3].CapacitorCharge != 7.5 || packageEntities[0].StatGrids.Count != 2 || diff --git a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs index f059fa2f5..8979557ae 100644 --- a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs +++ b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs @@ -454,7 +454,7 @@ public static class AetheriaRuntimeCommitLogApplier StatGrids = ToEntityStatGrids(entity.StatGrids), ActiveConsumables = ToActiveConsumables(entity.ActiveConsumables), BehaviorProgress = ToBehaviorProgress(entity.BehaviorProgress), - WeaponStates = ToWeaponStates(entity.WeaponStates), + WeaponStates = ToWeaponStates(entity.WeaponStates, runId, zoneIndex), BehaviorStates = ToBehaviorStates(entity.BehaviorStates), CargoContents = ToCargoBays(entity.CargoContents), DockingBayContents = ToCargoBays(entity.DockingBayContents), @@ -492,7 +492,9 @@ public static class AetheriaRuntimeCommitLogApplier } private static AetheriaWeaponStateSnapshot[] ToWeaponStates( - IReadOnlyList? 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.