Name behavior body state as typed keys
This commit is contained in:
parent
9140f44cf7
commit
0aea729eff
11 changed files with 82 additions and 41 deletions
Binary file not shown.
|
|
@ -294,7 +294,7 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
|
|||
OwnerIndex = 0,
|
||||
BehaviorIndex = 1,
|
||||
BehaviorKind = "ResourceScanner",
|
||||
ResourceScannerTargetBodyId = "aetheria.body:legacy:smoke:body",
|
||||
ResourceScannerTargetBodyKey = "aetheria.body:legacy:smoke:body",
|
||||
ResourceScannerAsteroidIndex = 2,
|
||||
ResourceScannerScanTime = 1.25,
|
||||
ResourceScannerRange = 500.0,
|
||||
|
|
@ -307,7 +307,7 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
|
|||
OwnerIndex = 0,
|
||||
BehaviorIndex = 2,
|
||||
BehaviorKind = "MiningTool",
|
||||
MiningToolAsteroidBeltId = "aetheria.body:legacy:smoke:body",
|
||||
MiningToolAsteroidBeltKey = "aetheria.body:legacy:smoke:body",
|
||||
MiningToolAsteroidIndex = 3,
|
||||
MiningToolRange = 275.0
|
||||
},
|
||||
|
|
@ -676,12 +676,12 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
|
|||
entitySnapshot.BehaviorStates[0].AetherDriveRpmY != 900.0 ||
|
||||
entitySnapshot.BehaviorStates[0].AetherDriveMaximumRpm != 2400.0 ||
|
||||
entitySnapshot.BehaviorStates[1].BehaviorKind != "ResourceScanner" ||
|
||||
entitySnapshot.BehaviorStates[1].ResourceScannerTargetBodyId != "aetheria.body:legacy:smoke:body" ||
|
||||
entitySnapshot.BehaviorStates[1].ResourceScannerTargetBodyKey != "aetheria.body:legacy:smoke:body" ||
|
||||
entitySnapshot.BehaviorStates[1].ResourceScannerAsteroidIndex != 2 ||
|
||||
entitySnapshot.BehaviorStates[1].ResourceScannerScanTime != 1.25 ||
|
||||
entitySnapshot.BehaviorStates[1].ResourceScannerScanDuration != 3.5 ||
|
||||
entitySnapshot.BehaviorStates[2].BehaviorKind != "MiningTool" ||
|
||||
entitySnapshot.BehaviorStates[2].MiningToolAsteroidBeltId != "aetheria.body:legacy:smoke:body" ||
|
||||
entitySnapshot.BehaviorStates[2].MiningToolAsteroidBeltKey != "aetheria.body:legacy:smoke:body" ||
|
||||
entitySnapshot.BehaviorStates[2].MiningToolAsteroidIndex != 3 ||
|
||||
entitySnapshot.BehaviorStates[2].MiningToolRange != 275.0 ||
|
||||
entitySnapshot.BehaviorStates[3].BehaviorKind != "Thruster" ||
|
||||
|
|
|
|||
|
|
@ -827,12 +827,12 @@ try
|
|||
entity.BehaviorStates[4].AetherDriveMaximumRpm == 2400.0 &&
|
||||
entity.BehaviorStates[4].AetherDriveThrustDirectionY == -0.5 &&
|
||||
entity.BehaviorStates[5].BehaviorKind == "ResourceScanner" &&
|
||||
entity.BehaviorStates[5].ResourceScannerTargetBodyId == "aetheria.body:legacy:smoke:body" &&
|
||||
entity.BehaviorStates[5].ResourceScannerTargetBodyKey == "aetheria.body:legacy:smoke:body" &&
|
||||
entity.BehaviorStates[5].ResourceScannerAsteroidIndex == 2 &&
|
||||
entity.BehaviorStates[5].ResourceScannerScanTime == 1.25 &&
|
||||
entity.BehaviorStates[5].ResourceScannerScanDuration == 3.5 &&
|
||||
entity.BehaviorStates[6].BehaviorKind == "MiningTool" &&
|
||||
entity.BehaviorStates[6].MiningToolAsteroidBeltId == "aetheria.body:legacy:smoke:body" &&
|
||||
entity.BehaviorStates[6].MiningToolAsteroidBeltKey == "aetheria.body:legacy:smoke:body" &&
|
||||
entity.BehaviorStates[6].MiningToolAsteroidIndex == 3 &&
|
||||
entity.BehaviorStates[6].MiningToolRange == 275.0 &&
|
||||
entity.BehaviorStates[7].BehaviorKind == "Thruster" &&
|
||||
|
|
@ -945,9 +945,9 @@ try
|
|||
packageEntities[0].BehaviorStates[3].CapacitorCharge != 7.5 ||
|
||||
packageEntities[0].BehaviorStates[4].AetherDriveRpmY != 900.0 ||
|
||||
packageEntities[0].BehaviorStates[4].AetherDriveMaximumRpm != 2400.0 ||
|
||||
packageEntities[0].BehaviorStates[5].ResourceScannerTargetBodyId != "aetheria.body:legacy:smoke:body" ||
|
||||
packageEntities[0].BehaviorStates[5].ResourceScannerTargetBodyKey != "aetheria.body:legacy:smoke:body" ||
|
||||
packageEntities[0].BehaviorStates[5].ResourceScannerScanDuration != 3.5 ||
|
||||
packageEntities[0].BehaviorStates[6].MiningToolAsteroidBeltId != "aetheria.body:legacy:smoke:body" ||
|
||||
packageEntities[0].BehaviorStates[6].MiningToolAsteroidBeltKey != "aetheria.body:legacy:smoke:body" ||
|
||||
packageEntities[0].BehaviorStates[6].MiningToolRange != 275.0 ||
|
||||
packageEntities[0].BehaviorStates[7].ThrusterAxis != 0.8 ||
|
||||
packageEntities[0].BehaviorStates[7].ThrusterThrust != 125.0 ||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ RequireTypedPendingCommitKeys(root);
|
|||
RequireTypedRuntimeFactionKeys(root);
|
||||
RequireTypedGalaxyFactionRelationships(root);
|
||||
RequireRuntimeCatalogKeyOnlyLookups(root);
|
||||
RequireTypedBehaviorBodyKeys(root);
|
||||
RequireEveRuntimeBootstrap(root);
|
||||
RequireNoRendererLocalConsole(root);
|
||||
RequireNoRendererLocalDebugPanels(root);
|
||||
|
|
@ -734,6 +735,43 @@ static void RequireRuntimeCatalogKeyOnlyLookups(string root)
|
|||
}
|
||||
}
|
||||
|
||||
static void RequireTypedBehaviorBodyKeys(string root)
|
||||
{
|
||||
var checkedFiles = new[]
|
||||
{
|
||||
Path.Combine(root, "Aetheria.State", "Documents", "AetheriaRuntimeStateDocuments.cs"),
|
||||
Path.Combine(root, "Aetheria.State", "AetheriaRuntimeCommitLogApplier.cs"),
|
||||
Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogSnapshot.cs"),
|
||||
Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogStore.cs"),
|
||||
Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs"),
|
||||
Path.Combine(root, "Aetheria.State.Smoke", "Program.cs"),
|
||||
Path.Combine(root, "Aetheria.State.Unity.Smoke", "Program.cs")
|
||||
};
|
||||
|
||||
var forbiddenSymbols = new[]
|
||||
{
|
||||
"ResourceScannerTargetBodyId",
|
||||
"MiningToolAsteroidBeltId",
|
||||
"ParseLegacyGuidFromReferenceKey",
|
||||
"ParseLegacyIdFromReferenceKey"
|
||||
};
|
||||
|
||||
var hits = checkedFiles
|
||||
.Where(File.Exists)
|
||||
.SelectMany(path => File.ReadLines(path)
|
||||
.Select((line, index) => new { Path = path, LineNumber = index + 1, Line = line }))
|
||||
.Where(line => forbiddenSymbols.Any(symbol => line.Line.Contains(symbol, StringComparison.Ordinal)))
|
||||
.Select(line => $"{Path.GetRelativePath(root, line.Path)}:{line.LineNumber}: {line.Line.Trim()}")
|
||||
.ToArray();
|
||||
|
||||
if (hits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime behavior body references must be named typed BodyKey surfaces; GUID parsing is confined to ParseBodyGuidFromKey: " +
|
||||
string.Join("; ", hits));
|
||||
}
|
||||
}
|
||||
|
||||
static void RequireEveRuntimeBootstrap(string root)
|
||||
{
|
||||
var bootstrapPath = Path.Combine(
|
||||
|
|
|
|||
|
|
@ -569,13 +569,13 @@ public static class AetheriaRuntimeCommitLogApplier
|
|||
AetherDriveMaximumRpm = state.AetherDriveMaximumRpm,
|
||||
AetherDriveThrustDirectionX = state.AetherDriveThrustDirectionX,
|
||||
AetherDriveThrustDirectionY = state.AetherDriveThrustDirectionY,
|
||||
ResourceScannerTargetBodyId = state.ResourceScannerTargetBodyKey ?? "",
|
||||
ResourceScannerTargetBodyKey = state.ResourceScannerTargetBodyKey ?? "",
|
||||
ResourceScannerAsteroidIndex = state.ResourceScannerAsteroidIndex,
|
||||
ResourceScannerScanTime = state.ResourceScannerScanTime,
|
||||
ResourceScannerRange = state.ResourceScannerRange,
|
||||
ResourceScannerMinimumDensity = state.ResourceScannerMinimumDensity,
|
||||
ResourceScannerScanDuration = state.ResourceScannerScanDuration,
|
||||
MiningToolAsteroidBeltId = state.MiningToolAsteroidBeltKey ?? "",
|
||||
MiningToolAsteroidBeltKey = state.MiningToolAsteroidBeltKey ?? "",
|
||||
MiningToolAsteroidIndex = state.MiningToolAsteroidIndex,
|
||||
MiningToolRange = state.MiningToolRange,
|
||||
ThrusterAxis = state.ThrusterAxis,
|
||||
|
|
|
|||
|
|
@ -818,7 +818,7 @@ public sealed class AetheriaBehaviorStateSnapshot
|
|||
public double AetherDriveThrustDirectionY { get; set; }
|
||||
|
||||
[Key(31)]
|
||||
public string ResourceScannerTargetBodyId { get; set; } = "";
|
||||
public string ResourceScannerTargetBodyKey { get; set; } = "";
|
||||
|
||||
[Key(32)]
|
||||
public int ResourceScannerAsteroidIndex { get; set; } = -1;
|
||||
|
|
@ -836,7 +836,7 @@ public sealed class AetheriaBehaviorStateSnapshot
|
|||
public double ResourceScannerScanDuration { get; set; }
|
||||
|
||||
[Key(37)]
|
||||
public string MiningToolAsteroidBeltId { get; set; } = "";
|
||||
public string MiningToolAsteroidBeltKey { get; set; } = "";
|
||||
|
||||
[Key(38)]
|
||||
public int MiningToolAsteroidIndex { get; set; } = -1;
|
||||
|
|
|
|||
|
|
@ -114,9 +114,10 @@ resolver are deleted from the simulation shell.
|
|||
Run checkpoint commit DTOs carry typed `OrbitKey`, `ParentOrbitKey`, and
|
||||
`BodyKey` only for zone orbit/body snapshots. The old pending-command
|
||||
`OrbitLegacyId`, `ParentLegacyId`, and `BodyLegacyId` fallback fields are
|
||||
deleted. Behavior-state runtime commits carry typed body keys for resource
|
||||
scanner targets and mining tool asteroid belts; the old raw body ID commit
|
||||
fields are deleted.
|
||||
deleted. Behavior-state runtime commits and readback snapshots carry typed
|
||||
body-key fields for resource scanner targets and mining tool asteroid belts;
|
||||
the old raw body ID commit/readback field names are deleted. Unity still parses
|
||||
those body keys into GUIDs only at the current `Zone` body runtime boundary.
|
||||
The package runtime catalog snapshot indexes items by canonical item key; Unity
|
||||
gameplay, HUD, inventory, trade, ship, and zone helper lookups use `ItemKey`
|
||||
directly instead of deriving `ItemId` and searching by legacy GUID.
|
||||
|
|
|
|||
|
|
@ -349,21 +349,16 @@ public class ActionGameManager : MonoBehaviour
|
|||
return instance;
|
||||
}
|
||||
|
||||
private static Guid ParseLegacyGuidFromReferenceKey(string key, string documentName)
|
||||
private static Guid ParseBodyGuidFromKey(string bodyKey)
|
||||
{
|
||||
var legacyId = ParseLegacyIdFromReferenceKey(key, documentName);
|
||||
return Guid.TryParse(legacyId, out var id) ? id : Guid.Empty;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(bodyKey))
|
||||
return Guid.Empty;
|
||||
|
||||
private static string ParseLegacyIdFromReferenceKey(string key, string documentName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
return "";
|
||||
|
||||
var prefix = $"{documentName}:legacy:";
|
||||
return key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)
|
||||
? key.Substring(prefix.Length)
|
||||
: key;
|
||||
const string bodyPrefix = "aetheria.body:legacy:";
|
||||
var runtimeBodyId = bodyKey.StartsWith(bodyPrefix, StringComparison.OrdinalIgnoreCase)
|
||||
? bodyKey.Substring(bodyPrefix.Length)
|
||||
: bodyKey;
|
||||
return Guid.TryParse(runtimeBodyId, out var id) ? id : Guid.Empty;
|
||||
}
|
||||
|
||||
public static Galaxy CurrentGalaxy;
|
||||
|
|
@ -2820,7 +2815,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
break;
|
||||
case ResourceScanner resourceScanner:
|
||||
resourceScanner.RestoreRuntimeState(
|
||||
ParseLegacyGuidFromReferenceKey(behaviorState.ResourceScannerTargetBodyId, "aetheria.body"),
|
||||
ParseBodyGuidFromKey(behaviorState.ResourceScannerTargetBodyKey),
|
||||
behaviorState.ResourceScannerAsteroidIndex,
|
||||
(float)behaviorState.ResourceScannerScanTime,
|
||||
(float)behaviorState.ResourceScannerRange,
|
||||
|
|
@ -2829,7 +2824,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
break;
|
||||
case MiningTool miningTool:
|
||||
miningTool.RestoreRuntimeState(
|
||||
ParseLegacyGuidFromReferenceKey(behaviorState.MiningToolAsteroidBeltId, "aetheria.body"),
|
||||
ParseBodyGuidFromKey(behaviorState.MiningToolAsteroidBeltKey),
|
||||
behaviorState.MiningToolAsteroidIndex,
|
||||
(float)behaviorState.MiningToolRange);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1211,13 +1211,13 @@ namespace GameCult.Aetheria.State.Unity
|
|||
double aetherDriveMaximumRpm,
|
||||
double aetherDriveThrustDirectionX,
|
||||
double aetherDriveThrustDirectionY,
|
||||
string resourceScannerTargetBodyId,
|
||||
string resourceScannerTargetBodyKey,
|
||||
int resourceScannerAsteroidIndex,
|
||||
double resourceScannerScanTime,
|
||||
double resourceScannerRange,
|
||||
double resourceScannerMinimumDensity,
|
||||
double resourceScannerScanDuration,
|
||||
string miningToolAsteroidBeltId,
|
||||
string miningToolAsteroidBeltKey,
|
||||
int miningToolAsteroidIndex,
|
||||
double miningToolRange,
|
||||
double thrusterAxis,
|
||||
|
|
@ -1267,13 +1267,13 @@ namespace GameCult.Aetheria.State.Unity
|
|||
AetherDriveMaximumRpm = aetherDriveMaximumRpm;
|
||||
AetherDriveThrustDirectionX = aetherDriveThrustDirectionX;
|
||||
AetherDriveThrustDirectionY = aetherDriveThrustDirectionY;
|
||||
ResourceScannerTargetBodyId = resourceScannerTargetBodyId;
|
||||
ResourceScannerTargetBodyKey = resourceScannerTargetBodyKey;
|
||||
ResourceScannerAsteroidIndex = resourceScannerAsteroidIndex;
|
||||
ResourceScannerScanTime = resourceScannerScanTime;
|
||||
ResourceScannerRange = resourceScannerRange;
|
||||
ResourceScannerMinimumDensity = resourceScannerMinimumDensity;
|
||||
ResourceScannerScanDuration = resourceScannerScanDuration;
|
||||
MiningToolAsteroidBeltId = miningToolAsteroidBeltId;
|
||||
MiningToolAsteroidBeltKey = miningToolAsteroidBeltKey;
|
||||
MiningToolAsteroidIndex = miningToolAsteroidIndex;
|
||||
MiningToolRange = miningToolRange;
|
||||
ThrusterAxis = thrusterAxis;
|
||||
|
|
@ -1324,13 +1324,13 @@ namespace GameCult.Aetheria.State.Unity
|
|||
public double AetherDriveMaximumRpm { get; }
|
||||
public double AetherDriveThrustDirectionX { get; }
|
||||
public double AetherDriveThrustDirectionY { get; }
|
||||
public string ResourceScannerTargetBodyId { get; }
|
||||
public string ResourceScannerTargetBodyKey { get; }
|
||||
public int ResourceScannerAsteroidIndex { get; }
|
||||
public double ResourceScannerScanTime { get; }
|
||||
public double ResourceScannerRange { get; }
|
||||
public double ResourceScannerMinimumDensity { get; }
|
||||
public double ResourceScannerScanDuration { get; }
|
||||
public string MiningToolAsteroidBeltId { get; }
|
||||
public string MiningToolAsteroidBeltKey { get; }
|
||||
public int MiningToolAsteroidIndex { get; }
|
||||
public double MiningToolRange { get; }
|
||||
public double ThrusterAxis { get; }
|
||||
|
|
|
|||
|
|
@ -987,13 +987,13 @@ namespace GameCult.Aetheria.State.Unity
|
|||
var aetherDriveMaximumRpm = ReadFieldDouble(ref reader, behaviorFields, 28);
|
||||
var aetherDriveThrustDirectionX = ReadFieldDouble(ref reader, behaviorFields, 29);
|
||||
var aetherDriveThrustDirectionY = ReadFieldDouble(ref reader, behaviorFields, 30);
|
||||
var resourceScannerTargetBodyId = ReadFieldString(ref reader, behaviorFields, 31);
|
||||
var resourceScannerTargetBodyKey = ReadFieldString(ref reader, behaviorFields, 31);
|
||||
var resourceScannerAsteroidIndex = ReadFieldInt32(ref reader, behaviorFields, 32);
|
||||
var resourceScannerScanTime = ReadFieldDouble(ref reader, behaviorFields, 33);
|
||||
var resourceScannerRange = ReadFieldDouble(ref reader, behaviorFields, 34);
|
||||
var resourceScannerMinimumDensity = ReadFieldDouble(ref reader, behaviorFields, 35);
|
||||
var resourceScannerScanDuration = ReadFieldDouble(ref reader, behaviorFields, 36);
|
||||
var miningToolAsteroidBeltId = ReadFieldString(ref reader, behaviorFields, 37);
|
||||
var miningToolAsteroidBeltKey = ReadFieldString(ref reader, behaviorFields, 37);
|
||||
var miningToolAsteroidIndex = ReadFieldInt32(ref reader, behaviorFields, 38);
|
||||
var miningToolRange = ReadFieldDouble(ref reader, behaviorFields, 39);
|
||||
var thrusterAxis = ReadFieldDouble(ref reader, behaviorFields, 40);
|
||||
|
|
@ -1044,13 +1044,13 @@ namespace GameCult.Aetheria.State.Unity
|
|||
aetherDriveMaximumRpm,
|
||||
aetherDriveThrustDirectionX,
|
||||
aetherDriveThrustDirectionY,
|
||||
resourceScannerTargetBodyId,
|
||||
resourceScannerTargetBodyKey,
|
||||
resourceScannerAsteroidIndex,
|
||||
resourceScannerScanTime,
|
||||
resourceScannerRange,
|
||||
resourceScannerMinimumDensity,
|
||||
resourceScannerScanDuration,
|
||||
miningToolAsteroidBeltId,
|
||||
miningToolAsteroidBeltKey,
|
||||
miningToolAsteroidIndex,
|
||||
miningToolRange,
|
||||
thrusterAxis,
|
||||
|
|
|
|||
|
|
@ -1348,7 +1348,10 @@ First Aetheria surfaces to publish:
|
|||
- In progress: convert domain references from GUID/base-class patterns to
|
||||
typed record refs. Item instances, cargo inventory indexes, weapon ammo
|
||||
references, item-use behavior references, and runtime commit item/hull
|
||||
surfaces now carry typed item keys; remaining broader simulation paths
|
||||
surfaces now carry typed item keys. Runtime behavior resource-scanner and
|
||||
mining-tool body references are named and serialized as typed body keys
|
||||
through commit/readback state, with GUID parsing confined to the current
|
||||
Unity `Zone` body runtime boundary. Remaining broader simulation paths
|
||||
still derive legacy GUIDs until those structures move to typed keys.
|
||||
- Done: delete the `ItemInstance.ItemId` legacy-GUID projection; diagnostics
|
||||
now report `ItemKey` so item instances expose only typed item-key identity.
|
||||
|
|
@ -1752,6 +1755,10 @@ First Aetheria surfaces to publish:
|
|||
- `Aetheria.State.Verify` guards Unity runtime catalog lookup authority:
|
||||
package snapshots may expose typed-key lookup only, while legacy-ID lookup
|
||||
remains quarantined in canonical migration/catalog inspection APIs.
|
||||
- `Aetheria.State.Verify` guards behavior body reference naming:
|
||||
resource-scanner and mining-tool runtime state surfaces use `BodyKey` fields;
|
||||
old `*BodyId` readback names and generic legacy reference parsers may not
|
||||
return.
|
||||
- Unity batchmode compile returned cleanly after the runtime blueprint rename;
|
||||
live Unity source has no `EntityPack`, `ShipPack`, `OrbitalEntityPack`,
|
||||
`ZonePack`, `PackedContents`, `PackZone`, `EntitySerializer.Pack`, or
|
||||
|
|
|
|||
Loading…
Reference in a new issue