Use typed audio stats for equipped items
This commit is contained in:
parent
d55eb38a3a
commit
6707dcaba8
160 changed files with 535 additions and 270 deletions
Binary file not shown.
|
|
@ -415,6 +415,7 @@ 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) : [],
|
||||
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) : [],
|
||||
HullPrefab = unionKey == 3 ? GetString(payload, 24) : "",
|
||||
HullGridOffset = unionKey == 3 ? GetDouble(payload, 26) : 0,
|
||||
HullArmor = unionKey == 3 ? GetDouble(payload, 27) : 0,
|
||||
|
|
@ -773,6 +774,51 @@ internal static class LegacyCatalogReader
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static AetheriaItemAudioStat[] ReadAudioStats(IReadOnlyDictionary<int, object?> payload, int key)
|
||||
{
|
||||
if (!payload.TryGetValue(key, out var value) || value is not object?[] audioStats)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return audioStats
|
||||
.Select(ReadAudioStat)
|
||||
.Where(audioStat => audioStat != null)
|
||||
.Cast<AetheriaItemAudioStat>()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static AetheriaItemAudioStat? ReadAudioStat(object? value)
|
||||
{
|
||||
if (value is not object?[] fields)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new AetheriaItemAudioStat
|
||||
{
|
||||
Parameter = ReadUIntValue(fields.ElementAtOrDefault(0)),
|
||||
Stat = ReadPerformanceStat(fields.ElementAtOrDefault(1))
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaItemPerformanceStat ReadPerformanceStat(object? value)
|
||||
{
|
||||
if (value is not object?[] fields)
|
||||
{
|
||||
return new AetheriaItemPerformanceStat();
|
||||
}
|
||||
|
||||
return new AetheriaItemPerformanceStat
|
||||
{
|
||||
Min = ReadDoubleValue(fields.ElementAtOrDefault(0)),
|
||||
Max = ReadDoubleValue(fields.ElementAtOrDefault(1)),
|
||||
HeatExponentMultiplier = ReadDoubleValue(fields.ElementAtOrDefault(2)),
|
||||
DurabilityExponentMultiplier = ReadDoubleValue(fields.ElementAtOrDefault(3)),
|
||||
QualityExponent = ReadDoubleValue(fields.ElementAtOrDefault(4))
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerable<object?[]> ExtractCurveKeyTuples(object? value)
|
||||
{
|
||||
if (value is not object?[] values)
|
||||
|
|
@ -1049,6 +1095,18 @@ internal static class LegacyCatalogReader
|
|||
};
|
||||
}
|
||||
|
||||
private static uint ReadUIntValue(object? value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
long integerValue when integerValue >= 0 => checked((uint)integerValue),
|
||||
int integerValue when integerValue >= 0 => checked((uint)integerValue),
|
||||
double doubleValue when doubleValue >= 0 => checked((uint)doubleValue),
|
||||
float floatValue when floatValue >= 0 => checked((uint)floatValue),
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
private static double ReadDoubleValue(object? value)
|
||||
{
|
||||
return value switch
|
||||
|
|
|
|||
|
|
@ -58,10 +58,26 @@ internal static class AetheriaRuntimeCatalogSnapshotMapper
|
|||
item.DockingMaxSizeX,
|
||||
item.DockingMaxSizeY,
|
||||
item.ActionBarIcon,
|
||||
item.AudioStats.Select(FromState).ToArray(),
|
||||
item.SimpleCommodityCategory,
|
||||
item.CompoundCommodityCategory);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAudioStat FromState(AetheriaItemAudioStat stat)
|
||||
{
|
||||
return new AetheriaRuntimeAudioStat(stat.Parameter, FromState(stat.Stat));
|
||||
}
|
||||
|
||||
private static AetheriaRuntimePerformanceStat FromState(AetheriaItemPerformanceStat stat)
|
||||
{
|
||||
return new AetheriaRuntimePerformanceStat(
|
||||
stat.Min,
|
||||
stat.Max,
|
||||
stat.HeatExponentMultiplier,
|
||||
stat.DurabilityExponentMultiplier,
|
||||
stat.QualityExponent);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeShapeCell FromState(AetheriaShapeCell cell)
|
||||
{
|
||||
return new AetheriaRuntimeShapeCell(cell.X, cell.Y);
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ var durableMaxDurabilityItems = maxDurabilityItems.Count(item => item.Durability
|
|||
var importedThermalRangeItems = items.Count(item => item.MaximumTemperature > item.MinimumTemperature);
|
||||
var importedThermalCurveItems = items.Count(item => item.ThermalPerformanceCurveKeys.Length > 0);
|
||||
var thermalResilienceItems = items.Count(item => item.ThermalResilience > 0);
|
||||
var audioStatItems = items.Count(item => item.AudioStats.Length > 0);
|
||||
var audioStatCount = items.Sum(item => item.AudioStats.Length);
|
||||
var actionBarIconItems = items.Count(item => !string.IsNullOrWhiteSpace(item.ActionBarIcon));
|
||||
var dockingBayItems = items.Count(item => item.Category == "DockingBayData");
|
||||
var dockingBayMaxSizeItems = items.Count(item =>
|
||||
|
|
@ -393,6 +395,7 @@ Console.WriteLine($"Catalog fingerprint: {quarantine.CatalogFingerprint}");
|
|||
Console.WriteLine($"Item definitions: {items.Length}");
|
||||
Console.WriteLine($"Priced/manufactured/specific-heat/conductive/shaped items: {pricedItems}/{manufacturedItems}/{specificHeatItems}/{conductiveItems}/{shapedItems}");
|
||||
Console.WriteLine($"Thermal resilience items: {thermalResilienceItems}");
|
||||
Console.WriteLine($"Audio stat items/stats: {audioStatItems}/{audioStatCount}");
|
||||
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}");
|
||||
|
|
|
|||
|
|
@ -156,6 +156,9 @@ public sealed class AetheriaItemDefinition
|
|||
|
||||
[Key(47)]
|
||||
public double ThermalResilience { get; set; } = 1;
|
||||
|
||||
[Key(48)]
|
||||
public AetheriaItemAudioStat[] AudioStats { get; set; } = [];
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -218,6 +221,35 @@ public sealed class AetheriaCurveKey
|
|||
public double OutTangent { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaItemAudioStat
|
||||
{
|
||||
[Key(0)]
|
||||
public uint Parameter { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public AetheriaItemPerformanceStat Stat { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaItemPerformanceStat
|
||||
{
|
||||
[Key(0)]
|
||||
public double Min { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public double Max { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
public double HeatExponentMultiplier { get; set; }
|
||||
|
||||
[Key(3)]
|
||||
public double DurabilityExponentMultiplier { get; set; }
|
||||
|
||||
[Key(4)]
|
||||
public double QualityExponent { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaBehaviorPayload
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader
|
|||
equippable.Durability = (float)item.Durability;
|
||||
equippable.ActionBarIcon = item.ActionBarIcon;
|
||||
equippable.ThermalResilience = (float)item.ThermalResilience;
|
||||
equippable.AudioStats = ProjectAudioStats(item).ToList();
|
||||
equippable.Behaviors = ProjectBehaviors(item).ToList();
|
||||
}
|
||||
|
||||
|
|
@ -174,6 +175,27 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static IEnumerable<AudioStat> ProjectAudioStats(AetheriaRuntimeCatalogItem item)
|
||||
{
|
||||
return item.AudioStats.Select(audioStat => new AudioStat
|
||||
{
|
||||
Parameter = audioStat.Parameter,
|
||||
Stat = ProjectPerformanceStat(audioStat.Stat)
|
||||
});
|
||||
}
|
||||
|
||||
private static PerformanceStat ProjectPerformanceStat(AetheriaRuntimePerformanceStat stat)
|
||||
{
|
||||
return new PerformanceStat
|
||||
{
|
||||
Min = (float)stat.Min,
|
||||
Max = (float)stat.Max,
|
||||
HeatExponentMultiplier = (float)stat.HeatExponentMultiplier,
|
||||
DurabilityExponentMultiplier = (float)stat.DurabilityExponentMultiplier,
|
||||
QualityExponent = (float)stat.QualityExponent
|
||||
};
|
||||
}
|
||||
|
||||
private static ItemData CreateItemData(AetheriaRuntimeCatalogItem item)
|
||||
{
|
||||
switch (item.Category)
|
||||
|
|
|
|||
|
|
@ -1286,6 +1286,7 @@ public class EquippedItem
|
|||
public Dictionary<uint, float> AudioParameterValues { get; } = new Dictionary<uint, float>();
|
||||
|
||||
private readonly BezierCurve _thermalPerformanceCurve;
|
||||
private readonly EquippedItemAudioStatBinding[] _audioStats;
|
||||
private float oldTemperature;
|
||||
public float Temperature
|
||||
{
|
||||
|
|
@ -1380,6 +1381,7 @@ public class EquippedItem
|
|||
MaxDurability = RuntimeItem?.Durability > 0 ? (float)RuntimeItem.Durability : Math.Max(item.Durability, 1f);
|
||||
ThermalResilience = RuntimeItem?.ThermalResilience > 0 ? (float)RuntimeItem.ThermalResilience : Data.ThermalResilience;
|
||||
_thermalPerformanceCurve = CreateThermalPerformanceCurve(RuntimeItem);
|
||||
_audioStats = CreateAudioStatBindings(RuntimeItem, Data);
|
||||
ThermalExponent = lerp(
|
||||
ItemManager.GameplaySettings.ThermalQualityMin,
|
||||
ItemManager.GameplaySettings.ThermalQualityMax,
|
||||
|
|
@ -1492,7 +1494,7 @@ public class EquippedItem
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
foreach (var audioStat in Data.AudioStats)
|
||||
foreach (var audioStat in _audioStats)
|
||||
{
|
||||
SetAudioParameter(audioStat.Parameter, Evaluate(audioStat.Stat));
|
||||
}
|
||||
|
|
@ -1520,6 +1522,48 @@ public class EquippedItem
|
|||
return b;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static EquippedItemAudioStatBinding[] CreateAudioStatBindings(
|
||||
AetheriaRuntimeCatalogItem item,
|
||||
EquippableItemData fallback)
|
||||
{
|
||||
if (item?.AudioStats != null)
|
||||
{
|
||||
return item.AudioStats
|
||||
.Select(audioStat => new EquippedItemAudioStatBinding(
|
||||
audioStat.Parameter,
|
||||
CreatePerformanceStat(audioStat.Stat)))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return fallback.AudioStats
|
||||
.Select(audioStat => new EquippedItemAudioStatBinding(audioStat.Parameter, audioStat.Stat))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static PerformanceStat CreatePerformanceStat(AetheriaRuntimePerformanceStat stat)
|
||||
{
|
||||
return new PerformanceStat
|
||||
{
|
||||
Min = (float)stat.Min,
|
||||
Max = (float)stat.Max,
|
||||
HeatExponentMultiplier = (float)stat.HeatExponentMultiplier,
|
||||
DurabilityExponentMultiplier = (float)stat.DurabilityExponentMultiplier,
|
||||
QualityExponent = (float)stat.QualityExponent
|
||||
};
|
||||
}
|
||||
|
||||
private readonly struct EquippedItemAudioStatBinding
|
||||
{
|
||||
public EquippedItemAudioStatBinding(uint parameter, PerformanceStat stat)
|
||||
{
|
||||
Parameter = parameter;
|
||||
Stat = stat;
|
||||
}
|
||||
|
||||
public uint Parameter { get; }
|
||||
public PerformanceStat Stat { get; }
|
||||
}
|
||||
}
|
||||
|
||||
public class EquippedCargoBay : EquippedItem
|
||||
|
|
|
|||
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