]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Added winddown to space drugs effect (#25652)
authorFlesh <62557990+PolterTzi@users.noreply.github.com>
Sat, 9 Mar 2024 19:33:40 +0000 (20:33 +0100)
committerGitHub <noreply@github.com>
Sat, 9 Mar 2024 19:33:40 +0000 (22:33 +0300)
added winddown to drug effect

Content.Client/Drugs/DrugOverlaySystem.cs
Content.Client/Drugs/RainbowOverlay.cs

index 9bfa4fdf8271f83496afe01eb483b023361ecf8d..60fdf12f5e393ad08fa55ddf83fffe84ba565534 100644 (file)
@@ -38,6 +38,7 @@ public sealed class DrugOverlaySystem : EntitySystem
     private void OnPlayerDetached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerDetachedEvent args)
     {
         _overlay.Intoxication = 0;
+        _overlay.TimeTicker = 0;
         _overlayMan.RemoveOverlay(_overlay);
     }
 
@@ -52,6 +53,7 @@ public sealed class DrugOverlaySystem : EntitySystem
         if (_player.LocalEntity == uid)
         {
             _overlay.Intoxication = 0;
+            _overlay.TimeTicker = 0;
             _overlayMan.RemoveOverlay(_overlay);
         }
     }
index 6ef5d0f65ce8e5d6d38ab0ea74b65f79130c889f..e62b0dfa66cd062317c3c768a61600c07493e1dd 100644 (file)
@@ -20,6 +20,7 @@ public sealed class RainbowOverlay : Overlay
     private readonly ShaderInstance _rainbowShader;
 
     public float Intoxication = 0.0f;
+    public float TimeTicker = 0.0f;
 
     private const float VisualThreshold = 10.0f;
     private const float PowerDivisor = 250.0f;
@@ -48,7 +49,17 @@ public sealed class RainbowOverlay : Overlay
             return;
 
         var timeLeft = (float) (time.Value.Item2 - time.Value.Item1).TotalSeconds;
-        Intoxication += (timeLeft - Intoxication) * args.DeltaSeconds / 16f;
+
+        TimeTicker += args.DeltaSeconds;
+
+        if (timeLeft - TimeTicker > timeLeft / 16f)
+        {
+            Intoxication += (timeLeft - Intoxication) * args.DeltaSeconds / 16f;
+        }
+        else
+        {
+            Intoxication -= Intoxication/(timeLeft - TimeTicker) * args.DeltaSeconds;
+        }
     }
 
     protected override bool BeforeDraw(in OverlayDrawArgs args)