From 9a910873c873b9a8a92431b718c2e3356e3d9277 Mon Sep 17 00:00:00 2001 From: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> Date: Mon, 26 May 2025 05:07:49 -0700 Subject: [PATCH] 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 --- .../Power/Generation/Teg/TegGeneratorComponent.cs | 6 ++++++ Content.Server/Power/Generation/Teg/TegSystem.cs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Server/Power/Generation/Teg/TegGeneratorComponent.cs b/Content.Server/Power/Generation/Teg/TegGeneratorComponent.cs index 87998e5d82..1551078a88 100644 --- a/Content.Server/Power/Generation/Teg/TegGeneratorComponent.cs +++ b/Content.Server/Power/Generation/Teg/TegGeneratorComponent.cs @@ -75,4 +75,10 @@ public sealed partial class TegGeneratorComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("volumeMax")] public float VolumeMax = -4; + + /// + /// Smoothing factor used to smooth out power generation. + /// + [DataField] + public float PowerSmoothingFactor = 0.2f; } diff --git a/Content.Server/Power/Generation/Teg/TegSystem.cs b/Content.Server/Power/Generation/Teg/TegSystem.cs index 77848d5c79..0de3038a35 100644 --- a/Content.Server/Power/Generation/Teg/TegSystem.cs +++ b/Content.Server/Power/Generation/Teg/TegSystem.cs @@ -186,8 +186,12 @@ public sealed class TegSystem : EntitySystem // Turn energy (at atmos tick rate) into wattage. var power = electricalEnergy / args.dt; + // 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(circA); var circBComp = Comp(circB);