Significantly improve TEG power generation stability (#37658)
* Significantly improve TEG power generation stability * Revert "Significantly improve TEG power generation stability" This reverts commit e88278c0f8dea925a89b240e09e5dbcb84f9d174. * Reimplement without auto formatting obliterating the entire system * second round of balancing
This commit is contained in:
@@ -75,4 +75,10 @@ public sealed partial class TegGeneratorComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("volumeMax")]
|
[DataField("volumeMax")]
|
||||||
public float VolumeMax = -4;
|
public float VolumeMax = -4;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Smoothing factor used to smooth out power generation.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float PowerSmoothingFactor = 0.2f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,8 +186,12 @@ public sealed class TegSystem : EntitySystem
|
|||||||
|
|
||||||
// Turn energy (at atmos tick rate) into wattage.
|
// Turn energy (at atmos tick rate) into wattage.
|
||||||
var power = electricalEnergy / args.dt;
|
var power = electricalEnergy / args.dt;
|
||||||
|
|
||||||
// Add ramp factor. This magics slight power into existence, but allows us to ramp up.
|
// Add ramp factor. This magics slight power into existence, but allows us to ramp up.
|
||||||
supplier.MaxSupply = power * component.RampFactor;
|
// Also apply an exponential moving average to smooth out fluttering, as it was causing
|
||||||
|
// seizures.
|
||||||
|
supplier.MaxSupply = component.PowerSmoothingFactor * (power * component.RampFactor) +
|
||||||
|
(1 - component.PowerSmoothingFactor) * supplier.MaxSupply;
|
||||||
|
|
||||||
var circAComp = Comp<TegCirculatorComponent>(circA);
|
var circAComp = Comp<TegCirculatorComponent>(circA);
|
||||||
var circBComp = Comp<TegCirculatorComponent>(circB);
|
var circBComp = Comp<TegCirculatorComponent>(circB);
|
||||||
|
|||||||
Reference in New Issue
Block a user