Persist entity session state in checkpoints

This commit is contained in:
Meta Vens 2026-06-14 13:58:46 +01:00
commit 6bcf6444b9
8 changed files with 191 additions and 8 deletions

Binary file not shown.

View file

@ -312,6 +312,15 @@ try
PositionZ = 3.0,
DirectionX = 0.0,
DirectionY = 1.0,
VelocityX = 4.0,
VelocityY = -2.0,
TargetEntityIndex = 0,
IsActive = true,
HeatsinksEnabled = false,
OverrideShutdown = true,
TractorPower = 12.5,
Heatstroke = 0.25,
Hypothermia = 0.125,
HullItemDefinitionLegacyId = "smoke:hull",
Equipment = new[]
{
@ -328,6 +337,16 @@ try
}
},
WeaponGroups = new[] { new[] { 0 } },
ActiveConsumables = new[]
{
new AetheriaRuntimeActiveConsumableCommit
{
ItemDefinitionLegacyId = "smoke:consumable",
Quality = 0.75,
RemainingDuration = 3.0,
Duration = 5.0
}
},
StatGrids = new[]
{
new AetheriaRuntimeEntityStatGridCommit
@ -403,6 +422,18 @@ try
zone.Bodies[0].Resources[0].ItemKey == "aetheria.item_definition:legacy:smoke:ore" &&
zone.Bodies[0].Asteroids.Length == 1 &&
entity?.Equipment.Length == 1 &&
entity.Velocity.X == 4.0 &&
entity.Velocity.Y == -2.0 &&
entity.TargetEntityKey == "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" &&
entity.IsActive &&
!entity.HeatsinksEnabled &&
entity.OverrideShutdown &&
entity.TractorPower == 12.5 &&
entity.Heatstroke == 0.25 &&
entity.Hypothermia == 0.125 &&
entity.ActiveConsumables.Length == 1 &&
entity.ActiveConsumables[0].ItemKey == "aetheria.item_definition:legacy:smoke:consumable" &&
entity.ActiveConsumables[0].RemainingDuration == 3.0 &&
entity.WeaponGroups.Length == 1 &&
entity.StatGrids.Length == 2 &&
entity.StatGrids.Any(grid => grid.Name == "temperature" && grid.Values.Length == 2 && grid.Values[1] == 281.0) &&

View file

@ -414,6 +414,20 @@ public static class AetheriaRuntimeCommitLogApplier
X = entity.DirectionX,
Y = entity.DirectionY
},
Velocity = new AetheriaVector2
{
X = entity.VelocityX,
Y = entity.VelocityY
},
TargetEntityKey = entity.TargetEntityIndex >= 0
? EntityKey(runId, zoneIndex, entity.TargetEntityIndex).ToString()
: "",
IsActive = entity.IsActive,
HeatsinksEnabled = entity.HeatsinksEnabled,
OverrideShutdown = entity.OverrideShutdown,
TractorPower = entity.TractorPower,
Heatstroke = entity.Heatstroke,
Hypothermia = entity.Hypothermia,
FactionKey = ReferenceKey("aetheria.corporation", entity.CorporationLegacyId ?? ""),
HullItemKey = ReferenceKey("aetheria.item_definition", entity.HullItemDefinitionLegacyId ?? ""),
Equipment = ToEntityItemSlots(entity.Equipment),
@ -425,10 +439,25 @@ public static class AetheriaRuntimeCommitLogApplier
WeaponGroups = ToIntArrayArray(entity.WeaponGroups)
.Select(group => new AetheriaWeaponGroupSnapshot { EquipmentIndices = group })
.ToArray(),
StatGrids = ToEntityStatGrids(entity.StatGrids)
StatGrids = ToEntityStatGrids(entity.StatGrids),
ActiveConsumables = ToActiveConsumables(entity.ActiveConsumables)
};
}
private static AetheriaActiveConsumableSnapshot[] ToActiveConsumables(
IReadOnlyList<AetheriaRuntimeActiveConsumableCommit>? consumables)
{
return (consumables ?? Array.Empty<AetheriaRuntimeActiveConsumableCommit>())
.Select(consumable => new AetheriaActiveConsumableSnapshot
{
ItemKey = ReferenceKey("aetheria.item_definition", consumable.ItemDefinitionLegacyId ?? ""),
Quality = consumable.Quality,
RemainingDuration = consumable.RemainingDuration,
Duration = consumable.Duration
})
.ToArray();
}
private static AetheriaEntityStatGrid[] ToEntityStatGrids(
IReadOnlyList<AetheriaRuntimeEntityStatGridCommit>? grids)
{

View file

@ -454,6 +454,34 @@ public sealed class AetheriaEntitySnapshot
[Key(11)]
public AetheriaEntityStatGrid[] StatGrids { get; set; } = [];
[Key(12)]
public AetheriaVector2 Velocity { get; set; } = new();
[Key(13)]
[CultReference(typeof(AetheriaEntitySnapshot))]
public string TargetEntityKey { get; set; } = "";
[Key(14)]
public bool IsActive { get; set; }
[Key(15)]
public bool HeatsinksEnabled { get; set; }
[Key(16)]
public bool OverrideShutdown { get; set; }
[Key(17)]
public double TractorPower { get; set; }
[Key(18)]
public double Heatstroke { get; set; }
[Key(19)]
public double Hypothermia { get; set; }
[Key(20)]
public AetheriaActiveConsumableSnapshot[] ActiveConsumables { get; set; } = [];
}
[MessagePackObject]
@ -489,6 +517,23 @@ public sealed class AetheriaEntityStatGrid
public double[] Values { get; set; } = [];
}
[MessagePackObject]
public sealed class AetheriaActiveConsumableSnapshot
{
[Key(0)]
[CultReference(typeof(AetheriaItemDefinition))]
public string ItemKey { get; set; } = "";
[Key(1)]
public double Quality { get; set; } = 1.0;
[Key(2)]
public double RemainingDuration { get; set; }
[Key(3)]
public double Duration { get; set; }
}
[MessagePackObject]
public sealed class AetheriaActionBarBinding
{

View file

@ -765,6 +765,15 @@ public class ActionGameManager : MonoBehaviour
PositionZ = entity.Position.z,
DirectionX = entity.Direction.x,
DirectionY = entity.Direction.y,
VelocityX = entity.Velocity.x,
VelocityY = entity.Velocity.y,
TargetEntityIndex = entity.Target?.Value == null ? -1 : zone.Entities.IndexOf(entity.Target.Value),
IsActive = entity.Active,
HeatsinksEnabled = entity.HeatsinksEnabled,
OverrideShutdown = entity.OverrideShutdown,
TractorPower = entity.TractorPower,
Heatstroke = entity.Heatstroke,
Hypothermia = entity.Hypothermia,
CorporationLegacyId = entity.Faction?.ID.ToString("D") ?? "",
HullItemDefinitionLegacyId = entity.Hull?.ItemId == Guid.Empty ? "" : entity.Hull.ItemId.ToString("D"),
Equipment = ProjectEquippedSlots(entity.Equipment),
@ -777,10 +786,24 @@ public class ActionGameManager : MonoBehaviour
WeaponGroups = entity.WeaponGroups?
.Select(group => (IReadOnlyList<int>)group.items.Select(item => entity.Equipment.IndexOf(item)).Where(index => index >= 0).ToArray())
.ToArray() ?? Array.Empty<IReadOnlyList<int>>(),
StatGrids = ProjectEntityStatGrids(entity)
StatGrids = ProjectEntityStatGrids(entity),
ActiveConsumables = ProjectActiveConsumables(entity)
};
}
private static AetheriaRuntimeActiveConsumableCommit[] ProjectActiveConsumables(Entity entity)
{
return entity.ActiveConsumables?
.Select(effect => new AetheriaRuntimeActiveConsumableCommit
{
ItemDefinitionLegacyId = effect.Item?.ItemId == Guid.Empty ? "" : effect.Item.ItemId.ToString("D"),
Quality = effect.Item?.Quality ?? 1.0,
RemainingDuration = effect.RemainingDuration,
Duration = effect.Duration
})
.ToArray() ?? Array.Empty<AetheriaRuntimeActiveConsumableCommit>();
}
private static AetheriaRuntimeEntityStatGridCommit[] ProjectEntityStatGrids(Entity entity)
{
return new[]

View file

@ -67,6 +67,7 @@ public abstract class Entity
private List<Radiator> _heatsinks = new List<Radiator>();
private List<ConsumableItemEffect> _activeConsumables = new List<ConsumableItemEffect>();
public IReadOnlyList<ConsumableItemEffect> ActiveConsumables => _activeConsumables;
protected bool _active;

View file

@ -528,6 +528,36 @@ namespace GameCult.Aetheria.State.Unity
[Key(15)]
public IReadOnlyList<AetheriaRuntimeEntityStatGridCommit> StatGrids { get; set; } = Array.Empty<AetheriaRuntimeEntityStatGridCommit>();
[Key(16)]
public double VelocityX { get; set; }
[Key(17)]
public double VelocityY { get; set; }
[Key(18)]
public int TargetEntityIndex { get; set; } = -1;
[Key(19)]
public bool IsActive { get; set; }
[Key(20)]
public bool HeatsinksEnabled { get; set; }
[Key(21)]
public bool OverrideShutdown { get; set; }
[Key(22)]
public double TractorPower { get; set; }
[Key(23)]
public double Heatstroke { get; set; }
[Key(24)]
public double Hypothermia { get; set; }
[Key(25)]
public IReadOnlyList<AetheriaRuntimeActiveConsumableCommit> ActiveConsumables { get; set; } = Array.Empty<AetheriaRuntimeActiveConsumableCommit>();
}
[MessagePackObject]
@ -545,4 +575,20 @@ namespace GameCult.Aetheria.State.Unity
[Key(3)]
public IReadOnlyList<double> Values { get; set; } = Array.Empty<double>();
}
[MessagePackObject]
public sealed class AetheriaRuntimeActiveConsumableCommit
{
[Key(0)]
public string ItemDefinitionLegacyId { get; set; } = "";
[Key(1)]
public double Quality { get; set; } = 1.0;
[Key(2)]
public double RemainingDuration { get; set; }
[Key(3)]
public double Duration { get; set; }
}
}

View file

@ -139,9 +139,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
no longer the only place generated celestial graph facts can live.
- Run checkpoint entity snapshots include typed simulation stat grids for
temperature, thermal mass, armor, max armor, and hull-conductivity axes.
They also carry public runtime session state: velocity, target entity
reference, active flag, heatsink toggle, shutdown override, tractor power,
heatstroke/hypothermia accumulators, and active consumable item/timer rows.
`RuntimeEntityBlueprint` still exists for construction/loadout projection,
but those live hull grids are no longer blueprint fields and cannot be
restored by the old blueprint projector path.
but those live hull grids and session scalars are not blueprint fields and
cannot be restored by the old blueprint projector path.
- `Aetheria.State` now defines `AetheriaLoadoutTemplate` as the typed Verse
replacement for bespoke `.loadout` files. It stores structured hull,
equipment, cargo bay, docking bay, child-entity, assignment, and weapon-group
@ -754,13 +757,17 @@ First Aetheria surfaces to publish:
- Done: extend run checkpoint commits and smoke coverage to carry typed
entity simulation stat grids into `AetheriaEntitySnapshot`, so
temperature/armor/conductivity no longer live only in runtime blueprints.
- Done: extend run checkpoint commits and smoke coverage to carry public
entity session state into `AetheriaEntitySnapshot`: velocity, target
references, active/toggle scalars, thermal injury accumulators, and active
consumable timers.
- Done: cut live simulation grids out of `RuntimeEntityBlueprint`; loadout
and construction templates no longer capture or restore temperature,
armor, max-armor, or hull-conductivity state.
- Remaining: add typed documents/mappers for runtime object graphs,
typed behavior factory construction, behavior-private simulation state,
and any catalog fields not covered by the stable scalar/fingerprint/
payload pass.
typed behavior factory construction, behavior-private simulation state
such as weapon cooldown/charge/ammo and sensor/shield progress, and any
catalog fields not covered by the stable scalar/fingerprint/payload pass.
4. Runtime cutover
- Done: add a Unity-facing typed catalog read facade and smoke proving it can
@ -1151,7 +1158,8 @@ First Aetheria surfaces to publish:
replacement, loadout templates as the `.loadout` replacement, and a run ->
zone -> entity snapshot graph as the `.zone` replacement. The zone smoke
includes orbit/body rows for generated celestial state, and the entity smoke
includes typed simulation stat grids. The Unity runtime smoke also proves
includes typed simulation stat grids, public entity session scalars, and
active consumable timer rows. The Unity runtime smoke also proves
package-owned readback of typed loadout templates from `.cc` records. It also
proves `aetheria.runtime_session.v1` is advertised and survives reopen as the
typed daemon-session signal.