Persist defensive behavior state in typed snapshots

This commit is contained in:
Meta Vens 2026-06-14 16:20:02 +01:00
commit 35c4195dac
10 changed files with 149 additions and 8 deletions

Binary file not shown.

View file

@ -304,6 +304,31 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
ThrusterAxis = 0.8,
ThrusterThrust = 125.0,
ThrusterTorque = -0.4
},
new AetheriaBehaviorStateSnapshot
{
OwnerKind = "equipment",
OwnerIndex = 0,
BehaviorIndex = 4,
BehaviorKind = "Shield",
ShieldEfficiency = 0.7,
ShieldEnergyUsage = 1.4
},
new AetheriaBehaviorStateSnapshot
{
OwnerKind = "equipment",
OwnerIndex = 0,
BehaviorIndex = 5,
BehaviorKind = "VelocityLimit",
VelocityLimit = 42.0
},
new AetheriaBehaviorStateSnapshot
{
OwnerKind = "equipment",
OwnerIndex = 0,
BehaviorIndex = 6,
BehaviorKind = "Thermotoggle",
ThermotoggleTargetTemperature = 315.5
}
],
StatGrids =
@ -567,7 +592,7 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
entitySnapshot.WeaponStates[0].BehaviorKind != "LockWeapon" ||
entitySnapshot.WeaponStates[0].LockProgress != 0.65 ||
entitySnapshot.WeaponStates[0].LockTargetEntityKey != entityKey.ToString() ||
entitySnapshot.BehaviorStates.Length != 4 ||
entitySnapshot.BehaviorStates.Length != 7 ||
entitySnapshot.BehaviorStates[0].BehaviorKind != "AetherDrive" ||
entitySnapshot.BehaviorStates[0].AetherDriveAxisX != 0.5 ||
entitySnapshot.BehaviorStates[0].AetherDriveRpmY != 900.0 ||
@ -585,6 +610,13 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
entitySnapshot.BehaviorStates[3].ThrusterAxis != 0.8 ||
entitySnapshot.BehaviorStates[3].ThrusterThrust != 125.0 ||
entitySnapshot.BehaviorStates[3].ThrusterTorque != -0.4 ||
entitySnapshot.BehaviorStates[4].BehaviorKind != "Shield" ||
entitySnapshot.BehaviorStates[4].ShieldEfficiency != 0.7 ||
entitySnapshot.BehaviorStates[4].ShieldEnergyUsage != 1.4 ||
entitySnapshot.BehaviorStates[5].BehaviorKind != "VelocityLimit" ||
entitySnapshot.BehaviorStates[5].VelocityLimit != 42.0 ||
entitySnapshot.BehaviorStates[6].BehaviorKind != "Thermotoggle" ||
entitySnapshot.BehaviorStates[6].ThermotoggleTargetTemperature != 315.5 ||
entitySnapshot.StatGrids.Length != 1 ||
entitySnapshot.StatGrids[0].Values.Length != 4)
{

View file

@ -533,6 +533,31 @@ try
ThrusterAxis = 0.8,
ThrusterThrust = 125.0,
ThrusterTorque = -0.4
},
new AetheriaRuntimeBehaviorStateCommit
{
OwnerKind = "equipment",
OwnerIndex = 8,
BehaviorIndex = 0,
BehaviorKind = "Shield",
ShieldEfficiency = 0.7,
ShieldEnergyUsage = 1.4
},
new AetheriaRuntimeBehaviorStateCommit
{
OwnerKind = "equipment",
OwnerIndex = 9,
BehaviorIndex = 0,
BehaviorKind = "VelocityLimit",
VelocityLimit = 42.0
},
new AetheriaRuntimeBehaviorStateCommit
{
OwnerKind = "equipment",
OwnerIndex = 10,
BehaviorIndex = 0,
BehaviorKind = "Thermotoggle",
ThermotoggleTargetTemperature = 315.5
}
},
StatGrids = new[]
@ -653,7 +678,7 @@ try
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 == 8 &&
entity.BehaviorStates.Length == 11 &&
entity.BehaviorStates[0].BehaviorKind == "Sensor" &&
entity.BehaviorStates[0].Pinging &&
entity.BehaviorStates[0].PingRadius == 1200.0 &&
@ -683,6 +708,13 @@ try
entity.BehaviorStates[7].ThrusterAxis == 0.8 &&
entity.BehaviorStates[7].ThrusterThrust == 125.0 &&
entity.BehaviorStates[7].ThrusterTorque == -0.4 &&
entity.BehaviorStates[8].BehaviorKind == "Shield" &&
entity.BehaviorStates[8].ShieldEfficiency == 0.7 &&
entity.BehaviorStates[8].ShieldEnergyUsage == 1.4 &&
entity.BehaviorStates[9].BehaviorKind == "VelocityLimit" &&
entity.BehaviorStates[9].VelocityLimit == 42.0 &&
entity.BehaviorStates[10].BehaviorKind == "Thermotoggle" &&
entity.BehaviorStates[10].ThermotoggleTargetTemperature == 315.5 &&
entity.WeaponGroups.Length == 1 &&
entity.StatGrids.Length == 2 &&
entity.StatGrids.Any(grid => grid.Name == "temperature" && grid.Values.Length == 2 && grid.Values[1] == 281.0) &&
@ -738,7 +770,7 @@ try
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 != 8 ||
packageEntities[0].BehaviorStates.Count != 11 ||
packageEntities[0].BehaviorStates[3].CapacitorCharge != 7.5 ||
packageEntities[0].BehaviorStates[4].AetherDriveRpmY != 900.0 ||
packageEntities[0].BehaviorStates[4].AetherDriveMaximumRpm != 2400.0 ||
@ -748,6 +780,9 @@ try
packageEntities[0].BehaviorStates[6].MiningToolRange != 275.0 ||
packageEntities[0].BehaviorStates[7].ThrusterAxis != 0.8 ||
packageEntities[0].BehaviorStates[7].ThrusterThrust != 125.0 ||
packageEntities[0].BehaviorStates[8].ShieldEfficiency != 0.7 ||
packageEntities[0].BehaviorStates[9].VelocityLimit != 42.0 ||
packageEntities[0].BehaviorStates[10].ThermotoggleTargetTemperature != 315.5 ||
packageEntities[0].StatGrids.Count != 2 ||
packageEntities[0].StatGrids.All(grid => grid.Name != "temperature" || grid.Values.Count != 2 || grid.Values[1] != 281.0))
{

View file

@ -510,7 +510,11 @@ public static class AetheriaRuntimeCommitLogApplier
MiningToolRange = state.MiningToolRange,
ThrusterAxis = state.ThrusterAxis,
ThrusterThrust = state.ThrusterThrust,
ThrusterTorque = state.ThrusterTorque
ThrusterTorque = state.ThrusterTorque,
ShieldEfficiency = state.ShieldEfficiency,
ShieldEnergyUsage = state.ShieldEnergyUsage,
VelocityLimit = state.VelocityLimit,
ThermotoggleTargetTemperature = state.ThermotoggleTargetTemperature
})
.ToArray();
}

View file

@ -775,6 +775,18 @@ public sealed class AetheriaBehaviorStateSnapshot
[Key(42)]
public double ThrusterTorque { get; set; }
[Key(43)]
public double ShieldEfficiency { get; set; }
[Key(44)]
public double ShieldEnergyUsage { get; set; }
[Key(45)]
public double VelocityLimit { get; set; }
[Key(46)]
public double ThermotoggleTargetTemperature { get; set; }
}
[MessagePackObject]

View file

@ -936,6 +936,28 @@ public class ActionGameManager : MonoBehaviour
ThrusterTorque = thruster.Torque
};
}
else if (behavior is Shield shield)
{
state = new AetheriaRuntimeBehaviorStateCommit
{
ShieldEfficiency = shield.Efficiency,
ShieldEnergyUsage = shield.EnergyUsage
};
}
else if (behavior is VelocityLimit velocityLimit)
{
state = new AetheriaRuntimeBehaviorStateCommit
{
VelocityLimit = velocityLimit.Limit
};
}
else if (behavior is Thermotoggle thermotoggle)
{
state = new AetheriaRuntimeBehaviorStateCommit
{
ThermotoggleTargetTemperature = thermotoggle.TargetTemperature
};
}
if (state == null)
continue;

View file

@ -1110,7 +1110,11 @@ namespace GameCult.Aetheria.State.Unity
double miningToolRange,
double thrusterAxis,
double thrusterThrust,
double thrusterTorque)
double thrusterTorque,
double shieldEfficiency,
double shieldEnergyUsage,
double velocityLimit,
double thermotoggleTargetTemperature)
{
OwnerKind = ownerKind;
OwnerIndex = ownerIndex;
@ -1155,6 +1159,10 @@ namespace GameCult.Aetheria.State.Unity
ThrusterAxis = thrusterAxis;
ThrusterThrust = thrusterThrust;
ThrusterTorque = thrusterTorque;
ShieldEfficiency = shieldEfficiency;
ShieldEnergyUsage = shieldEnergyUsage;
VelocityLimit = velocityLimit;
ThermotoggleTargetTemperature = thermotoggleTargetTemperature;
}
public string OwnerKind { get; }
@ -1200,5 +1208,9 @@ namespace GameCult.Aetheria.State.Unity
public double ThrusterAxis { get; }
public double ThrusterThrust { get; }
public double ThrusterTorque { get; }
public double ShieldEfficiency { get; }
public double ShieldEnergyUsage { get; }
public double VelocityLimit { get; }
public double ThermotoggleTargetTemperature { get; }
}
}

View file

@ -900,7 +900,11 @@ namespace GameCult.Aetheria.State.Unity
var thrusterAxis = ReadFieldDouble(ref reader, behaviorFields, 40);
var thrusterThrust = ReadFieldDouble(ref reader, behaviorFields, 41);
var thrusterTorque = ReadFieldDouble(ref reader, behaviorFields, 42);
SkipRemaining(ref reader, behaviorFields, 43);
var shieldEfficiency = ReadFieldDouble(ref reader, behaviorFields, 43);
var shieldEnergyUsage = ReadFieldDouble(ref reader, behaviorFields, 44);
var velocityLimit = ReadFieldDouble(ref reader, behaviorFields, 45);
var thermotoggleTargetTemperature = ReadFieldDouble(ref reader, behaviorFields, 46);
SkipRemaining(ref reader, behaviorFields, 47);
behaviorStates[behavior] = new AetheriaRuntimeBehaviorStateSnapshot(
ownerKind,
ownerIndex,
@ -944,7 +948,11 @@ namespace GameCult.Aetheria.State.Unity
miningToolRange,
thrusterAxis,
thrusterThrust,
thrusterTorque);
thrusterTorque,
shieldEfficiency,
shieldEnergyUsage,
velocityLimit,
thermotoggleTargetTemperature);
}
return behaviorStates;

View file

@ -824,5 +824,17 @@ namespace GameCult.Aetheria.State.Unity
[Key(42)]
public double ThrusterTorque { get; set; }
[Key(43)]
public double ShieldEfficiency { get; set; }
[Key(44)]
public double ShieldEnergyUsage { get; set; }
[Key(45)]
public double VelocityLimit { get; set; }
[Key(46)]
public double ThermotoggleTargetTemperature { get; set; }
}
}

View file

@ -175,7 +175,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
publish target body id, asteroid index, scan timer, range, minimum density,
and scan duration rows. Mining tools publish asteroid belt id, asteroid
index, and evaluated range rows. Thrusters publish analog axis input,
evaluated thrust, and torque rows.
evaluated thrust, and torque rows. Shields publish evaluated efficiency and
energy usage, velocity limiters publish evaluated limit, and thermotoggles
publish their active target temperature.
`RuntimeEntityBlueprint` still exists for construction/loadout projection,
but those live hull grids and session scalars are not blueprint fields and
cannot be restored by the old blueprint projector path.
@ -818,6 +820,8 @@ First Aetheria surfaces to publish:
snapshot/readback state.
- Done: extend behavior state rows for Thruster axis, thrust, and torque,
so analog propulsion state is typed snapshot/readback state.
- Done: extend behavior state rows for Shield efficiency/energy usage,
VelocityLimit limit, and Thermotoggle target temperature.
- 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.