Expand typed item equipment migration

This commit is contained in:
Meta Vens 2026-06-13 09:01:13 +01:00
commit b854e9f61b
151 changed files with 574 additions and 272 deletions

Binary file not shown.

View file

@ -180,6 +180,89 @@ internal static class LegacyCatalogReader
};
private static readonly HashSet<int> ItemUnionKeys = [0, 1, 2, 3, 29, 30, 31];
private static readonly Dictionary<int, string> HardpointTypes = CreateEnumMap([
"Hull",
"Tool",
"Thermal",
"Thruster",
"WarpDrive",
"Reactor",
"Radiator",
"Shield",
"Sensors",
"Energy",
"Ballistic",
"Launcher",
"ControlModule",
"AetherDrive"
]);
private static readonly Dictionary<int, string> HullTypes = CreateEnumMap(["Ship", "Station", "Turret"]);
private static readonly Dictionary<int, string> WeaponRanges = CreateEnumMap(["Melee", "Short", "Medium", "Long"]);
private static readonly Dictionary<int, string> WeaponCalibers = CreateEnumMap(["Small", "Medium", "Large", "ExtraLarge"]);
private static readonly Dictionary<int, string> WeaponTypes = CreateEnumMap([
"ElectromagneticallyPropelled",
"ExplosivelyPropelled",
"Laser",
"Electrostatic",
"ParticleProjection",
"Missile",
"MicroMissile",
"SplitMissile",
"Mine",
"Jet"
]);
private static readonly Dictionary<int, string> WeaponFireTypeFlags = new()
{
[1 << 0] = "Direct",
[1 << 1] = "Guided",
[1 << 2] = "Seeking",
[1 << 3] = "Continuous",
[1 << 4] = "Charged"
};
private static readonly Dictionary<int, string> WeaponModifierFlags = new()
{
[1 << 0] = "Airburst",
[1 << 1] = "Incendiary",
[1 << 2] = "ArmorPenetrating",
[1 << 3] = "NegativeEntropy",
[1 << 4] = "RapidFire",
[1 << 5] = "Burst",
[1 << 6] = "Cluster"
};
private static readonly Dictionary<int, string> BehaviorUnionNames = new()
{
[0] = "GuidedWeapon",
[1] = "Launcher",
[2] = "Reactor",
[3] = "Radiator",
[4] = "StatModifier",
[5] = "Sensor",
[6] = "Reflector",
[7] = "Shield",
[8] = "Thruster",
[9] = "Wear",
[10] = "VelocityConversion",
[11] = "VelocityLimit",
[12] = "AetherDrive",
[15] = "Cooldown",
[16] = "Heat",
[18] = "ItemUsage",
[20] = "Switch",
[21] = "Trigger",
[22] = "Visibility",
[23] = "Thermotoggle",
[24] = "EnergyDraw",
[26] = "MiningTool",
[28] = "ResourceScanner",
[31] = "Capacitor",
[32] = "Cockpit",
[33] = "HeatStorage",
[34] = "TurretController",
[35] = "InstantWeapon",
[36] = "ConstantWeapon",
[37] = "ChargedWeapon",
[38] = "AutoWeapon"
};
public static IReadOnlyList<LegacyCatalogEntry> Read(string catalogPath)
{
@ -222,6 +305,7 @@ internal static class LegacyCatalogReader
var name = GetString(payload, 1);
var description = GetString(payload, 2);
var shape = ReadShape(payload, 5);
var behaviorKinds = ReadBehaviorKinds(payload, unionKey == 31 || unionKey is 2 or 3 or 29 or 30 ? 11 : 10);
var summary = new AetheriaLegacyCatalogEntrySummary
{
LegacyId = legacyId,
@ -247,7 +331,20 @@ internal static class LegacyCatalogReader
ShapeWidth = shape.Width,
ShapeHeight = shape.Height,
OccupiedCells = shape.OccupiedCells,
Tags = [unionName, "legacy-catalog"]
HardpointType = GetHardpointType(unionKey, payload),
HullType = unionKey == 3 ? GetEnumName(payload, 25, HullTypes) : "",
BehaviorKinds = behaviorKinds,
BehaviorCount = behaviorKinds.Length,
MaxStack = unionKey == 0 ? GetInt(payload, 9) : 0,
Stackable = false,
Duration = 0,
Durability = unionKey is 2 or 3 or 29 or 30 or 31 ? GetDouble(payload, 12) : 0,
WeaponRange = unionKey == 31 ? GetEnumName(payload, 24, WeaponRanges) : "",
WeaponCaliber = unionKey == 31 ? GetEnumName(payload, 25, WeaponCalibers) : "",
WeaponType = unionKey == 31 ? GetEnumName(payload, 26, WeaponTypes) : "",
WeaponFireTypes = unionKey == 31 ? GetFlags(payload, 27, WeaponFireTypeFlags) : "",
WeaponModifiers = unionKey == 31 ? GetFlags(payload, 28, WeaponModifierFlags) : "",
Tags = [unionName, "legacy-catalog", .. behaviorKinds.Select(kind => $"behavior:{kind}")]
}
: null,
unionKey == 13
@ -421,6 +518,11 @@ internal static class LegacyCatalogReader
};
}
private static bool GetBool(IReadOnlyDictionary<int, object?> payload, int key)
{
return payload.TryGetValue(key, out var value) && value is true;
}
private static uint GetUInt(IReadOnlyDictionary<int, object?> payload, int key)
{
if (!payload.TryGetValue(key, out var value) || value == null)
@ -448,6 +550,82 @@ internal static class LegacyCatalogReader
return payload.TryGetValue(key, out var value) && value is object?[] array ? array.Length : 0;
}
private static string GetHardpointType(int unionKey, IReadOnlyDictionary<int, object?> payload)
{
return unionKey switch
{
3 => "Hull",
29 or 30 => "Tool",
2 or 31 => GetEnumName(payload, 23, HardpointTypes),
_ => ""
};
}
private static string GetEnumName(
IReadOnlyDictionary<int, object?> payload,
int key,
IReadOnlyDictionary<int, string> names)
{
var value = GetInt(payload, key);
return names.TryGetValue(value, out var name) ? name : "";
}
private static string GetFlags(
IReadOnlyDictionary<int, object?> payload,
int key,
IReadOnlyDictionary<int, string> names)
{
var value = GetInt(payload, key);
if (value == 0)
{
return "None";
}
var flags = names
.Where(entry => (value & entry.Key) == entry.Key)
.Select(entry => entry.Value)
.ToArray();
return flags.Length == 0 ? "" : string.Join("|", flags);
}
private static string[] ReadBehaviorKinds(IReadOnlyDictionary<int, object?> payload, int key)
{
if (!payload.TryGetValue(key, out var value) || value is not object?[] behaviors)
{
return [];
}
return behaviors
.Select(ReadBehaviorKind)
.Where(kind => !string.IsNullOrWhiteSpace(kind))
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(kind => kind, StringComparer.OrdinalIgnoreCase)
.ToArray();
}
private static string ReadBehaviorKind(object? value)
{
if (value is not object?[] union || union.Length < 1)
{
return "";
}
var unionKey = union[0] switch
{
long longValue => checked((int) longValue),
int intValue => intValue,
_ => -1
};
return BehaviorUnionNames.TryGetValue(unionKey, out var name) ? name : $"behavior:{unionKey}";
}
private static Dictionary<int, string> CreateEnumMap(string[] names)
{
return names
.Select((name, index) => new { name, index })
.ToDictionary(entry => entry.index, entry => entry.name);
}
private static string[] GetStringArraySample(IReadOnlyDictionary<int, object?> payload, int key, int max)
{
return payload.TryGetValue(key, out var value) && value is object?[] array

View file

@ -43,6 +43,13 @@ 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 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));
var weaponItems = items.Count(item =>
!string.IsNullOrWhiteSpace(item.WeaponType) &&
!string.IsNullOrWhiteSpace(item.WeaponRange) &&
!string.IsNullOrWhiteSpace(item.WeaponCaliber));
var describedCorporations = corporations.Count(corporation => !string.IsNullOrWhiteSpace(corporation.Description));
var corporationNameLinks = corporations.Count(corporation => !string.IsNullOrWhiteSpace(corporation.GeonameFileLegacyId));
@ -61,6 +68,26 @@ if (shapedItems == 0)
throw new InvalidOperationException("Typed item definitions did not import any shape dimensions.");
}
if (behaviorItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any behavior fingerprints.");
}
if (hardpointItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any hardpoint types.");
}
if (hullItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any hull types.");
}
if (weaponItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any weapon facets.");
}
if (describedCorporations == 0)
{
throw new InvalidOperationException("Typed corporations did not import descriptions from legacy key 3.");
@ -78,6 +105,27 @@ if (tradeItems.Length != pricedItems)
$"Typed catalog trade item query mismatch: query={tradeItems.Length}, priced={pricedItems}.");
}
var equipmentItems = catalog.EquipmentItems.ToArray();
if (equipmentItems.Length != hardpointItems)
{
throw new InvalidOperationException(
$"Typed catalog equipment item query mismatch: query={equipmentItems.Length}, hardpoint={hardpointItems}.");
}
var behaviorKind = items.SelectMany(item => item.BehaviorKinds).FirstOrDefault()
?? throw new InvalidOperationException("Cannot verify typed catalog behavior query: no behavior kinds.");
if (!catalog.FindItemsByBehavior(behaviorKind).Any())
{
throw new InvalidOperationException($"Typed catalog behavior query failed for {behaviorKind}.");
}
var hardpointType = items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.HardpointType))?.HardpointType
?? throw new InvalidOperationException("Cannot verify typed catalog hardpoint query: no hardpoint types.");
if (!catalog.FindItemsByHardpoint(hardpointType).Any())
{
throw new InvalidOperationException($"Typed catalog hardpoint query failed for {hardpointType}.");
}
var manufacturedItem = items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.ManufacturerLegacyId))
?? throw new InvalidOperationException("Cannot verify typed catalog manufacturer lookup: no manufactured item.");
if (catalog.GetManufacturer(manufacturedItem) == null)
@ -131,6 +179,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($"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)");
Console.WriteLine($"Corporations: {corporations.Length}");

View file

@ -40,6 +40,28 @@ public sealed class AetheriaCatalogSnapshot
public IEnumerable<AetheriaItemDefinition> TradeItems =>
Items.Where(item => item.Price > 0).OrderBy(item => item.Name, StringComparer.OrdinalIgnoreCase);
public IEnumerable<AetheriaItemDefinition> EquipmentItems =>
Items.Where(item => !string.IsNullOrWhiteSpace(item.HardpointType))
.OrderBy(item => item.Name, StringComparer.OrdinalIgnoreCase);
public IEnumerable<AetheriaItemDefinition> FindItemsByBehavior(string behaviorKind)
{
return string.IsNullOrWhiteSpace(behaviorKind)
? []
: Items
.Where(item => item.BehaviorKinds.Contains(behaviorKind, StringComparer.OrdinalIgnoreCase))
.OrderBy(item => item.Name, StringComparer.OrdinalIgnoreCase);
}
public IEnumerable<AetheriaItemDefinition> FindItemsByHardpoint(string hardpointType)
{
return string.IsNullOrWhiteSpace(hardpointType)
? []
: Items
.Where(item => string.Equals(item.HardpointType, hardpointType, StringComparison.OrdinalIgnoreCase))
.OrderBy(item => item.Name, StringComparer.OrdinalIgnoreCase);
}
public AetheriaItemDefinition? FindItemByLegacyId(string legacyId)
{
return TryGet(_itemsByLegacyId, legacyId);

View file

@ -46,9 +46,11 @@ public static class AetheriaCatalogSurfaceProjector
Node(
"aetheria.catalog.summary",
"grid",
[("columns", "4")],
[("columns", "6")],
Metric("summary.items", "Items", catalog.Items.Count.ToString()),
Metric("summary.trade", "Trade Items", catalog.TradeItems.Count().ToString()),
Metric("summary.equipment", "Equipment", catalog.EquipmentItems.Count().ToString()),
Metric("summary.behaviors", "Behavior Kinds", catalog.Items.SelectMany(item => item.BehaviorKinds).Distinct().Count().ToString()),
Metric("summary.corporations", "Corporations", catalog.Corporations.Count.ToString()),
Metric("summary.nameFiles", "Name Files", catalog.NameFiles.Count.ToString())),
Node(

View file

@ -46,4 +46,45 @@ public sealed class AetheriaItemDefinition
[Key(11)]
public int OccupiedCells { get; set; }
[Key(12)]
[CultIndex("hardpointType")]
public string HardpointType { get; set; } = "";
[Key(13)]
[CultIndex("hullType")]
public string HullType { get; set; } = "";
[Key(14)]
public string[] BehaviorKinds { get; set; } = [];
[Key(15)]
public int BehaviorCount { get; set; }
[Key(16)]
public int MaxStack { get; set; }
[Key(17)]
public bool Stackable { get; set; }
[Key(18)]
public double Duration { get; set; }
[Key(19)]
public double Durability { get; set; }
[Key(20)]
public string WeaponRange { get; set; } = "";
[Key(21)]
public string WeaponCaliber { get; set; } = "";
[Key(22)]
public string WeaponType { get; set; } = "";
[Key(23)]
public string WeaponFireTypes { get; set; } = "";
[Key(24)]
public string WeaponModifiers { get; set; } = "";
}

View file

@ -46,7 +46,10 @@ 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, and occupied cell counts.
legacy manufacturer IDs, price, shape dimensions, occupied cell counts, 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
@ -57,8 +60,8 @@ not as resolvable catalog links.
`AetheriaCatalogSnapshot` is the typed read surface over materialized catalog
documents. It exposes trade items, legacy-ID lookup, manufacturer lookup,
corporation prefix lookup, and corporation name-file lookup without reading
`DatabaseEntry` objects.
corporation prefix lookup, corporation name-file lookup, equipment items,
behavior lookup, and hardpoint lookup without reading `DatabaseEntry` objects.
`AetheriaCatalogSurfaceProjector` publishes the first Eve-compatible provider
surface from typed catalog state. The importer materializes

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more