]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Significantly improve TEG power generation stability (#37658)
authorArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Mon, 26 May 2025 12:07:49 +0000 (05:07 -0700)
committerGitHub <noreply@github.com>
Mon, 26 May 2025 12:07:49 +0000 (14:07 +0200)
* 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

Content.Server/Power/Generation/Teg/TegGeneratorComponent.cs
Content.Server/Power/Generation/Teg/TegSystem.cs

index 87998e5d82a98566888dfc78f49e04257673a49d..1551078a880763d55adbbec160d0aee2e4c1278d 100644 (file)
@@ -75,4 +75,10 @@ public sealed partial class TegGeneratorComponent : Component
     [ViewVariables(VVAccess.ReadWrite)]
     [DataField("volumeMax")]
     public float VolumeMax = -4;
+
+    /// <summary>
+    /// Smoothing factor used to smooth out power generation.
+    /// </summary>
+    [DataField]
+    public float PowerSmoothingFactor = 0.2f;
 }
index 77848d5c796344649ea3d5a02e4781f7af9304a5..0de3038a35b42dc8f3c7719e57a9bfbc97e07a70 100644 (file)
@@ -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<TegCirculatorComponent>(circA);
         var circBComp = Comp<TegCirculatorComponent>(circB);