Import typed item shape masks
This commit is contained in:
parent
3818670e48
commit
ea50359594
151 changed files with 384 additions and 288 deletions
Binary file not shown.
|
|
@ -331,6 +331,7 @@ internal static class LegacyCatalogReader
|
|||
ShapeWidth = shape.Width,
|
||||
ShapeHeight = shape.Height,
|
||||
OccupiedCells = shape.OccupiedCells,
|
||||
ShapeCells = shape.Cells,
|
||||
HardpointType = GetHardpointType(unionKey, payload),
|
||||
HullType = unionKey == 3 ? GetEnumName(payload, 25, HullTypes) : "",
|
||||
BehaviorKinds = behaviorKinds,
|
||||
|
|
@ -637,20 +638,21 @@ internal static class LegacyCatalogReader
|
|||
{
|
||||
if (!payload.TryGetValue(key, out var value) || value == null)
|
||||
{
|
||||
return new ShapeFacts(0, 0, 0);
|
||||
return ShapeFacts.Empty;
|
||||
}
|
||||
|
||||
var matrix = UnwrapShapeMatrix(value);
|
||||
if (matrix is not object?[] columns)
|
||||
{
|
||||
return new ShapeFacts(0, 0, 0);
|
||||
return ShapeFacts.Empty;
|
||||
}
|
||||
|
||||
var width = columns.Length;
|
||||
var height = 0;
|
||||
var occupied = 0;
|
||||
foreach (var column in columns)
|
||||
var cellsByRow = new List<AetheriaShapeCell>();
|
||||
for (var x = 0; x < columns.Length; x++)
|
||||
{
|
||||
var column = columns[x];
|
||||
if (column is not object?[] cells)
|
||||
{
|
||||
if (column is bool occupiedCell)
|
||||
|
|
@ -658,7 +660,7 @@ internal static class LegacyCatalogReader
|
|||
height = Math.Max(height, 1);
|
||||
if (occupiedCell)
|
||||
{
|
||||
occupied++;
|
||||
cellsByRow.Add(new AetheriaShapeCell { X = x, Y = 0 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -666,10 +668,22 @@ internal static class LegacyCatalogReader
|
|||
}
|
||||
|
||||
height = Math.Max(height, cells.Length);
|
||||
occupied += cells.Count(cell => cell is true);
|
||||
for (var y = 0; y < cells.Length; y++)
|
||||
{
|
||||
if (cells[y] is true)
|
||||
{
|
||||
cellsByRow.Add(new AetheriaShapeCell { X = x, Y = y });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ShapeFacts(width, height, occupied);
|
||||
return new ShapeFacts(
|
||||
width,
|
||||
height,
|
||||
cellsByRow
|
||||
.OrderBy(cell => cell.Y)
|
||||
.ThenBy(cell => cell.X)
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
private static object? UnwrapShapeMatrix(object? value)
|
||||
|
|
@ -684,4 +698,9 @@ internal sealed record LegacyCatalogEntry(
|
|||
AetheriaCorporation? Corporation,
|
||||
AetheriaNameFile? NameFile);
|
||||
|
||||
internal readonly record struct ShapeFacts(int Width, int Height, int OccupiedCells);
|
||||
internal readonly record struct ShapeFacts(int Width, int Height, AetheriaShapeCell[] Cells)
|
||||
{
|
||||
public static ShapeFacts Empty { get; } = new(0, 0, []);
|
||||
|
||||
public int OccupiedCells => Cells.Length;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,19 @@ if (catalog.EquipmentItems.Count == 0)
|
|||
throw new InvalidOperationException("Runtime catalog has no equipment items.");
|
||||
}
|
||||
|
||||
var shaped = catalog.Items.FirstOrDefault(item => item.ShapeCells.Count > 0)
|
||||
?? throw new InvalidOperationException("Runtime catalog has no typed shape masks.");
|
||||
if (shaped.ShapeCells.Count != shaped.OccupiedCells)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Runtime shape mask count mismatch for {shaped.Name}: cells={shaped.ShapeCells.Count}, occupied={shaped.OccupiedCells}.");
|
||||
}
|
||||
|
||||
if (shaped.ShapeCells.Any(cell => cell.X < 0 || cell.Y < 0 || cell.X >= shaped.ShapeWidth || cell.Y >= shaped.ShapeHeight))
|
||||
{
|
||||
throw new InvalidOperationException($"Runtime shape mask has out-of-bounds cells for {shaped.Name}.");
|
||||
}
|
||||
|
||||
var behaviorKind = catalog.Items.SelectMany(item => item.BehaviorKinds).FirstOrDefault()
|
||||
?? throw new InvalidOperationException("Runtime catalog has no behavior kind fingerprints.");
|
||||
if (!catalog.FindItemsByBehavior(behaviorKind).Any())
|
||||
|
|
@ -53,5 +66,6 @@ if (surface?.Schema != "gamecult.eve.surface.v1" ||
|
|||
|
||||
Console.WriteLine($"Aetheria Unity runtime catalog smoke passed: {statePath}");
|
||||
Console.WriteLine($"Items/trade/equipment: {catalog.Items.Count}/{catalog.TradeItems.Count}/{catalog.EquipmentItems.Count}");
|
||||
Console.WriteLine($"Shape mask sample: {shaped.Name} {shaped.ShapeWidth}x{shaped.ShapeHeight}/{shaped.ShapeCells.Count}");
|
||||
Console.WriteLine($"Behavior sample: {behaviorKind}");
|
||||
Console.WriteLine($"Eve surface: {surface.Surface.Id}");
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ public sealed class AetheriaRuntimeCatalogItem
|
|||
int shapeWidth,
|
||||
int shapeHeight,
|
||||
int occupiedCells,
|
||||
IReadOnlyList<AetheriaRuntimeShapeCell> shapeCells,
|
||||
string hardpointType,
|
||||
string hullType,
|
||||
IReadOnlyList<string> behaviorKinds,
|
||||
|
|
@ -129,6 +130,7 @@ public sealed class AetheriaRuntimeCatalogItem
|
|||
ShapeWidth = shapeWidth;
|
||||
ShapeHeight = shapeHeight;
|
||||
OccupiedCells = occupiedCells;
|
||||
ShapeCells = shapeCells;
|
||||
HardpointType = hardpointType;
|
||||
HullType = hullType;
|
||||
BehaviorKinds = behaviorKinds;
|
||||
|
|
@ -152,6 +154,7 @@ public sealed class AetheriaRuntimeCatalogItem
|
|||
public int ShapeWidth { get; }
|
||||
public int ShapeHeight { get; }
|
||||
public int OccupiedCells { get; }
|
||||
public IReadOnlyList<AetheriaRuntimeShapeCell> ShapeCells { get; }
|
||||
public string HardpointType { get; }
|
||||
public string HullType { get; }
|
||||
public IReadOnlyList<string> BehaviorKinds { get; }
|
||||
|
|
@ -177,6 +180,7 @@ public sealed class AetheriaRuntimeCatalogItem
|
|||
item.ShapeWidth,
|
||||
item.ShapeHeight,
|
||||
item.OccupiedCells,
|
||||
item.ShapeCells.Select(AetheriaRuntimeShapeCell.FromState).ToArray(),
|
||||
item.HardpointType,
|
||||
item.HullType,
|
||||
item.BehaviorKinds,
|
||||
|
|
@ -190,6 +194,24 @@ public sealed class AetheriaRuntimeCatalogItem
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeShapeCell
|
||||
{
|
||||
public AetheriaRuntimeShapeCell(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public int X { get; }
|
||||
|
||||
public int Y { get; }
|
||||
|
||||
public static AetheriaRuntimeShapeCell FromState(AetheriaShapeCell cell)
|
||||
{
|
||||
return new AetheriaRuntimeShapeCell(cell.X, cell.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeCorporation
|
||||
{
|
||||
public AetheriaRuntimeCorporation(
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ if (nameFiles.Length == 0)
|
|||
var pricedItems = items.Count(item => item.Price > 0);
|
||||
var manufacturedItems = items.Count(item => !string.IsNullOrWhiteSpace(item.ManufacturerLegacyId));
|
||||
var shapedItems = items.Count(item => item.ShapeWidth > 0 && item.ShapeHeight > 0 && item.OccupiedCells > 0);
|
||||
var shapedMaskItems = items.Count(item => item.ShapeCells.Length > 0);
|
||||
var behaviorItems = items.Count(item => item.BehaviorCount > 0 && item.BehaviorKinds.Length > 0);
|
||||
var hardpointItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HardpointType));
|
||||
var hullItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HullType));
|
||||
|
|
@ -68,6 +69,26 @@ if (shapedItems == 0)
|
|||
throw new InvalidOperationException("Typed item definitions did not import any shape dimensions.");
|
||||
}
|
||||
|
||||
if (shapedMaskItems != shapedItems)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Typed item shape mask import mismatch: masks={shapedMaskItems}, shaped={shapedItems}.");
|
||||
}
|
||||
|
||||
foreach (var item in items.Where(item => item.ShapeCells.Length > 0))
|
||||
{
|
||||
if (item.ShapeCells.Length != item.OccupiedCells)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Typed item shape mask cell count mismatch for {item.Name}: cells={item.ShapeCells.Length}, occupied={item.OccupiedCells}.");
|
||||
}
|
||||
|
||||
if (item.ShapeCells.Any(cell => cell.X < 0 || cell.Y < 0 || cell.X >= item.ShapeWidth || cell.Y >= item.ShapeHeight))
|
||||
{
|
||||
throw new InvalidOperationException($"Typed item shape mask has out-of-bounds cells for {item.Name}.");
|
||||
}
|
||||
}
|
||||
|
||||
if (behaviorItems == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Typed item definitions did not import any behavior fingerprints.");
|
||||
|
|
@ -179,6 +200,7 @@ Console.WriteLine($"Aetheria typed state verify passed: {statePath}");
|
|||
Console.WriteLine($"Catalog fingerprint: {quarantine.CatalogFingerprint}");
|
||||
Console.WriteLine($"Item definitions: {items.Length}");
|
||||
Console.WriteLine($"Priced/manufactured/shaped items: {pricedItems}/{manufacturedItems}/{shapedItems}");
|
||||
Console.WriteLine($"Shape masks: {shapedMaskItems}");
|
||||
Console.WriteLine($"Behavior/hardpoint/hull/weapon items: {behaviorItems}/{hardpointItems}/{hullItems}/{weaponItems}");
|
||||
Console.WriteLine($"Typed catalog trade items: {tradeItems.Length}");
|
||||
Console.WriteLine($"Eve catalog surface: {surface.Surface.Id} ({surface.Surface.Root.Children.Length} root children)");
|
||||
|
|
|
|||
|
|
@ -87,4 +87,17 @@ public sealed class AetheriaItemDefinition
|
|||
|
||||
[Key(24)]
|
||||
public string WeaponModifiers { get; set; } = "";
|
||||
|
||||
[Key(25)]
|
||||
public AetheriaShapeCell[] ShapeCells { get; set; } = [];
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaShapeCell
|
||||
{
|
||||
[Key(0)]
|
||||
public int X { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public int Y { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,15 +46,16 @@ raw MessagePack union pass that maps stable catalog fields into typed
|
|||
item/faction/name-file documents without compiling Unity's legacy domain model
|
||||
into `Aetheria.State`. The current checked-in catalog maps to 115 item
|
||||
definitions, 12 factions, and 12 name files. Typed item definitions include
|
||||
legacy manufacturer IDs, price, shape dimensions, occupied cell counts, and
|
||||
legacy manufacturer IDs, price, shape dimensions, occupied cell counts, full
|
||||
shape-cell masks, and
|
||||
stable equipment facets: hardpoint type, hull type, behavior kind fingerprints,
|
||||
stack size, durability, and weapon range/caliber/type/fire/modifier
|
||||
classifications.
|
||||
Typed corporation documents include the legacy short name, the true description
|
||||
field from key 3, name-file and boss-hull legacy IDs, influence distance,
|
||||
allegiance count, and music bank IDs. Runtime object graphs, behaviors, full
|
||||
Unity shape masks, and simulation state remain legacy until dedicated typed
|
||||
documents exist.
|
||||
allegiance count, and music bank IDs. Runtime object graphs, full behavior
|
||||
payloads, and simulation state remain legacy until dedicated typed documents
|
||||
exist.
|
||||
Legacy GUID references that are `Guid.Empty` are imported as absent references,
|
||||
not as resolvable catalog links.
|
||||
|
||||
|
|
@ -73,16 +74,18 @@ Unity UI Toolkit lowering package exists.
|
|||
`Aetheria.State.Unity` is the Unity-facing runtime read facade over typed state.
|
||||
It opens `aetheria-world.cc`, emits immutable catalog read models for trade,
|
||||
equipment, behavior, hardpoint, manufacturer, corporation, and name-file
|
||||
queries, and can read the published Eve catalog surface. It does not deserialize
|
||||
legacy `DatabaseEntry` objects and does not write state. Unity can use this as
|
||||
the first package boundary once CultLib/Eve runtime packaging is available.
|
||||
queries, exposes typed item shape masks for layout and fitting consumers, and
|
||||
can read the published Eve catalog surface. It does not deserialize legacy
|
||||
`DatabaseEntry` objects and does not write state. Unity can use this as the
|
||||
first package boundary once CultLib/Eve runtime packaging is available.
|
||||
|
||||
`Aetheria.State.Verify` opens a materialized state file and checks that the
|
||||
typed migration ledger matches the actual item, corporation, and name-file
|
||||
records in the `.cc` store. It also verifies the canonical legacy-ID lookup API
|
||||
for one migrated record of each catalog kind and checks that expanded item and
|
||||
corporation catalog facts survived materialization. The verifier also exercises
|
||||
the typed catalog snapshot query surface and the published Eve catalog surface.
|
||||
the typed catalog snapshot query surface, shape-mask invariants, and the
|
||||
published Eve catalog surface.
|
||||
Use it after import when `GameData/aetheria-world.cc` changes.
|
||||
|
||||
`Aetheria.State.Unity.Smoke` opens the materialized state through the runtime
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue