diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index a932cbd92..09423f081 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 5151a8b11..b216e9390 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -208,10 +208,12 @@ runtime performance stats explicitly for `StatModifier`. Capacitor, Shield, MiningTool, ResourceScanner, Thermotoggle, and Thruster now follow the same direct-definition path; the temporary config bridge no longer constructs those medium behavior classes. -Reactor, Radiator, Sensor, and StatModifier also read typed payload fields -through `RuntimeBehaviorDefinition`; the bridge no longer owns their -construction or stat reflection. -`ItemManager` currently owns the explicit typed-payload-to-config bridge. +Reactor, Radiator, Sensor, StatModifier, and AetherDrive also read typed +payload fields through `RuntimeBehaviorDefinition`; the bridge no longer owns +their construction or stat reflection. AetherDrive registers its live +performance-stat names explicitly for `StatModifier`. +`ItemManager` currently owns the remaining weapon-family typed-payload-to-config +bridge. Typed name-file documents are `aetheria.name_file.v2` records. They carry the legacy ID, display name, count, compact sample names for surfaces, and the full name array used by `Galaxy`/Markov name generation through typed name-file diff --git a/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs b/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs index e1f655666..032f8c543 100644 --- a/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs +++ b/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs @@ -6,58 +6,6 @@ using Unity.Mathematics; using static Unity.Mathematics.math; [Inspectable, EntityTypeRestriction(HullType.Ship)] -public class AetherDriveConfig : RuntimeBehaviorConfig -{ - [Inspectable] - public float3 RotorDiameter; - - [Inspectable] - public float3 RotorMass; - - [Inspectable] - public PerformanceStat MaximumRpm; - - [Inspectable] - public float3 CouplingLambda; - - [Inspectable] - public PerformanceStat LambdaMultiplier; - - [Inspectable] - public PerformanceStat CouplingEfficiency; - - [Inspectable] - public PerformanceStat Torque; - - [Inspectable] - public BezierCurve TorqueProfile; - - [Inspectable] - public PerformanceStat EnergyDraw; - - [Inspectable] - public PerformanceStat PassiveCoupling; - - [InspectableAudioParameter] - public uint RpmAudioParameter; - - [InspectableAudioParameter] - public uint TorqueRatioAudioParameter; - - [InspectablePrefab] - public string Particles; - - public override Behavior CreateInstance(EquippedItem item) - { - return new AetherDrive(this, item); - } - - public override Behavior CreateInstance(ConsumableItemEffect item) - { - return new AetherDrive(this, item); - } -} - public class AetherDrive : Behavior { private readonly float3 _rotorDiameter; @@ -86,38 +34,50 @@ public class AetherDrive : Behavior set => _axis = clamp(value, -1, 1); } - public AetherDrive(AetherDriveConfig data, EquippedItem item) : base(data, item) + public AetherDrive(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item) { - _rotorDiameter = data.RotorDiameter; - _rotorMass = data.RotorMass; - _maximumRpm = data.MaximumRpm; - _couplingLambda = data.CouplingLambda; - _lambdaMultiplier = data.LambdaMultiplier; - _couplingEfficiency = data.CouplingEfficiency; - _torque = data.Torque; - _torqueProfile = data.TorqueProfile; - _energyDraw = data.EnergyDraw; - _passiveCoupling = data.PassiveCoupling; - _rpmAudioParameter = data.RpmAudioParameter; - _torqueRatioAudioParameter = data.TorqueRatioAudioParameter; - Particles = data.Particles; + _rotorDiameter = definition.Float3(1); + _rotorMass = definition.Float3(2); + _maximumRpm = definition.PerformanceStat(3, null); + _couplingLambda = definition.Float3(4); + _lambdaMultiplier = definition.PerformanceStat(5, null); + _couplingEfficiency = definition.PerformanceStat(6, null); + _torque = definition.PerformanceStat(7, null); + _torqueProfile = definition.BezierCurve(8, null); + _energyDraw = definition.PerformanceStat(9, null); + _passiveCoupling = definition.PerformanceStat(10, null); + _rpmAudioParameter = definition.UInt(11); + _torqueRatioAudioParameter = definition.UInt(12); + Particles = definition.String(13); + RegisterAetherDriveStats(); } - public AetherDrive(AetherDriveConfig data, ConsumableItemEffect item) : base(data, item) + public AetherDrive(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item) { - _rotorDiameter = data.RotorDiameter; - _rotorMass = data.RotorMass; - _maximumRpm = data.MaximumRpm; - _couplingLambda = data.CouplingLambda; - _lambdaMultiplier = data.LambdaMultiplier; - _couplingEfficiency = data.CouplingEfficiency; - _torque = data.Torque; - _torqueProfile = data.TorqueProfile; - _energyDraw = data.EnergyDraw; - _passiveCoupling = data.PassiveCoupling; - _rpmAudioParameter = data.RpmAudioParameter; - _torqueRatioAudioParameter = data.TorqueRatioAudioParameter; - Particles = data.Particles; + _rotorDiameter = definition.Float3(1); + _rotorMass = definition.Float3(2); + _maximumRpm = definition.PerformanceStat(3, null); + _couplingLambda = definition.Float3(4); + _lambdaMultiplier = definition.PerformanceStat(5, null); + _couplingEfficiency = definition.PerformanceStat(6, null); + _torque = definition.PerformanceStat(7, null); + _torqueProfile = definition.BezierCurve(8, null); + _energyDraw = definition.PerformanceStat(9, null); + _passiveCoupling = definition.PerformanceStat(10, null); + _rpmAudioParameter = definition.UInt(11); + _torqueRatioAudioParameter = definition.UInt(12); + Particles = definition.String(13); + RegisterAetherDriveStats(); + } + + private void RegisterAetherDriveStats() + { + RegisterPerformanceStat(nameof(MaximumRpm), _maximumRpm); + RegisterPerformanceStat("LambdaMultiplier", _lambdaMultiplier); + RegisterPerformanceStat("CouplingEfficiency", _couplingEfficiency); + RegisterPerformanceStat("Torque", _torque); + RegisterPerformanceStat("EnergyDraw", _energyDraw); + RegisterPerformanceStat("PassiveCoupling", _passiveCoupling); } public override bool Execute(float dt) diff --git a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs index 371028100..85efdd8b3 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs @@ -229,6 +229,16 @@ public sealed class RuntimeBehaviorDefinition return _fields.TryGetValue(key, out var value) ? (float)value.NumberValue : fallback; } + public uint UInt(int key, uint fallback = 0) + { + return _fields.TryGetValue(key, out var value) ? checked((uint)value.NumberValue) : fallback; + } + + public float3 Float3(int key, float3 fallback = default) + { + return _fields.TryGetValue(key, out var value) ? ToFloat3(value) : fallback; + } + public string String(int key, string fallback = "") { return _fields.TryGetValue(key, out var value) ? value.StringValue ?? "" : fallback; @@ -309,6 +319,11 @@ public sealed class RuntimeBehaviorDefinition return new float4(ChildFloat(value, 0), ChildFloat(value, 1), ChildFloat(value, 2), ChildFloat(value, 3)); } + private static float3 ToFloat3(AetheriaRuntimeBehaviorValue value) + { + return new float3(ChildFloat(value, 0), ChildFloat(value, 1), ChildFloat(value, 2)); + } + private static float ChildFloat(AetheriaRuntimeBehaviorValue value, int index) { return value.Children.Count > index ? (float)value.Children[index].NumberValue : 0; diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index b7cad3705..ac3670a2f 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -93,6 +93,7 @@ public class ItemManager switch (payload.Kind) { case "Cockpit": return new Cockpit(definition, item); + case "AetherDrive": return new AetherDrive(definition, item); case "Capacitor": return new Capacitor(definition, item); case "Cooldown": return new Cooldown(definition, item); case "EnergyDraw": return new EnergyDraw(definition, item); @@ -126,6 +127,7 @@ public class ItemManager switch (payload.Kind) { case "Cockpit": return new Cockpit(definition, effect); + case "AetherDrive": return new AetherDrive(definition, effect); case "Capacitor": return new Capacitor(definition, effect); case "Cooldown": return new Cooldown(definition, effect); case "EnergyDraw": return new EnergyDraw(definition, effect); @@ -157,7 +159,6 @@ public class ItemManager { switch (payload.Kind) { - case "AetherDrive": return Configure(new AetherDriveConfig(), payload, ApplyAetherDriveConfig); case "AutoWeapon": return Configure(new AutoWeaponConfig(), payload, ApplyInstantWeaponConfig); case "ChargedWeapon": return Configure(new ChargedWeaponConfig(), payload, ApplyChargedWeaponConfig); case "ConstantWeapon": return Configure(new ConstantWeaponConfig(), payload, ApplyConstantWeaponConfig); @@ -178,23 +179,6 @@ public class ItemManager return config; } - private static void ApplyAetherDriveConfig(AetherDriveConfig config, BehaviorPayloadReader reader) - { - config.RotorDiameter = reader.Float3(1, config.RotorDiameter); - config.RotorMass = reader.Float3(2, config.RotorMass); - config.MaximumRpm = reader.PerformanceStat(3, config.MaximumRpm); - config.CouplingLambda = reader.Float3(4, config.CouplingLambda); - config.LambdaMultiplier = reader.PerformanceStat(5, config.LambdaMultiplier); - config.CouplingEfficiency = reader.PerformanceStat(6, config.CouplingEfficiency); - config.Torque = reader.PerformanceStat(7, config.Torque); - config.TorqueProfile = reader.BezierCurve(8, config.TorqueProfile); - config.EnergyDraw = reader.PerformanceStat(9, config.EnergyDraw); - config.PassiveCoupling = reader.PerformanceStat(10, config.PassiveCoupling); - config.RpmAudioParameter = reader.UInt(11, config.RpmAudioParameter); - config.TorqueRatioAudioParameter = reader.UInt(12, config.TorqueRatioAudioParameter); - config.Particles = reader.String(13, config.Particles); - } - private static void ApplyWeaponConfig(WeaponConfig config, BehaviorPayloadReader reader) { config.DamageType = reader.Enum(1, config.DamageType); @@ -317,11 +301,6 @@ public class ItemManager return _fields.TryGetValue(key, out var value) ? checked((int)value.NumberValue) : fallback; } - public uint UInt(int key, uint fallback = 0) - { - return _fields.TryGetValue(key, out var value) ? checked((uint)value.NumberValue) : fallback; - } - public string ItemKey(int key, string fallback = "") { return _fields.TryGetValue(key, out var value) && @@ -346,11 +325,6 @@ public class ItemManager return (T)System.Enum.ToObject(typeof(T), checked((int)value.NumberValue)); } - public float3 Float3(int key, float3 fallback = default) - { - return _fields.TryGetValue(key, out var value) ? ToFloat3(value) : fallback; - } - public float4[] Float4Array(int key, float4[] fallback) { return _fields.TryGetValue(key, out var value) @@ -404,11 +378,6 @@ public class ItemManager }; } - private static float3 ToFloat3(AetheriaRuntimeBehaviorValue value) - { - return new float3(ChildFloat(value, 0), ChildFloat(value, 1), ChildFloat(value, 2)); - } - private static float4 ToFloat4(AetheriaRuntimeBehaviorValue value) { return new float4(ChildFloat(value, 0), ChildFloat(value, 1), ChildFloat(value, 2), ChildFloat(value, 3)); diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 3bf41138e..7781171e6 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -333,9 +333,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. Capacitor, Shield, MiningTool, ResourceScanner, Thermotoggle, and Thruster now follow the same direct-definition path, so the temporary config bridge no longer constructs those medium behavior classes. - Reactor, Radiator, Sensor, and StatModifier also read typed payload fields - through `RuntimeBehaviorDefinition`; their live stat surfaces are registered - explicitly rather than recovered through config reflection. + Reactor, Radiator, Sensor, StatModifier, and AetherDrive also read typed + payload fields through `RuntimeBehaviorDefinition`; their live stat surfaces + are registered explicitly rather than recovered through config reflection. `StatModifier` behavior requirements and behavior-stat targets compare typed behavior kinds on the live equipped behavior instances through `AetheriaRuntimeBehaviorMetadataCatalog` instead of scanning config @@ -1485,6 +1485,10 @@ First Aetheria surfaces to publish: stats, curves, enum, scalar, and stat-reference fields directly, and live behavior instances explicitly expose the stat names used by `StatModifier`. + - Done: delete `AetherDriveConfig`. `RuntimeBehaviorDefinition` now reads + rotor geometry, RPM/coupling/torque/energy/passive-coupling stats, torque + curve, audio parameters, and particle prefab path directly; the remaining + `RuntimeBehaviorConfig` bridge is weapon-family-only. - Done: delete `LegacyPayloadKeyAttribute` from live Unity source after importer constants and explicit typed mappers became the only migrated field-key authorities.