Use typed hull prefabs in zone renderer

This commit is contained in:
Meta Vens 2026-06-14 03:31:08 +01:00
commit 46793a5a2f
159 changed files with 305 additions and 276 deletions

Binary file not shown.

View file

@ -394,6 +394,7 @@ internal static class LegacyCatalogReader
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) : [],
HullPrefab = unionKey == 3 ? GetString(payload, 24) : "",
WeaponRange = unionKey == 31 ? GetEnumName(payload, 24, WeaponRanges) : "",
WeaponCaliber = unionKey == 31 ? GetEnumName(payload, 25, WeaponCalibers) : "",
WeaponType = unionKey == 31 ? GetEnumName(payload, 26, WeaponTypes) : "",

View file

@ -46,7 +46,8 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
item.WeaponModifiers,
item.MinimumTemperature,
item.MaximumTemperature,
item.ThermalPerformanceCurveKeys.Select(FromState).ToArray());
item.ThermalPerformanceCurveKeys.Select(FromState).ToArray(),
item.HullPrefab);
}
private static AetheriaRuntimeShapeCell FromState(AetheriaShapeCell cell)

View file

@ -62,6 +62,7 @@ var behaviorLegacyRefCount = items
.Count(field => ContainsBehaviorValueKind(field.Value, "legacy-id"));
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 weaponItems = items.Count(item =>
!string.IsNullOrWhiteSpace(item.WeaponType) &&
!string.IsNullOrWhiteSpace(item.WeaponRange) &&
@ -228,6 +229,11 @@ if (hullItems == 0)
throw new InvalidOperationException("Typed item definitions did not import any hull types.");
}
if (hullPrefabItems != hullItems)
{
throw new InvalidOperationException($"Typed hull prefab import mismatch: hulls={hullItems}, prefabs={hullPrefabItems}.");
}
if (weaponItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any weapon facets.");
@ -333,6 +339,7 @@ Console.WriteLine($"Shape masks: {shapedMaskItems}");
Console.WriteLine($"Interior masks/hardpoint hosts/hardpoints: {interiorShapeItems}/{hardpointHostItems}/{hardpointCount}");
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($"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

@ -117,6 +117,9 @@ public sealed class AetheriaItemDefinition
[Key(34)]
public AetheriaCurveKey[] ThermalPerformanceCurveKeys { get; set; } = [];
[Key(35)]
public string HullPrefab { get; set; } = "";
}
[MessagePackObject]

View file

@ -287,26 +287,32 @@ public class ZoneRenderer : MonoBehaviour
void LoadEntity(Entity entity)
{
var hullData = ItemManager.GetData(entity.Hull) as HullData;
var typedHull = FindTypedZoneItem(entity.Hull);
if (typedHull == null || string.IsNullOrWhiteSpace(typedHull.HullPrefab))
{
ItemManager.Log($"Failed to instantiate {entity.Name} with missing typed hull prefab.");
return;
}
EntityInstance instance;
if (entity is Ship)
{
instance = Instantiate(UnityHelpers.LoadAsset<GameObject>(hullData.Prefab), ZoneRoot).GetComponent<ShipInstance>();
instance = Instantiate(UnityHelpers.LoadAsset<GameObject>(typedHull.HullPrefab), ZoneRoot).GetComponent<ShipInstance>();
if (instance == null)
{
ItemManager.Log($"Failed to instantiate {hullData.Name} ship with invalid prefab: no ShipInstance component!");
ItemManager.Log($"Failed to instantiate {typedHull.Name} ship with invalid prefab: no ShipInstance component!");
return;
}
}
else
{
instance = Instantiate(UnityHelpers.LoadAsset<GameObject>(hullData.Prefab), ZoneRoot).GetComponent<EntityInstance>();
instance = Instantiate(UnityHelpers.LoadAsset<GameObject>(typedHull.HullPrefab), ZoneRoot).GetComponent<EntityInstance>();
if (instance == null)
{
ItemManager.Log($"Failed to instantiate {hullData.Name} entity with invalid prefab: no EntityInstance component!");
ItemManager.Log($"Failed to instantiate {typedHull.Name} entity with invalid prefab: no EntityInstance component!");
return;
}
if (entity.HullData.HullType == HullType.Station)
if (string.Equals(typedHull.HullType, nameof(HullType.Station), StringComparison.Ordinal))
{
instance.CompassIcon = CompassIconPrototype.Instantiate<CompassIcon>();
instance.CompassIcon.Icon.sprite = OrbitalIcon;
@ -569,7 +575,7 @@ public class ZoneRenderer : MonoBehaviour
public void DropItem(Vector3 position, Vector3 velocity, ItemInstance item)
{
var typedItem = FindTypedPickupItem(item);
var typedItem = FindTypedZoneItem(item);
var gridObject = item switch
{
SimpleCommodity _ => Instantiate(SimpleCommodityPickup),
@ -603,7 +609,7 @@ public class ZoneRenderer : MonoBehaviour
return typedItem != null && string.Equals(typedItem.Category, nameof(WeaponItemData), StringComparison.Ordinal);
}
private static AetheriaRuntimeCatalogItem FindTypedPickupItem(ItemInstance item)
private static AetheriaRuntimeCatalogItem FindTypedZoneItem(ItemInstance item)
{
var itemId = item?.Data?.ItemId ?? Guid.Empty;
return itemId == Guid.Empty

Binary file not shown.

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