Use typed thermal curves in properties panel
This commit is contained in:
parent
0d286e095a
commit
66c4acf97d
159 changed files with 467 additions and 282 deletions
Binary file not shown.
|
|
@ -393,6 +393,7 @@ internal static class LegacyCatalogReader
|
|||
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) : [],
|
||||
WeaponRange = unionKey == 31 ? GetEnumName(payload, 24, WeaponRanges) : "",
|
||||
WeaponCaliber = unionKey == 31 ? GetEnumName(payload, 25, WeaponCalibers) : "",
|
||||
WeaponType = unionKey == 31 ? GetEnumName(payload, 26, WeaponTypes) : "",
|
||||
|
|
@ -716,6 +717,66 @@ internal static class LegacyCatalogReader
|
|||
};
|
||||
}
|
||||
|
||||
private static AetheriaCurveKey[] ReadCurveKeys(IReadOnlyDictionary<int, object?> payload, int key)
|
||||
{
|
||||
if (!payload.TryGetValue(key, out var value))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return ExtractCurveKeyTuples(value)
|
||||
.Select(tuple => new AetheriaCurveKey
|
||||
{
|
||||
Time = ReadDoubleValue(tuple.ElementAtOrDefault(0)),
|
||||
Value = ReadDoubleValue(tuple.ElementAtOrDefault(1)),
|
||||
InTangent = ReadDoubleValue(tuple.ElementAtOrDefault(2)),
|
||||
OutTangent = ReadDoubleValue(tuple.ElementAtOrDefault(3))
|
||||
})
|
||||
.OrderBy(curveKey => curveKey.Time)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static IEnumerable<object?[]> ExtractCurveKeyTuples(object? value)
|
||||
{
|
||||
if (value is not object?[] values)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
if (LooksLikeCurveKey(values))
|
||||
{
|
||||
return [values];
|
||||
}
|
||||
|
||||
var directKeys = values
|
||||
.OfType<object?[]>()
|
||||
.Where(LooksLikeCurveKey)
|
||||
.ToArray();
|
||||
if (directKeys.Length > 0)
|
||||
{
|
||||
return directKeys;
|
||||
}
|
||||
|
||||
return values
|
||||
.OfType<object?[]>()
|
||||
.SelectMany(ExtractCurveKeyTuples)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static bool LooksLikeCurveKey(object?[] values)
|
||||
{
|
||||
return values.Length >= 4 &&
|
||||
IsNumber(values[0]) &&
|
||||
IsNumber(values[1]) &&
|
||||
IsNumber(values[2]) &&
|
||||
IsNumber(values[3]);
|
||||
}
|
||||
|
||||
private static bool IsNumber(object? value)
|
||||
{
|
||||
return value is byte or sbyte or short or ushort or int or uint or long or ulong or float or double or decimal;
|
||||
}
|
||||
|
||||
private static AetheriaBehaviorPayload[] ReadBehaviorPayloads(IReadOnlyDictionary<int, object?> payload, int key)
|
||||
{
|
||||
if (!payload.TryGetValue(key, out var value) || value is not object?[] behaviors)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
|
|||
item.WeaponFireTypes,
|
||||
item.WeaponModifiers,
|
||||
item.MinimumTemperature,
|
||||
item.MaximumTemperature);
|
||||
item.MaximumTemperature,
|
||||
item.ThermalPerformanceCurveKeys.Select(FromState).ToArray());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeShapeCell FromState(AetheriaShapeCell cell)
|
||||
|
|
@ -53,6 +54,11 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
|
|||
return new AetheriaRuntimeShapeCell(cell.X, cell.Y);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeCurveKey FromState(AetheriaCurveKey key)
|
||||
{
|
||||
return new AetheriaRuntimeCurveKey(key.Time, key.Value, key.InTangent, key.OutTangent);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeBehaviorPayload FromState(AetheriaBehaviorPayload payload)
|
||||
{
|
||||
return new AetheriaRuntimeBehaviorPayload(
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ var maxDurabilityItems = items
|
|||
.ToArray();
|
||||
var durableMaxDurabilityItems = maxDurabilityItems.Count(item => item.Durability > 0);
|
||||
var importedThermalRangeItems = items.Count(item => item.MaximumTemperature > item.MinimumTemperature);
|
||||
var importedThermalCurveItems = items.Count(item => item.ThermalPerformanceCurveKeys.Length > 0);
|
||||
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);
|
||||
|
|
@ -150,6 +151,19 @@ if (importedThermalRangeItems == 0)
|
|||
throw new InvalidOperationException("Typed item definitions did not import any thermal ranges.");
|
||||
}
|
||||
|
||||
if (importedThermalCurveItems == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Typed item definitions did not import any thermal performance curves.");
|
||||
}
|
||||
|
||||
foreach (var item in items.Where(item => item.ThermalPerformanceCurveKeys.Length > 0))
|
||||
{
|
||||
if (item.ThermalPerformanceCurveKeys.Any(key => key.Time < 0 || key.Time > 1))
|
||||
{
|
||||
throw new InvalidOperationException($"Typed thermal performance curve has out-of-range key time for {item.Name}.");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.Where(item => item.Hardpoints.Length > 0))
|
||||
{
|
||||
foreach (var hardpoint in item.Hardpoints)
|
||||
|
|
@ -320,7 +334,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($"Durable hull/weapon items: {durableMaxDurabilityItems}/{maxDurabilityItems.Length}");
|
||||
Console.WriteLine($"Thermal-range items: {importedThermalRangeItems}");
|
||||
Console.WriteLine($"Thermal range/curve items: {importedThermalRangeItems}/{importedThermalCurveItems}");
|
||||
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}");
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public sealed class AetheriaItemDefinition
|
|||
|
||||
[Key(33)]
|
||||
public double MaximumTemperature { get; set; }
|
||||
|
||||
[Key(34)]
|
||||
public AetheriaCurveKey[] ThermalPerformanceCurveKeys { get; set; } = [];
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -160,6 +163,22 @@ public sealed class AetheriaItemHardpoint
|
|||
public double Armor { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaCurveKey
|
||||
{
|
||||
[Key(0)]
|
||||
public double Time { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public double Value { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
public double InTangent { get; set; }
|
||||
|
||||
[Key(3)]
|
||||
public double OutTangent { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaBehaviorPayload
|
||||
{
|
||||
|
|
|
|||
|
|
@ -405,6 +405,43 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return Math.Max(item.Durability, 1f);
|
||||
}
|
||||
|
||||
private static (float minimum, float maximum) GetThermalRange(AetheriaRuntimeCatalogItem typedItem, EquippableItemData legacyData)
|
||||
{
|
||||
if (typedItem != null && typedItem.MaximumTemperature > typedItem.MinimumTemperature)
|
||||
return ((float)typedItem.MinimumTemperature, (float)typedItem.MaximumTemperature);
|
||||
|
||||
if (legacyData != null && legacyData.MaximumTemperature > legacyData.MinimumTemperature)
|
||||
return (legacyData.MinimumTemperature, legacyData.MaximumTemperature);
|
||||
|
||||
return (0f, 1f);
|
||||
}
|
||||
|
||||
private static BezierCurve GetThermalPerformanceCurve(AetheriaRuntimeCatalogItem typedItem, EquippableItemData legacyData)
|
||||
{
|
||||
if (typedItem?.ThermalPerformanceCurveKeys != null && typedItem.ThermalPerformanceCurveKeys.Count > 0)
|
||||
{
|
||||
return new BezierCurve
|
||||
{
|
||||
Keys = typedItem.ThermalPerformanceCurveKeys
|
||||
.Select(key => new float4(
|
||||
(float)key.Time,
|
||||
(float)key.Value,
|
||||
(float)key.InTangent,
|
||||
(float)key.OutTangent))
|
||||
.ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
return legacyData?.HeatPerformanceCurve ?? new BezierCurve
|
||||
{
|
||||
Keys = new[]
|
||||
{
|
||||
new float4(0f, 1f, 0f, 0f),
|
||||
new float4(1f, 1f, 0f, 0f)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeCatalogItem FindTypedPropertyItem(ItemInstance item)
|
||||
{
|
||||
var itemId = item?.Data?.ItemId ?? Guid.Empty;
|
||||
|
|
@ -502,7 +539,10 @@ public class PropertiesPanel : MonoBehaviour
|
|||
OnPropertyAdded?.Invoke(weaponGroups.gameObject);
|
||||
}
|
||||
|
||||
var typedItem = FindTypedPropertyItem(item.EquippableItem);
|
||||
var gearData = GameManager.ItemManager.GetData(item.EquippableItem);
|
||||
var thermalRange = GetThermalRange(typedItem, gearData);
|
||||
var thermalCurve = GetThermalPerformanceCurve(typedItem, gearData);
|
||||
var statusSheet = AddStatSheet();
|
||||
if (item.EquippableItem.Durability < .01f)
|
||||
statusSheet.AddStat("Durability", () => "Item Destroyed!");
|
||||
|
|
@ -511,11 +551,11 @@ public class PropertiesPanel : MonoBehaviour
|
|||
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
gearData.HeatPerformanceCurve,
|
||||
t => ActionGameManager.RuntimePlayerSettings.FormatTemperature(lerp(gearData.MinimumTemperature, gearData.MaximumTemperature, t)),
|
||||
"Thermal Performance",
|
||||
thermalCurve,
|
||||
t => ActionGameManager.RuntimePlayerSettings.FormatTemperature(lerp(thermalRange.minimum, thermalRange.maximum, t)),
|
||||
true);
|
||||
RefreshPropertyValues += () => heatCurve.SetCurrent(unlerp(gearData.MinimumTemperature, gearData.MaximumTemperature, item.Temperature));
|
||||
RefreshPropertyValues += () => heatCurve.SetCurrent(unlerp(thermalRange.minimum, thermalRange.maximum, item.Temperature));
|
||||
AddEquippableItemProperties(item.EquippableItem, item.Evaluate);
|
||||
AddSpacer();
|
||||
|
||||
|
|
@ -546,14 +586,17 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
Title.text = GetTitle(gear);
|
||||
AddSpacer();
|
||||
var typedItem = FindTypedPropertyItem(gear);
|
||||
var gearData = GameManager.ItemManager.GetData(gear);
|
||||
var thermalRange = GetThermalRange(typedItem, gearData);
|
||||
var thermalCurve = GetThermalPerformanceCurve(typedItem, gearData);
|
||||
var statusSheet = AddStatSheet();
|
||||
statusSheet.AddStat("Durability", () => $"{(int)(gear.Durability / GetMaxDurability(gear) * 100)}%");
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
gearData.HeatPerformanceCurve,
|
||||
t => ActionGameManager.RuntimePlayerSettings.FormatTemperature(lerp(gearData.MinimumTemperature, gearData.MaximumTemperature, t)),
|
||||
"Thermal Performance",
|
||||
thermalCurve,
|
||||
t => ActionGameManager.RuntimePlayerSettings.FormatTemperature(lerp(thermalRange.minimum, thermalRange.maximum, t)),
|
||||
true);
|
||||
AddEquippableItemProperties(gear, stat => GameManager.ItemManager.Evaluate(stat, gear));
|
||||
}
|
||||
|
|
|
|||
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.
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