Bypass config for AetherDrive
This commit is contained in:
parent
70c9e965a1
commit
6479f6fcfa
6 changed files with 70 additions and 120 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue