From 0568ea71db62a37213ab8f27e9f966b314dba377 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 04:24:05 +0100 Subject: [PATCH] Use typed behavior payloads in properties panel --- .voidbot/state/aetheria.cc | Bin 62899 -> 63215 bytes .../UI/Properties Panel/PropertiesPanel.cs | 139 ++++++++++++++++-- docs/aetheria-perfect-machine-map.md | 12 +- 3 files changed, 137 insertions(+), 14 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 10df3bb1ab5a11d54f84a9e93046ec4d9a9e09fb..9625b9a43e99e826d12a62e34a09c6f4d7e36058 100644 GIT binary patch delta 1138 zcmZWpJ!@1!6eZaZO+YY(8Y0RS1QRuDve6KdLi{#GB=`Xu@MH4c-Q7vvo0-ha+hlEm z*a&JN)7T5zSSU{$71TmOK@5mRIxA6wn4jRC-M1Tw-P^l&&bjxTGn205{`}58dDyz4 zP#8T_$Pc*HT(^7Idb_j!dvM_3)V-E1PUfyRE5o(Q#+JZ~zjNU2S;^n*D zlapF1)Rv=}WCA15iLg9I_vzZU4k713BMXfixw5OJ;0~L8C?rHulu$#!qR7Cw#dv}V zMwR?2w8xocU?qgysEAcz8q2K0r3Pb}H9#Np$dnWivY5{FYerZQB)WnoPhc6}jjN-J zz(fdv6vpZ#ptD4zq-MGblc0 zy}vr)KB}I@r!4Sjw9xG+u&(gLO|lPH9_gwfWP3-oe?7@_@#w!sFx zPEVLHUq%65cr0-;hf%-Ma)ySZfBS2VU4bRA#2^V6Gb)X_&1~!NETRIHm@*e7ShHuI z>2S@OrpBI2il~~-uwS{0N5b<*8%N(-Hcy)}m5(Dbu%UaZ_lbw-g(YMJOTDUcCI# zEC?p=y5gYAOoq%rMhWrT>r&##OI>ErQfP)*m~up&OgQq z50PSW7K`S7+7*Av_1t`*vADcfmtZ}ITUzd4)MrR%PC?2pLQ}PR-0Qq#&id11HRXU& zV&fQvrQnshAyX&~5tv!DLD{F-dUKkf78h*3KGE0(!EJRrOf%|?Wmxk#yPEyV-%W?= zWk+`FM+VZqx#5=d*0)U^8yhwEIoFdl3=WRCH$T5No`6CjdlcH;i(fK(ItJa+O1C?` Ua--2TG~m0^A1iM=nx&zszXS=Vq5uE@ delta 1055 zcma)*%W4!s6oyGA#6$%_2vI?EynqU0$4R0w(M@C!vKSQ2LIVml)n{f(s;io+>d{^e zUT`C*p}-dqFAEW+A3y{J?-znXR5S=~j6r<^tLGLJ1Xt7ZbL#)Ub57Nd#Z0o0xqG8? zd2V!kWT&@lY-oC>qt8C-yx7xH?5|9}{khO>ql{^njn&I~y4H7oJ)LarqQ`9V>})na zrHGFO6cPBbAOWLL#0sf0senoz1ww<6r$8a`t(aZ2$-7QDVZr;3;?hYWflEq1raC4oreZ?b5g*uOlaI*!XPskKz{0AV_YtUDUhcGkjPY|VyV4% zkI??qYBC5pqjlH0#|I)4DYT#0^{x7g#1@|S*W46RWbJ?&T|r1@WDyC@7EvLOm!DApA+>|j0r6Ovnl^xWr&!~u|sLP)fW^MCn?#|`v mPjmIc{gyJ+P<}2%ZDqJ#bN>68wlbP3$(F?jy)9`tH~ky`=ZTU4 diff --git a/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs b/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs index 26ec8d2e1..543d1667c 100644 --- a/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs +++ b/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs @@ -454,42 +454,159 @@ public class PropertiesPanel : MonoBehaviour return; } - var gearData = GameManager.ItemManager.GetData(item); + var typedItem = FindTypedPropertyItem(item); var sheet = AddStatSheet(); - foreach (var behavior in gearData.Behaviors) + foreach (var behavior in typedItem?.BehaviorPayloads ?? Array.Empty()) { - if (behavior is StatModifierData statMod) + if (string.Equals(behavior.Kind, nameof(StatModifierData), StringComparison.Ordinal)) { - sheet.AddStat($"{statMod.Stat.Target.SplitCamelCase()}:{statMod.Stat.Stat.SplitCamelCase()}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.RuntimePlayerSettings.Format(statValueFunction(statMod.Modifier))}"); + var statReference = ReadTypedStatReference(FindTypedBehaviorField(behavior, 1)?.Value); + var modifier = ReadTypedPerformanceStat(FindTypedBehaviorField(behavior, 2)?.Value); + var modifierType = ReadTypedEnum(FindTypedBehaviorField(behavior, 3)?.Value, StatModifierType.Constant); + sheet.AddStat($"{statReference.target.SplitCamelCase()}:{statReference.stat.SplitCamelCase()}", + () => $"{(modifierType == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.RuntimePlayerSettings.Format(statValueFunction(modifier))}"); } else { - var type = behavior.GetType(); - if (type.GetCustomAttribute(typeof(RuntimeInspectable)) == null) continue; + var type = ResolveBehaviorType(behavior.Kind); + if (type == null || type.GetCustomAttribute(typeof(RuntimeInspectable)) == null) continue; foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute() != null)) { var fieldType = field.FieldType; + var payloadField = FindTypedBehaviorField(behavior, field.GetCustomAttribute()?.Key); if (fieldType == typeof(float)) - sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.RuntimePlayerSettings.Format((float) field.GetValue(behavior))}"); + { + var value = (float)(payloadField?.Value.NumberValue ?? 0); + sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.RuntimePlayerSettings.Format(value)}"); + } else if (fieldType == typeof(int)) - sheet.AddStat(field.Name.SplitCamelCase(), () => $"{(int) field.GetValue(behavior)}"); + { + var value = (int)(payloadField?.Value.NumberValue ?? 0); + sheet.AddStat(field.Name.SplitCamelCase(), () => $"{value}"); + } else if (fieldType == typeof(PerformanceStat)) { - var stat = (PerformanceStat) field.GetValue(behavior); + var stat = ReadTypedPerformanceStat(payloadField?.Value); sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.RuntimePlayerSettings.Format(statValueFunction(stat))}"); } } } } - if (gearData.Behaviors.FirstOrDefault(b => b is WeaponData) is WeaponData weapon) + var weaponPayload = typedItem?.BehaviorPayloads.FirstOrDefault(payload => TypedBehaviorMatches(payload, typeof(WeaponData))); + if (weaponPayload != null) { + var damageCurve = ReadTypedBezierCurve(FindTypedBehaviorField(weaponPayload, 7)?.Value); + var minRange = ReadTypedPerformanceStat(FindTypedBehaviorField(weaponPayload, 5)?.Value); + var rangeStat = ReadTypedPerformanceStat(FindTypedBehaviorField(weaponPayload, 6)?.Value); var range = AddCurveField(); - range.Show("Damage Range", weapon.DamageCurve, t => ActionGameManager.RuntimePlayerSettings.Format(lerp(statValueFunction(weapon.MinRange), statValueFunction(weapon.Range), t))); + range.Show("Damage Range", damageCurve, t => ActionGameManager.RuntimePlayerSettings.Format(lerp(statValueFunction(minRange), statValueFunction(rangeStat), t))); } } + private static AetheriaRuntimeBehaviorField FindTypedBehaviorField(AetheriaRuntimeBehaviorPayload behavior, int? key) + { + return key == null + ? null + : behavior.Fields.FirstOrDefault(field => field.Key == key.Value); + } + + private static PerformanceStat ReadTypedPerformanceStat(AetheriaRuntimeBehaviorValue value) + { + return new PerformanceStat + { + Min = ReadTypedChildNumber(value, 0), + Max = ReadTypedChildNumber(value, 1), + HeatExponentMultiplier = ReadTypedChildNumber(value, 2), + DurabilityExponentMultiplier = ReadTypedChildNumber(value, 3), + QualityExponent = ReadTypedChildNumber(value, 4) + }; + } + + private static (string target, string stat) ReadTypedStatReference(AetheriaRuntimeBehaviorValue value) + { + return ( + ReadTypedChildString(value, 1), + ReadTypedChildString(value, 2)); + } + + private static BezierCurve ReadTypedBezierCurve(AetheriaRuntimeBehaviorValue value) + { + var keysValue = value != null && value.Children.Count > 0 ? value.Children[0] : null; + var keys = keysValue?.Children + .Select(ReadTypedFloat4) + .ToArray(); + + return new BezierCurve + { + Keys = keys != null && keys.Length > 0 + ? keys + : new[] { new float4(0f, 1f, 0f, 0f), new float4(1f, 1f, 0f, 0f) } + }; + } + + private static float4 ReadTypedFloat4(AetheriaRuntimeBehaviorValue value) + { + return new float4( + ReadTypedChildNumber(value, 0), + ReadTypedChildNumber(value, 1), + ReadTypedChildNumber(value, 2), + ReadTypedChildNumber(value, 3)); + } + + private static float ReadTypedChildNumber(AetheriaRuntimeBehaviorValue value, int index) + { + return value != null && value.Children.Count > index + ? (float)value.Children[index].NumberValue + : 0f; + } + + private static string ReadTypedChildString(AetheriaRuntimeBehaviorValue value, int index) + { + return value != null && value.Children.Count > index + ? value.Children[index].StringValue ?? "" + : ""; + } + + private static T ReadTypedEnum(AetheriaRuntimeBehaviorValue value, T fallback) where T : struct + { + if (!string.IsNullOrWhiteSpace(value?.StringValue) && Enum.TryParse(value.StringValue, true, out T parsed)) + { + return parsed; + } + + return value != null && Enum.IsDefined(typeof(T), (int)value.NumberValue) + ? (T)Enum.ToObject(typeof(T), (int)value.NumberValue) + : fallback; + } + + private static bool TypedBehaviorMatches(AetheriaRuntimeBehaviorPayload payload, Type behaviorType) + { + if (string.Equals(payload.Kind, behaviorType.Name, StringComparison.Ordinal)) + { + return true; + } + + var payloadType = ResolveBehaviorType(payload.Kind); + return payloadType != null && behaviorType.IsAssignableFrom(payloadType); + } + + private static Type ResolveBehaviorType(string kind) + { + return string.IsNullOrWhiteSpace(kind) + ? null + : BehaviorTypesByName.TryGetValue(kind, out var type) + ? type + : null; + } + + private static readonly IReadOnlyDictionary 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); diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index f7e4f682c..119ea9907 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -182,9 +182,11 @@ 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; legacy `ItemData` hydration remains only for behavior stat reflection. - Incomplete typed thermal curve rows render a neutral fallback curve instead - of hydrating legacy `EquippableItemData`. Inventory selection highlighting now uses typed item + DTOs. Runtime behavior stat display and damage-range curves read typed + behavior payload fields by legacy payload key; the explicit `Inspect(ItemData)` + overload remains a legacy DTO inspection surface. Incomplete typed thermal + curve rows render a neutral fallback curve instead of hydrating legacy + `EquippableItemData`. Inventory selection highlighting now uses typed item shape cells only for UI tint geometry; incomplete typed rows produce no selected-cell mask instead of falling back to legacy `ItemData.Shape`. Inventory cargo cell tint now uses typed hardpoint facets only; incomplete @@ -659,6 +661,10 @@ First Aetheria surfaces to publish: - Done: import typed thermal performance curve keys and move PropertiesPanel thermal curve presentation onto typed catalog rows; incomplete typed rows use a neutral fallback curve instead of hydrating legacy thermal DTOs. + - Done: move PropertiesPanel runtime behavior stat display and damage-range + curves onto typed behavior payload fields; only the explicit + `Inspect(ItemData)` projection inspector still reflects legacy behavior + DTOs. - 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.