Use typed commodity categories in trade rows

This commit is contained in:
Meta Vens 2026-06-14 03:52:20 +01:00
commit ecd64d20a6
159 changed files with 356 additions and 297 deletions

Binary file not shown.

View file

@ -233,6 +233,23 @@ internal static class LegacyCatalogReader
"Clockwise"
]);
private static readonly Dictionary<int, string> HullTypes = CreateEnumMap(["Ship", "Station", "Turret"]);
private static readonly Dictionary<int, string> SimpleCommodityCategories = CreateEnumMap([
"Minerals",
"Metals",
"Alloys",
"Compounds",
"Organics",
"Ammo",
"Consumer"
]);
private static readonly Dictionary<int, string> CompoundCommodityCategories = CreateEnumMap([
"Wearables",
"Consumables",
"Luxuries",
"Tools",
"Manufacturing",
"Assemblies"
]);
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([
@ -395,6 +412,8 @@ internal static class LegacyCatalogReader
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) : [],
HullPrefab = unionKey == 3 ? GetString(payload, 24) : "",
SimpleCommodityCategory = unionKey == 0 ? GetEnumName(payload, 10, SimpleCommodityCategories) : "",
CompoundCommodityCategory = unionKey == 1 ? GetEnumName(payload, 11, CompoundCommodityCategories) : "",
WeaponRange = unionKey == 31 ? GetEnumName(payload, 24, WeaponRanges) : "",
WeaponCaliber = unionKey == 31 ? GetEnumName(payload, 25, WeaponCalibers) : "",
WeaponType = unionKey == 31 ? GetEnumName(payload, 26, WeaponTypes) : "",

View file

@ -47,7 +47,9 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
item.MinimumTemperature,
item.MaximumTemperature,
item.ThermalPerformanceCurveKeys.Select(FromState).ToArray(),
item.HullPrefab);
item.HullPrefab,
item.SimpleCommodityCategory,
item.CompoundCommodityCategory);
}
private static AetheriaRuntimeShapeCell FromState(AetheriaShapeCell cell)

View file

@ -63,6 +63,8 @@ var behaviorLegacyRefCount = items
var hardpointItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HardpointType));
var hullItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HullType));
var hullPrefabItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HullPrefab));
var simpleCommodityCategoryItems = items.Count(item => !string.IsNullOrWhiteSpace(item.SimpleCommodityCategory));
var compoundCommodityCategoryItems = items.Count(item => !string.IsNullOrWhiteSpace(item.CompoundCommodityCategory));
var weaponItems = items.Count(item =>
!string.IsNullOrWhiteSpace(item.WeaponType) &&
!string.IsNullOrWhiteSpace(item.WeaponRange) &&
@ -234,6 +236,16 @@ if (hullPrefabItems != hullItems)
throw new InvalidOperationException($"Typed hull prefab import mismatch: hulls={hullItems}, prefabs={hullPrefabItems}.");
}
if (simpleCommodityCategoryItems == 0)
{
throw new InvalidOperationException("Typed simple commodity category import produced no categories.");
}
if (compoundCommodityCategoryItems == 0)
{
throw new InvalidOperationException("Typed compound commodity category import produced no categories.");
}
if (weaponItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any weapon facets.");
@ -340,6 +352,7 @@ Console.WriteLine($"Interior masks/hardpoint hosts/hardpoints: {interiorShapeIte
Console.WriteLine($"Behavior payload items/payloads/fields/legacy refs: {behaviorPayloadItems}/{behaviorPayloadCount}/{behaviorFieldCount}/{behaviorLegacyRefCount}");
Console.WriteLine($"Behavior/hardpoint/hull/weapon items: {behaviorItems}/{hardpointItems}/{hullItems}/{weaponItems}");
Console.WriteLine($"Hull prefab items: {hullPrefabItems}");
Console.WriteLine($"Simple/compound commodity category items: {simpleCommodityCategoryItems}/{compoundCommodityCategoryItems}");
Console.WriteLine($"Durable hull/weapon items: {durableMaxDurabilityItems}/{maxDurabilityItems.Length}");
Console.WriteLine($"Thermal range/curve items: {importedThermalRangeItems}/{importedThermalCurveItems}");
Console.WriteLine($"Typed catalog trade items: {tradeItems.Length}");

View file

@ -120,6 +120,12 @@ public sealed class AetheriaItemDefinition
[Key(35)]
public string HullPrefab { get; set; } = "";
[Key(36)]
public string SimpleCommodityCategory { get; set; } = "";
[Key(37)]
public string CompoundCommodityCategory { get; set; } = "";
}
[MessagePackObject]

View file

@ -198,26 +198,22 @@ public class TradeMenu : MonoBehaviour
columns.Add(("Type", 2,
x => () =>
{
if (x.TypedItem != null && x.TypedItem.Category == "SimpleCommodityData" && x.LegacyData is SimpleCommodityData s)
return Enum.GetName(typeof(SimpleCommodityCategory), s.Category);
if (x.TypedItem != null && x.TypedItem.Category == "CompoundCommodityData" && x.LegacyData is CompoundCommodityData c)
return Enum.GetName(typeof(CompoundCommodityCategory), c.Category);
if (x.TryGetTypedSimpleCommodityCategory(out _))
return x.TypedItem.SimpleCommodityCategory;
if (x.TryGetTypedCompoundCommodityCategory(out _))
return x.TypedItem.CompoundCommodityCategory;
if (x.TryGetTypedHardpoint(out var hardpointType)) return Enum.GetName(typeof(HardpointType), hardpointType);
if (x.TypedItem == null && x.LegacyData is SimpleCommodityData legacySimple) return Enum.GetName(typeof(SimpleCommodityCategory), legacySimple.Category);
if(x.TypedItem == null && x.LegacyData is CompoundCommodityData legacyCompound) return Enum.GetName(typeof(CompoundCommodityCategory), legacyCompound.Category);
return "None";
},
x =>
{
if (x.TypedItem != null && x.TypedItem.Category == "SimpleCommodityData" && x.LegacyData is SimpleCommodityData s)
return (int) s.Category;
if (x.TryGetTypedSimpleCommodityCategory(out var simpleCategory))
return (int)simpleCategory;
var offset = Enum.GetValues(typeof(SimpleCommodityCategory)).Length;
if(x.TypedItem != null && x.TypedItem.Category == "CompoundCommodityData" && x.LegacyData is CompoundCommodityData c)
return (int) c.Category + offset;
if(x.TryGetTypedCompoundCommodityCategory(out var compoundCategory))
return (int)compoundCategory + offset;
offset += Enum.GetValues(typeof(CompoundCommodityCategory)).Length;
if (x.TryGetTypedHardpoint(out var hardpointType)) return (int) hardpointType + offset;
if (x.TypedItem == null && x.LegacyData is SimpleCommodityData legacySimple) return (int) legacySimple.Category;
if(x.TypedItem == null && x.LegacyData is CompoundCommodityData legacyCompound) return (int) legacyCompound.Category + Enum.GetValues(typeof(SimpleCommodityCategory)).Length;
return 0;
}));
columns.Add(("Mass", 1,
@ -245,10 +241,10 @@ public class TradeMenu : MonoBehaviour
MaximumSizeFilter.Height.text.Length > 0 && i.ShapeHeight > int.Parse(MaximumSizeFilter.Height.text)));
if(_commodityFilter.filter != null)
items = items.Where(i => i.LegacyData is SimpleCommodityData s && s.Category == _commodityFilter.type);
items = items.Where(i => i.TryGetTypedSimpleCommodityCategory(out var category) && category == _commodityFilter.type);
if(_compoundCommodityFilter.filter != null)
items = items.Where(i => i.LegacyData is CompoundCommodityData c && c.Category == _compoundCommodityFilter.type);
items = items.Where(i => i.TryGetTypedCompoundCommodityCategory(out var category) && category == _compoundCommodityFilter.type);
if (_hardpointFilter.filter != null)
items = items.Where(i => i.TryGetTypedHardpoint(out var hardpointType) && hardpointType == _hardpointFilter.type);
@ -428,11 +424,11 @@ public class TradeMenu : MonoBehaviour
public EquippableItemData LegacyEquippableData => LegacyData as EquippableItemData;
public Guid LegacyId => Item?.Data?.ItemId ?? LegacyData.ID;
public Guid LegacyId => Item?.Data?.ItemId ?? Guid.Empty;
public string Name => !string.IsNullOrWhiteSpace(TypedItem?.Name) ? TypedItem.Name : LegacyData.Name;
public string Name => !string.IsNullOrWhiteSpace(TypedItem?.Name) ? TypedItem.Name : "Unknown Item";
public float Mass => TypedItem != null ? (float)TypedItem.Mass : LegacyData.Mass;
public float Mass => TypedItem != null ? (float)TypedItem.Mass : 0f;
public int Price
{
@ -441,15 +437,29 @@ public class TradeMenu : MonoBehaviour
if (Item is CraftedItemInstance craftedItemInstance)
return _itemManager.GetPrice(craftedItemInstance);
return TypedItem != null ? TypedItem.Price : LegacyData.Price;
return TypedItem != null ? TypedItem.Price : 0;
}
}
public int ShapeWidth => TypedItem != null && TypedItem.ShapeWidth > 0 ? TypedItem.ShapeWidth : LegacyData.Shape.Width;
public int ShapeWidth => TypedItem != null && TypedItem.ShapeWidth > 0 ? TypedItem.ShapeWidth : 0;
public int ShapeHeight => TypedItem != null && TypedItem.ShapeHeight > 0 ? TypedItem.ShapeHeight : LegacyData.Shape.Height;
public int ShapeHeight => TypedItem != null && TypedItem.ShapeHeight > 0 ? TypedItem.ShapeHeight : 0;
public bool IsHull => TypedItem != null ? !string.IsNullOrWhiteSpace(TypedItem.HullType) : LegacyData is HullData;
public bool IsHull => !string.IsNullOrWhiteSpace(TypedItem?.HullType);
public bool TryGetTypedSimpleCommodityCategory(out SimpleCommodityCategory category)
{
category = SimpleCommodityCategory.Minerals;
return !string.IsNullOrWhiteSpace(TypedItem?.SimpleCommodityCategory) &&
Enum.TryParse(TypedItem.SimpleCommodityCategory, true, out category);
}
public bool TryGetTypedCompoundCommodityCategory(out CompoundCommodityCategory category)
{
category = CompoundCommodityCategory.Wearables;
return !string.IsNullOrWhiteSpace(TypedItem?.CompoundCommodityCategory) &&
Enum.TryParse(TypedItem.CompoundCommodityCategory, true, out category);
}
public bool TryGetTypedHardpoint(out HardpointType hardpointType)
{

Binary file not shown.

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