Use typed metadata for properties behavior stats

This commit is contained in:
Meta Vens 2026-06-14 10:12:32 +01:00
commit 3e616ae988
6 changed files with 156 additions and 34 deletions

Binary file not shown.

View file

@ -11,6 +11,7 @@
<Compile Include="..\Packages\org.gamecult.eve.surface\Runtime\EveSurfaceDocument.cs" Link="EveSurfaceDocument.cs" />
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeCatalogSnapshot.cs" Link="AetheriaRuntimeCatalogSnapshot.cs" />
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeCatalogStore.cs" Link="AetheriaRuntimeCatalogStore.cs" />
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeBehaviorMetadata.cs" Link="AetheriaRuntimeBehaviorMetadata.cs" />
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeBehaviorKinds.cs" Link="AetheriaRuntimeBehaviorKinds.cs" />
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeItemCategories.cs" Link="AetheriaRuntimeItemCategories.cs" />
<Compile Include="..\Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeEveCommandLog.cs" Link="AetheriaRuntimeEveCommandLog.cs" />

View file

@ -7,7 +7,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using GameCult.Aetheria.State.Unity;
using TMPro;
using UniRx;
@ -449,23 +448,22 @@ public class PropertiesPanel : MonoBehaviour
}
else
{
var type = ResolveBehaviorType(behavior.Kind);
if (type == null || type.GetCustomAttribute(typeof(RuntimeInspectable)) == null) continue;
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
var metadata = AetheriaRuntimeBehaviorMetadataCatalog.Get(behavior.Kind);
if (metadata == null) continue;
foreach (var field in metadata.DisplayFields)
{
var fieldType = field.FieldType;
var payloadField = FindTypedBehaviorField(behavior, field.GetCustomAttribute<LegacyPayloadKeyAttribute>()?.Key);
if (fieldType == typeof(float))
var payloadField = FindTypedBehaviorField(behavior, field.Key);
if (field.ValueKind == AetheriaRuntimeBehaviorFieldValueKind.Number)
{
var value = (float)(payloadField?.Value.NumberValue ?? 0);
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.RuntimePlayerSettings.Format(value)}");
}
else if (fieldType == typeof(int))
else if (field.ValueKind == AetheriaRuntimeBehaviorFieldValueKind.Integer)
{
var value = (int)(payloadField?.Value.NumberValue ?? 0);
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{value}");
}
else if (fieldType == typeof(PerformanceStat))
else if (field.ValueKind == AetheriaRuntimeBehaviorFieldValueKind.PerformanceStat)
{
var stat = ReadTypedPerformanceStat(payloadField?.Value);
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.RuntimePlayerSettings.Format(statValueFunction(stat))}");
@ -561,21 +559,6 @@ public class PropertiesPanel : MonoBehaviour
: fallback;
}
private static Type ResolveBehaviorType(string kind)
{
return string.IsNullOrWhiteSpace(kind)
? null
: BehaviorTypesByName.TryGetValue(kind, out var type)
? type
: null;
}
private static readonly IReadOnlyDictionary<string, Type> BehaviorTypesByName = typeof(BehaviorData)
.GetAllChildClasses()
.Where(type => !string.IsNullOrWhiteSpace(type.Name))
.GroupBy(type => type.Name)
.ToDictionary(group => group.Key, group => group.First(), StringComparer.Ordinal);
private string GetTitle(EquippableItem item)
{
var typedItem = FindTypedPropertyItem(item);

View file

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace GameCult.Aetheria.State.Unity
{
public enum AetheriaRuntimeBehaviorFieldValueKind
{
Number,
Integer,
PerformanceStat
}
public sealed class AetheriaRuntimeBehaviorFieldMetadata
{
public AetheriaRuntimeBehaviorFieldMetadata(string name, int key, AetheriaRuntimeBehaviorFieldValueKind valueKind)
{
Name = name ?? "";
Key = key;
ValueKind = valueKind;
}
public string Name { get; }
public int Key { get; }
public AetheriaRuntimeBehaviorFieldValueKind ValueKind { get; }
}
public sealed class AetheriaRuntimeBehaviorMetadata
{
public AetheriaRuntimeBehaviorMetadata(
string kind,
string parentKind,
IReadOnlyList<AetheriaRuntimeBehaviorFieldMetadata> displayFields)
{
Kind = kind ?? "";
ParentKind = parentKind ?? "";
DisplayFields = displayFields ?? Array.Empty<AetheriaRuntimeBehaviorFieldMetadata>();
}
public string Kind { get; }
public string ParentKind { get; }
public IReadOnlyList<AetheriaRuntimeBehaviorFieldMetadata> DisplayFields { get; }
}
public static class AetheriaRuntimeBehaviorMetadataCatalog
{
private static readonly AetheriaRuntimeBehaviorFieldMetadata[] WeaponFields =
{
Stat("Damage", 2),
Stat("Penetration", 3),
Stat("Energy", 9),
Stat("Heat", 10),
Stat("Visibility", 11)
};
private static readonly AetheriaRuntimeBehaviorFieldMetadata[] InstantWeaponFields =
With(WeaponFields, Stat("Cooldown", 19));
private static readonly AetheriaRuntimeBehaviorFieldMetadata[] LockWeaponFields =
With(InstantWeaponFields, Stat("LockSpeed", 21), Stat("LockAngle", 23));
private static readonly IReadOnlyDictionary<string, AetheriaRuntimeBehaviorMetadata> ByKind =
new[]
{
Behavior("AetherDrive", "", Stat("MaximumRpm", 3), Stat("CouplingEfficiency", 6), Stat("Torque", 7), Stat("EnergyDraw", 9), Stat("PassiveCoupling", 10)),
Behavior("Capacitor", "", Stat("Capacity", 1), Stat("Efficiency", 2)),
Behavior("ChargedWeapon", AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields, Stat("ChargeTime", 21), Stat("ChargeEnergy", 22), Stat("ChargeHeat", 23))),
Behavior("ConstantWeapon", "Weapon", WeaponFields),
Behavior(AetheriaRuntimeBehaviorKinds.GuidedWeapon, AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields, Stat("MissileVelocity", 26))),
Behavior(AetheriaRuntimeBehaviorKinds.Launcher, "LockWeapon", With(LockWeaponFields, Stat("MissileVelocity", 31))),
Behavior("LockWeapon", AetheriaRuntimeBehaviorKinds.InstantWeapon, LockWeaponFields),
Behavior(AetheriaRuntimeBehaviorKinds.InstantWeapon, "Weapon", InstantWeaponFields),
Behavior(AetheriaRuntimeBehaviorKinds.AutoWeapon, AetheriaRuntimeBehaviorKinds.InstantWeapon, InstantWeaponFields),
Behavior("Cooldown", "", Stat("Cooldown", 1)),
Behavior("EnergyDraw", "", Stat("EnergyDraw", 1)),
Behavior("Radiator", "", Stat("Emissivity", 1), Stat("PumpedHeat", 2), Number("TemperatureFloor", 3), Stat("WasteHeat", 4), Stat("EnergyUsage", 5), Stat("ThermalMass", 6)),
Behavior("Reactor", "", Stat("Charge", 1), Stat("Efficiency", 2), Stat("OverloadEfficiency", 3), Stat("ThrottlingFactor", 4)),
Behavior("Reflector", "", Stat("CrossSection", 1)),
Behavior("ResourceScanner", "", Stat("Range", 1), Stat("MinimumDensity", 2), Stat("ScanDuration", 3)),
Behavior("Sensor", "", Stat("Sensitivity", 3), Stat("PingBoost", 5), Stat("PingEnergy", 6), Stat("PingVisibility", 7), Stat("PingRange", 8), Stat("PingCooldown", 9)),
Behavior("Shield", "", Stat("Efficiency", 1), Stat("EnergyUsage", 2)),
Behavior("Thruster", "", Stat("Thrust", 1), Stat("Visibility", 2), Stat("Heat", 3), Stat("EnergyUsage", 4)),
Behavior("VelocityConversion", "", Stat("Lambda", 1)),
Behavior("VelocityLimit", "", Stat("TopSpeed", 1)),
Behavior("Visibility", "", Stat("Visibility", 1))
}
.ToDictionary(metadata => metadata.Kind, StringComparer.Ordinal);
public static AetheriaRuntimeBehaviorMetadata Get(string kind)
{
return !string.IsNullOrWhiteSpace(kind) && ByKind.TryGetValue(kind, out var metadata)
? metadata
: null!;
}
public static IReadOnlyList<AetheriaRuntimeBehaviorMetadata> All => ByKind.Values.ToArray();
private static AetheriaRuntimeBehaviorMetadata Behavior(
string kind,
string parentKind,
params AetheriaRuntimeBehaviorFieldMetadata[] displayFields)
{
return new AetheriaRuntimeBehaviorMetadata(kind, parentKind, displayFields);
}
private static AetheriaRuntimeBehaviorFieldMetadata Stat(string name, int key)
{
return new AetheriaRuntimeBehaviorFieldMetadata(name, key, AetheriaRuntimeBehaviorFieldValueKind.PerformanceStat);
}
private static AetheriaRuntimeBehaviorFieldMetadata Number(string name, int key)
{
return new AetheriaRuntimeBehaviorFieldMetadata(name, key, AetheriaRuntimeBehaviorFieldValueKind.Number);
}
private static AetheriaRuntimeBehaviorFieldMetadata[] With(
AetheriaRuntimeBehaviorFieldMetadata[] baseFields,
params AetheriaRuntimeBehaviorFieldMetadata[] extraFields)
{
return baseFields.Concat(extraFields).ToArray();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a6d7af26b164b8fa8629e2b8efbe9c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -167,8 +167,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
commodity subtype, hull ownership, and behavior-kind filters read typed
catalog rows before any legacy projection is hydrated. Active behavior
filters store typed behavior kind keys and match typed behavior payloads;
`BehaviorData` reflection is only temporary option/column metadata. Dynamic
behavior columns read typed behavior payload fields by legacy payload key
`BehaviorData` reflection is only temporary TradeMenu option/column metadata.
PropertiesPanel display metadata is now package-owned typed behavior metadata.
Dynamic behavior columns read typed behavior payload fields by legacy payload key
instead of hydrating `BehaviorData` DTOs. Trade buy decisions for crafted price,
ship-hull classification, simple commodity base price, and simple commodity
stack size also read typed catalog rows; the existing inventory transfer and
@ -224,12 +225,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
The item properties panel also reads typed catalog title names, descriptions,
manufacturer, base mass, max durability, thermal bounds, and thermal
performance curve keys for basic item presentation without hydrating legacy
DTOs. Runtime behavior stat display and damage-range curves read typed
behavior payload fields by legacy payload key; stat modifier presentation
checks the package-owned typed `StatModifier` kind instead of a legacy data
class name. Damage-range payload selection is keyed by package-owned typed
weapon behavior metadata; legacy `BehaviorData` ancestry is no longer a
fallback for weapon payload selection. The old explicit
DTOs. Runtime behavior stat display reads typed behavior payload fields
through package-owned typed behavior display metadata; stat modifier
presentation checks the package-owned typed `StatModifier` kind instead of a
legacy data class name. Damage-range payload selection is keyed by
package-owned typed weapon behavior metadata; legacy `BehaviorData` ancestry
is no longer a fallback for weapon payload selection. The old explicit
`Inspect(ItemData)` DTO inspection overload is deleted; trade row clicks now
inspect the typed runtime catalog row directly. Incomplete typed thermal
curve rows render a neutral fallback curve instead of hydrating legacy
@ -766,8 +767,11 @@ First Aetheria surfaces to publish:
package-owned typed `StatModifier` behavior kind.
- Done: demote PropertiesPanel weapon damage-range payload matching from
`BehaviorData` `Type` authority to package-owned typed weapon behavior
metadata; `BehaviorData` reflection remains display/filter metadata-only
until typed behavior metadata/factory documents exist.
metadata.
- Done: move PropertiesPanel generic behavior stat display off
`BehaviorData` reflection and onto package-owned typed behavior display
metadata keyed by behavior kind and payload field key. TradeMenu still has
the remaining temporary `BehaviorData` display/filter metadata bridge.
- Done: remove the loot pickup presentation fallback to legacy `ItemData`;
typed category/name rows now decide pickup visuals and scan labels, and
missing typed rows render generic unknown gear pickup presentation.