Use typed item category tokens

This commit is contained in:
Meta Vens 2026-06-15 20:33:32 +01:00
commit 2de9a0f93b
156 changed files with 320 additions and 283 deletions

Binary file not shown.

View file

@ -209,6 +209,17 @@ internal static class LegacyCatalogReader
[31] = "WeaponItemData"
};
private static readonly Dictionary<int, string> ItemCategories = new()
{
[0] = "simple-commodity",
[1] = "compound-commodity",
[2] = "gear",
[3] = "hull",
[29] = "cargo-bay",
[30] = "docking-bay",
[31] = "weapon"
};
private static readonly HashSet<int> ItemUnionKeys = [0, 1, 2, 3, 29, 30, 31];
private static readonly Dictionary<int, string> HardpointTypes = CreateEnumMap([
"Hull",
@ -363,6 +374,8 @@ internal static class LegacyCatalogReader
var hardpoints = unionKey == 3 ? ReadHardpoints(payload, 23) : [];
var behaviorKey = unionKey == 31 || unionKey is 2 or 3 or 29 or 30 ? 11 : 10;
var behaviorPayloads = ReadBehaviorPayloads(payload, behaviorKey);
var itemCategory = GetItemCategory(unionKey);
var isConsumable = itemCategory == "consumable";
var behaviorKinds = behaviorPayloads
.Select(behavior => behavior.Kind)
.Where(kind => !string.IsNullOrWhiteSpace(kind))
@ -384,7 +397,7 @@ internal static class LegacyCatalogReader
? new AetheriaItemDefinition
{
Name = name,
Category = unionName,
Category = itemCategory,
LegacyId = legacyId,
Description = description,
Mass = GetDouble(payload, 4),
@ -408,15 +421,15 @@ internal static class LegacyCatalogReader
BehaviorKinds = behaviorKinds,
BehaviorCount = behaviorPayloads.Length,
MaxStack = unionKey == 0 ? GetInt(payload, 9) : 0,
Stackable = unionName == "ConsumableItemData" && GetBool(payload, 11),
Duration = unionName == "ConsumableItemData" ? GetDouble(payload, 12) : 0,
Stackable = isConsumable && GetBool(payload, 11),
Duration = isConsumable ? GetDouble(payload, 12) : 0,
Durability = unionKey is 2 or 3 or 29 or 30 or 31 ? GetDouble(payload, 12) : 0,
MinimumTemperature = unionKey is 2 or 3 or 29 or 30 or 31 ? GetDouble(payload, 13) : 0,
MaximumTemperature = unionKey is 2 or 3 or 29 or 30 or 31 ? GetDouble(payload, 14) : 0,
ThermalPerformanceCurveKeys = unionKey is 2 or 3 or 29 or 30 or 31 ? ReadCurveKeys(payload, 17) : [],
ThermalResilience = unionKey is 2 or 3 or 29 or 30 or 31 ? GetPositiveDoubleOrDefault(payload, 18, 1) : 1,
AudioStats = unionKey is 2 or 3 or 29 or 30 or 31 ? ReadAudioStats(payload, 22) : [],
EffectivenessCurveKeys = unionName == "ConsumableItemData" ? ReadCurveKeys(payload, 14) : [],
EffectivenessCurveKeys = isConsumable ? ReadCurveKeys(payload, 14) : [],
HullPrefab = unionKey == 3 ? GetString(payload, 24) : "",
HullGridOffset = unionKey == 3 ? GetDouble(payload, 26) : 0,
HullArmor = unionKey == 3 ? GetDouble(payload, 27) : 0,
@ -691,6 +704,13 @@ internal static class LegacyCatalogReader
};
}
private static string GetItemCategory(int unionKey)
{
return ItemCategories.TryGetValue(unionKey, out var category)
? category
: $"legacy-union:{unionKey}";
}
private static string GetEnumName(
IReadOnlyDictionary<int, object?> payload,
int key,

View file

@ -102,12 +102,23 @@ var dockingBayMaxSizeItems = items.Count(item =>
var describedCorporations = corporations.Count(corporation => !string.IsNullOrWhiteSpace(corporation.Description));
var corporationNameLinks = corporations.Count(corporation => !string.IsNullOrWhiteSpace(corporation.GeonameFileLegacyId));
var corporationAllegianceEdges = corporations.Sum(corporation => corporation.Allegiances.Length);
var legacyDtoCategories = items
.Where(item => item.Category.EndsWith("Data", StringComparison.Ordinal))
.Select(item => $"{item.Name}:{item.Category}")
.ToArray();
if (pricedItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any prices.");
}
if (legacyDtoCategories.Length > 0)
{
throw new InvalidOperationException(
"Typed item categories still contain legacy DTO class names: " +
string.Join(", ", legacyDtoCategories.Take(5)));
}
if (manufacturedItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any manufacturer legacy IDs.");

View file

@ -132,6 +132,9 @@ typed `ItemKeyValue` emitted by import/runtime projection.
Loadout generation now applies typed catalog prefilters for item category,
hardpoint type, shape fit, hull type, and behavior kind, then instantiates
generated equipment directly from typed runtime rows.
Typed item definition `Category` values are stable Aetheria tokens such as
`hull`, `weapon`, `gear`, `cargo-bay`, and `docking-bay`; legacy union class
names remain migration provenance, not live category predicates.
The surviving trade menu also applies typed catalog prefilters for row size,
hardpoint type, and behavior kind before legacy buy actions.
The old `ItemData`/`EquippableItemData`/`HullData`/`WeaponItemData` DTO

View file

@ -333,12 +333,6 @@ public static class ZoneGenerator
return blueprint;
}
// static float ResourceValue(ref Random random, ZoneGenerationSettings settings, SimpleCommodityData resource, float density)
// {
// return random.NextPowerDistribution(resource.Minimum, resource.Maximum, resource.Exponent,
// 1 / lerp(settings.ResourceDensityMinimum, settings.ResourceDensityMaximum, density));
// }
public static GeneratorPlanet[] GenerateEntities(ZoneGenerationSettings settings, ref Random random, float mass, float radius, float2 fixedPosition)
{
var root = new GeneratorPlanet

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