Preserve entity item facts in typed snapshots

This commit is contained in:
Meta Vens 2026-06-14 15:23:38 +01:00
commit 2907cdd801
8 changed files with 62 additions and 8 deletions

Binary file not shown.

View file

@ -206,7 +206,10 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
new AetheriaEntityItemSlot
{
Position = new AetheriaGridCoord { X = 0, Y = 0 },
ItemKey = AetheriaCatalogKeys.ItemDefinitionFromLegacyId(itemLegacyId).ToString()
ItemKey = AetheriaCatalogKeys.ItemDefinitionFromLegacyId(itemLegacyId).ToString(),
Quality = 0.9,
Durability = 0.8,
Quantity = 1
}
],
WeaponGroups =
@ -465,6 +468,9 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
if (entitySnapshot?.Kind != "ship" ||
entitySnapshot.Equipment.Length != 1 ||
entitySnapshot.Equipment[0].Quality != 0.9 ||
entitySnapshot.Equipment[0].Durability != 0.8 ||
entitySnapshot.Equipment[0].Quantity != 1 ||
entitySnapshot.WeaponGroups.Length != 1 ||
entitySnapshot.StatGrids.Length != 1 ||
entitySnapshot.StatGrids[0].Values.Length != 4)

View file

@ -529,6 +529,9 @@ try
zone.Bodies[0].Resources[0].ItemKey == "aetheria.item_definition:legacy:smoke:ore" &&
zone.Bodies[0].Asteroids.Length == 1 &&
entity?.Equipment.Length == 1 &&
entity.Equipment[0].Quality == 0.9 &&
entity.Equipment[0].Durability == 0.8 &&
entity.Equipment[0].Quantity == 1 &&
entity.Velocity.X == 4.0 &&
entity.Velocity.Y == -2.0 &&
entity.TargetEntityKey == "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" &&
@ -611,6 +614,9 @@ try
packageZones[0].Bodies[0].AsteroidCount != 1 ||
packageEntities.Count != 1 ||
packageEntities[0].Name != "Unity Smoke Ship" ||
packageEntities[0].Equipment[0].Quality != 0.9 ||
packageEntities[0].Equipment[0].Durability != 0.8 ||
packageEntities[0].Equipment[0].Quantity != 1 ||
packageEntities[0].VelocityX != 4.0 ||
packageEntities[0].VelocityY != -2.0 ||
packageEntities[0].TargetEntityKey != "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" ||

View file

@ -191,11 +191,22 @@ public static class AetheriaRuntimeCommitLogApplier
private static AetheriaEntityItemSlot[] ToEntityItemSlots(
IReadOnlyList<AetheriaRuntimeLoadoutItemSlotCommit>? slots)
{
return ToItemSlots(slots)
.Select(slot => new AetheriaEntityItemSlot
return (slots ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
.Select(slot =>
{
Position = slot.Position,
ItemKey = slot.Item.ItemKey
var item = ToLoadoutItem(slot.Item);
return new AetheriaEntityItemSlot
{
Position = new AetheriaGridCoord
{
X = slot.X,
Y = slot.Y
},
ItemKey = item.ItemKey,
Quality = item.Quality,
Durability = item.Durability,
Quantity = item.Quantity
};
})
.ToArray();
}

View file

@ -504,6 +504,15 @@ public sealed class AetheriaEntityItemSlot
[Key(1)]
public string ItemKey { get; set; } = "";
[Key(2)]
public double Quality { get; set; } = 1.0;
[Key(3)]
public double Durability { get; set; } = 1.0;
[Key(4)]
public int Quantity { get; set; } = 1;
}
[MessagePackObject]

View file

@ -923,16 +923,22 @@ namespace GameCult.Aetheria.State.Unity
public sealed class AetheriaRuntimeEntityItemSlotSnapshot
{
public AetheriaRuntimeEntityItemSlotSnapshot(int x, int y, string itemKey)
public AetheriaRuntimeEntityItemSlotSnapshot(int x, int y, string itemKey, double quality, double durability, int quantity)
{
X = x;
Y = y;
ItemKey = itemKey;
Quality = quality;
Durability = durability;
Quantity = quantity;
}
public int X { get; }
public int Y { get; }
public string ItemKey { get; }
public double Quality { get; }
public double Durability { get; }
public int Quantity { get; }
}
public sealed class AetheriaRuntimeEntityStatGridSnapshot

View file

@ -696,8 +696,17 @@ namespace GameCult.Aetheria.State.Unity
var slotFields = reader.ReadArrayHeader();
var position = ReadFieldGridCoord(ref reader, slotFields, 0);
var itemKey = ReadFieldString(ref reader, slotFields, 1);
SkipRemaining(ref reader, slotFields, 2);
slots[slot] = new AetheriaRuntimeEntityItemSlotSnapshot(position.X, position.Y, itemKey);
var quality = ReadFieldDouble(ref reader, slotFields, 2, 1);
var durability = ReadFieldDouble(ref reader, slotFields, 3, 1);
var quantity = ReadFieldInt32(ref reader, slotFields, 4);
SkipRemaining(ref reader, slotFields, 5);
slots[slot] = new AetheriaRuntimeEntityItemSlotSnapshot(
position.X,
position.Y,
itemKey,
quality,
durability,
quantity <= 0 ? 1 : quantity);
}
return slots;

View file

@ -153,6 +153,10 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
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.
Entity equipment, cargo-bay, and docking-bay slot rows preserve item-instance
facts needed for restore: item key, quality, durability, and quantity. Those
facts are no longer discarded when pending checkpoint commands become
canonical `AetheriaEntitySnapshot` documents or package readback DTOs.
Equipped-item and active-consumable behaviors that intentionally expose
`IProgressBehavior` now publish typed progress rows keyed by owner kind,
owner index, behavior index, behavior kind, and progress value.
@ -800,6 +804,9 @@ First Aetheria surfaces to publish:
- Done: persist the actual galaxy generation seed in typed run state, so
future Continue/restore work has a reproducible topology body before
applying current-zone/entity snapshots.
- Done: preserve entity snapshot item-instance facts for equipment,
cargo-bay, and docking-bay slot rows: item key, quality, durability, and
quantity now survive canonical state and Unity package readback.
- Remaining: add typed documents/mappers for runtime object graphs,
typed behavior factory construction, remaining behavior-private state not
covered by progress, weapon, sensor, radiator, reactor, or capacitor rows,