Use typed hull facets in entity state
This commit is contained in:
parent
f85033b6c6
commit
710a98bc8d
160 changed files with 413 additions and 308 deletions
Binary file not shown.
|
|
@ -388,6 +388,7 @@ internal static class LegacyCatalogReader
|
|||
Description = description,
|
||||
Mass = GetDouble(payload, 4),
|
||||
SpecificHeat = GetPositiveDoubleOrDefault(payload, 6, 1),
|
||||
Conductivity = GetPositiveDoubleOrDefault(payload, 7, 1),
|
||||
Volume = shape.OccupiedCells,
|
||||
ManufacturerLegacyId = GetOptionalGuid(payload, 3),
|
||||
Price = GetInt(payload, 8),
|
||||
|
|
@ -413,6 +414,10 @@ 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) : "",
|
||||
HullGridOffset = unionKey == 3 ? GetDouble(payload, 26) : 0,
|
||||
HullArmor = unionKey == 3 ? GetDouble(payload, 27) : 0,
|
||||
HullDrag = unionKey == 3 ? GetDouble(payload, 28) : 0,
|
||||
HullCanTow = unionKey == 3 && GetBool(payload, 29),
|
||||
SimpleCommodityCategory = unionKey == 0 ? GetEnumName(payload, 10, SimpleCommodityCategories) : "",
|
||||
CompoundCommodityCategory = unionKey == 1 ? GetEnumName(payload, 11, CompoundCommodityCategories) : "",
|
||||
WeaponRange = unionKey == 31 ? GetEnumName(payload, 24, WeaponRanges) : "",
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
|
|||
item.Price,
|
||||
item.Mass,
|
||||
item.SpecificHeat,
|
||||
item.Conductivity,
|
||||
item.Volume,
|
||||
item.ShapeWidth,
|
||||
item.ShapeHeight,
|
||||
|
|
@ -49,6 +50,10 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
|
|||
item.MaximumTemperature,
|
||||
item.ThermalPerformanceCurveKeys.Select(FromState).ToArray(),
|
||||
item.HullPrefab,
|
||||
item.HullGridOffset,
|
||||
item.HullArmor,
|
||||
item.HullDrag,
|
||||
item.HullCanTow,
|
||||
item.SimpleCommodityCategory,
|
||||
item.CompoundCommodityCategory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ if (nameFiles.Any(nameFile => nameFile.Names.Length == 0 || nameFile.Names.Lengt
|
|||
var pricedItems = items.Count(item => item.Price > 0);
|
||||
var manufacturedItems = items.Count(item => !string.IsNullOrWhiteSpace(item.ManufacturerLegacyId));
|
||||
var specificHeatItems = items.Count(item => item.SpecificHeat > 0);
|
||||
var conductiveItems = items.Count(item => item.Conductivity > 0);
|
||||
var shapedItems = items.Count(item => item.ShapeWidth > 0 && item.ShapeHeight > 0 && item.OccupiedCells > 0);
|
||||
var shapedMaskItems = items.Count(item => item.ShapeCells.Length > 0);
|
||||
var interiorShapeItems = items.Count(item => item.InteriorShapeCells.Length > 0);
|
||||
|
|
@ -64,6 +65,12 @@ 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 hullArmorItems = items.Count(item => !string.IsNullOrWhiteSpace(item.HullType) && item.HullArmor > 0);
|
||||
var hullPhysicalFacetItems = items.Count(item =>
|
||||
!string.IsNullOrWhiteSpace(item.HullType) &&
|
||||
item.HullArmor > 0 &&
|
||||
item.HullDrag >= 0 &&
|
||||
!double.IsNaN(item.HullGridOffset));
|
||||
var simpleCommodityCategoryItems = items.Count(item => !string.IsNullOrWhiteSpace(item.SimpleCommodityCategory));
|
||||
var compoundCommodityCategoryItems = items.Count(item => !string.IsNullOrWhiteSpace(item.CompoundCommodityCategory));
|
||||
var weaponItems = items.Count(item =>
|
||||
|
|
@ -96,6 +103,12 @@ if (specificHeatItems != items.Length)
|
|||
$"Typed item definitions did not import positive specific heat for every item: {specificHeatItems}/{items.Length}.");
|
||||
}
|
||||
|
||||
if (conductiveItems != items.Length)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Typed item definitions did not import positive conductivity for every item: {conductiveItems}/{items.Length}.");
|
||||
}
|
||||
|
||||
if (shapedItems == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Typed item definitions did not import any shape dimensions.");
|
||||
|
|
@ -243,6 +256,12 @@ if (hullPrefabItems != hullItems)
|
|||
throw new InvalidOperationException($"Typed hull prefab import mismatch: hulls={hullItems}, prefabs={hullPrefabItems}.");
|
||||
}
|
||||
|
||||
if (hullArmorItems != hullItems || hullPhysicalFacetItems != hullItems)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Typed hull physical facet import mismatch: hulls={hullItems}, armor={hullArmorItems}, physical={hullPhysicalFacetItems}.");
|
||||
}
|
||||
|
||||
if (simpleCommodityCategoryItems == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Typed simple commodity category import produced no categories.");
|
||||
|
|
@ -353,12 +372,13 @@ if (string.IsNullOrWhiteSpace(quarantine.CatalogFingerprint))
|
|||
Console.WriteLine($"Aetheria typed state verify passed: {statePath}");
|
||||
Console.WriteLine($"Catalog fingerprint: {quarantine.CatalogFingerprint}");
|
||||
Console.WriteLine($"Item definitions: {items.Length}");
|
||||
Console.WriteLine($"Priced/manufactured/specific-heat/shaped items: {pricedItems}/{manufacturedItems}/{specificHeatItems}/{shapedItems}");
|
||||
Console.WriteLine($"Priced/manufactured/specific-heat/conductive/shaped items: {pricedItems}/{manufacturedItems}/{specificHeatItems}/{conductiveItems}/{shapedItems}");
|
||||
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($"Hull armor/physical facet items: {hullArmorItems}/{hullPhysicalFacetItems}");
|
||||
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}");
|
||||
|
|
|
|||
|
|
@ -129,6 +129,21 @@ public sealed class AetheriaItemDefinition
|
|||
|
||||
[Key(38)]
|
||||
public double SpecificHeat { get; set; } = 1;
|
||||
|
||||
[Key(39)]
|
||||
public double Conductivity { get; set; } = 1;
|
||||
|
||||
[Key(40)]
|
||||
public double HullGridOffset { get; set; }
|
||||
|
||||
[Key(41)]
|
||||
public double HullArmor { get; set; }
|
||||
|
||||
[Key(42)]
|
||||
public double HullDrag { get; set; }
|
||||
|
||||
[Key(43)]
|
||||
public bool HullCanTow { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader
|
|||
projected.Manufacturer = ParseGuid(item.ManufacturerLegacyId);
|
||||
projected.Mass = (float)item.Mass;
|
||||
projected.SpecificHeat = (float)item.SpecificHeat;
|
||||
projected.Conductivity = (float)item.Conductivity;
|
||||
projected.Shape = ProjectShape(item.ShapeWidth, item.ShapeHeight, item.ShapeCells);
|
||||
projected.Price = item.Price;
|
||||
|
||||
|
|
@ -143,6 +144,10 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader
|
|||
{
|
||||
hull.HullType = ParseEnum(item.HullType, HullType.Ship);
|
||||
hull.Hardpoints = item.Hardpoints.Select(ProjectHardpoint).ToList();
|
||||
hull.GridOffset = (float)item.HullGridOffset;
|
||||
hull.Armor = (float)item.HullArmor;
|
||||
hull.Drag = (float)item.HullDrag;
|
||||
hull.CanTow = item.HullCanTow;
|
||||
}
|
||||
|
||||
return projected;
|
||||
|
|
|
|||
|
|
@ -339,39 +339,44 @@ public abstract class Entity
|
|||
|
||||
private void MapEntity()
|
||||
{
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
var typedHull = ItemManager.GetRuntimeItem(Hull);
|
||||
if (typedHull == null)
|
||||
throw new InvalidOperationException($"Unable to map entity {Name}: missing typed hull row for {Hull?.Data?.ItemId}");
|
||||
|
||||
var hullShape = GetHullShape(typedHull);
|
||||
EquippedHull = new EquippedItem(ItemManager, Hull, int2.zero, this);
|
||||
Equipment.Add(EquippedHull);
|
||||
Mass = hullData.Mass;
|
||||
Temperature = new float[hullData.Shape.Width, hullData.Shape.Height];
|
||||
NewTemperature = new float[hullData.Shape.Width, hullData.Shape.Height];
|
||||
HullConductivity = new bool2[hullData.Shape.Width,hullData.Shape.Height];
|
||||
ThermalMass = new float[hullData.Shape.Width, hullData.Shape.Height];
|
||||
Armor = new float[hullData.Shape.Width, hullData.Shape.Height];
|
||||
MaxArmor = new float[hullData.Shape.Width, hullData.Shape.Height];
|
||||
Hardpoints = new HardpointData[hullData.Shape.Width, hullData.Shape.Height];
|
||||
foreach (var hardpoint in hullData.Hardpoints)
|
||||
Mass = ItemManager.GetMass(Hull);
|
||||
Temperature = new float[hullShape.Width, hullShape.Height];
|
||||
NewTemperature = new float[hullShape.Width, hullShape.Height];
|
||||
HullConductivity = new bool2[hullShape.Width, hullShape.Height];
|
||||
ThermalMass = new float[hullShape.Width, hullShape.Height];
|
||||
Armor = new float[hullShape.Width, hullShape.Height];
|
||||
MaxArmor = new float[hullShape.Width, hullShape.Height];
|
||||
Hardpoints = new HardpointData[hullShape.Width, hullShape.Height];
|
||||
foreach (var typedHardpoint in typedHull.Hardpoints)
|
||||
{
|
||||
var hardpoint = ProjectHardpoint(typedHardpoint);
|
||||
foreach (var hardpointCoord in hardpoint.Shape.Coordinates)
|
||||
{
|
||||
var hullCoord = hardpoint.Position + hardpointCoord;
|
||||
Hardpoints[hullCoord.x, hullCoord.y] = hardpoint;
|
||||
}
|
||||
}
|
||||
var cellCount = hullData.Shape.Coordinates.Length;
|
||||
foreach (var v in hullData.Shape.Coordinates)
|
||||
var cellCount = Math.Max(hullShape.Coordinates.Length, 1);
|
||||
foreach (var v in hullShape.Coordinates)
|
||||
{
|
||||
Armor[v.x, v.y] = hullData.Armor;
|
||||
MaxArmor[v.x, v.y] = hullData.Armor;
|
||||
Armor[v.x, v.y] = (float)typedHull.HullArmor;
|
||||
MaxArmor[v.x, v.y] = (float)typedHull.HullArmor;
|
||||
if (Hardpoints[v.x, v.y] != null)
|
||||
{
|
||||
Armor[v.x, v.y] += Hardpoints[v.x, v.y].Armor;
|
||||
MaxArmor[v.x, v.y] += Hardpoints[v.x, v.y].Armor;
|
||||
}
|
||||
Temperature[v.x, v.y] = 280;
|
||||
ThermalMass[v.x, v.y] = hullData.Mass * hullData.SpecificHeat / cellCount;
|
||||
ThermalMass[v.x, v.y] = (float)(typedHull.Mass * typedHull.SpecificHeat / cellCount);
|
||||
}
|
||||
GearOccupancy = new EquippedItem[hullData.Shape.Width, hullData.Shape.Height];
|
||||
GearOccupancy = new EquippedItem[hullShape.Width, hullShape.Height];
|
||||
}
|
||||
|
||||
public void GenerateWeaponGroups()
|
||||
|
|
@ -417,10 +422,13 @@ public abstract class Entity
|
|||
{
|
||||
get
|
||||
{
|
||||
var emptyShape = new Shape(HullData.Shape.Width, HullData.Shape.Height);
|
||||
foreach (var v in HullData.Shape.Coordinates)
|
||||
var typedHull = ItemManager.GetRuntimeItem(Hull);
|
||||
var hullShape = GetHullShape(typedHull);
|
||||
var hullInterior = GetHullInteriorShape(typedHull);
|
||||
var emptyShape = new Shape(hullShape.Width, hullShape.Height);
|
||||
foreach (var v in hullShape.Coordinates)
|
||||
{
|
||||
if (HullData.InteriorCells[v] && GearOccupancy[v.x, v.y] == null && Hardpoints[v.x,v.y] == null)
|
||||
if (hullInterior[v] && GearOccupancy[v.x, v.y] == null && Hardpoints[v.x, v.y] == null)
|
||||
emptyShape[v] = true;
|
||||
}
|
||||
|
||||
|
|
@ -580,6 +588,19 @@ public abstract class Entity
|
|||
: ItemRotation.None;
|
||||
}
|
||||
|
||||
private static HardpointData ProjectHardpoint(AetheriaRuntimeHardpoint hardpoint)
|
||||
{
|
||||
return new HardpointData
|
||||
{
|
||||
Type = GetHardpointType(hardpoint, HardpointType.Hull),
|
||||
Position = new int2(hardpoint.PositionX, hardpoint.PositionY),
|
||||
Shape = ToShape(hardpoint.ShapeWidth, hardpoint.ShapeHeight, hardpoint.ShapeCells),
|
||||
Transform = hardpoint.Transform,
|
||||
Rotation = GetRotation(hardpoint),
|
||||
Armor = (float)hardpoint.Armor
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsCargoBay(AetheriaRuntimeCatalogItem typedItem)
|
||||
{
|
||||
return typedItem != null &&
|
||||
|
|
@ -986,8 +1007,6 @@ public abstract class Entity
|
|||
|
||||
public virtual void Update(float delta)
|
||||
{
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
|
||||
TargetRange = Target.Value == null ? -1 : length(Position - Target.Value.Position);
|
||||
|
||||
var localSecurityLevel = Zone.GetSecurityLevel(Position.xz);
|
||||
|
|
@ -1084,61 +1103,64 @@ public abstract class Entity
|
|||
Position = Parent.Position;
|
||||
Velocity = Parent.Velocity;
|
||||
}
|
||||
else Position.y = Zone.GetHeight(Position.xz) + hullData.GridOffset;
|
||||
else Position.y = Zone.GetHeight(Position.xz) + (float)(ItemManager.GetRuntimeItem(Hull)?.HullGridOffset ?? 0);
|
||||
}
|
||||
|
||||
private void UpdateTemperature(float delta)
|
||||
{
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
var typedHull = ItemManager.GetRuntimeItem(Hull);
|
||||
var hullShape = GetHullShape(typedHull);
|
||||
var hullInterior = GetHullInteriorShape(typedHull);
|
||||
var hullConductivity = (float)(typedHull?.Conductivity ?? 1);
|
||||
|
||||
MaxTemp = Single.MinValue;
|
||||
MinTemp = Single.MaxValue;
|
||||
|
||||
//float[,] newTemp = new float[hullData.Shape.Width,hullData.Shape.Height];
|
||||
//float[,] newTemp = new float[hullShape.Width,hullShape.Height];
|
||||
var radiation = 0f;
|
||||
foreach (var v in hullData.Shape.Coordinates)
|
||||
foreach (var v in hullShape.Coordinates)
|
||||
{
|
||||
var temp = Temperature[v.x, v.y];
|
||||
var totalTemp = temp / ItemManager.GameplaySettings.HeatConductionMultiplier;
|
||||
var totalConductivity = 1f / ItemManager.GameplaySettings.HeatConductionMultiplier;
|
||||
|
||||
if (hullData.Shape[int2(v.x - 1, v.y)])
|
||||
if (hullShape[int2(v.x - 1, v.y)])
|
||||
{
|
||||
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
|
||||
(GearOccupancy[v.x - 1, v.y]?.Conductivity ?? 1) *
|
||||
(HullConductivity[v.x - 1, v.y].x ? hullData.Conductivity : 1 / hullData.Conductivity) *
|
||||
(HullConductivity[v.x - 1, v.y].x ? hullConductivity : 1 / hullConductivity) *
|
||||
(ThermalMass[v.x - 1, v.y] / ThermalMass[v.x, v.y]);
|
||||
totalConductivity += conductivity;
|
||||
totalTemp += Temperature[v.x - 1, v.y] * conductivity;
|
||||
}
|
||||
|
||||
if (hullData.Shape[int2(v.x + 1, v.y)])
|
||||
if (hullShape[int2(v.x + 1, v.y)])
|
||||
{
|
||||
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
|
||||
(GearOccupancy[v.x + 1, v.y]?.Conductivity ?? 1) *
|
||||
(HullConductivity[v.x, v.y].x ? hullData.Conductivity : 1 / hullData.Conductivity) *
|
||||
(HullConductivity[v.x, v.y].x ? hullConductivity : 1 / hullConductivity) *
|
||||
(ThermalMass[v.x + 1, v.y] / ThermalMass[v.x, v.y]);
|
||||
totalConductivity += conductivity;
|
||||
totalTemp += Temperature[v.x + 1, v.y] * conductivity;
|
||||
}
|
||||
|
||||
|
||||
if (hullData.Shape[int2(v.x, v.y - 1)])
|
||||
if (hullShape[int2(v.x, v.y - 1)])
|
||||
{
|
||||
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
|
||||
(GearOccupancy[v.x, v.y - 1]?.Conductivity ?? 1) *
|
||||
(HullConductivity[v.x, v.y - 1].y ? hullData.Conductivity : 1 / hullData.Conductivity) *
|
||||
(HullConductivity[v.x, v.y - 1].y ? hullConductivity : 1 / hullConductivity) *
|
||||
(ThermalMass[v.x, v.y - 1] / ThermalMass[v.x, v.y]);
|
||||
totalConductivity += conductivity;
|
||||
totalTemp += Temperature[v.x, v.y - 1] * conductivity;
|
||||
}
|
||||
|
||||
|
||||
if (hullData.Shape[int2(v.x, v.y + 1)])
|
||||
if (hullShape[int2(v.x, v.y + 1)])
|
||||
{
|
||||
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
|
||||
(GearOccupancy[v.x, v.y + 1]?.Conductivity ?? 1) *
|
||||
(HullConductivity[v.x, v.y].y ? hullData.Conductivity : 1 / hullData.Conductivity) *
|
||||
(HullConductivity[v.x, v.y].y ? hullConductivity : 1 / hullConductivity) *
|
||||
(ThermalMass[v.x, v.y + 1] / ThermalMass[v.x, v.y]);
|
||||
totalConductivity += conductivity;
|
||||
totalTemp += Temperature[v.x, v.y + 1] * conductivity;
|
||||
|
|
@ -1148,7 +1170,7 @@ public abstract class Entity
|
|||
|
||||
var r = 0f;
|
||||
// For all cells on the border of the entity, radiate some heat into space, increasing the visibility of the ship
|
||||
if (Parent==null && !hullData.InteriorCells[v])
|
||||
if (Parent==null && !hullInterior[v])
|
||||
{
|
||||
var rad = pow(NewTemperature[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) *
|
||||
ItemManager.GameplaySettings.HeatRadiationMultiplier;
|
||||
|
|
|
|||
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