From b9bd71101a1b246a8aeeac5daf39b9ca11b0eb6d Mon Sep 17 00:00:00 2001 From: SimpleStation14 <130339894+SimpleStation14@users.noreply.github.com> Date: Sat, 4 May 2024 16:07:12 -0700 Subject: [PATCH] Mirror: Added winddown to space drugs effect (#131) ## Mirror of PR #25652: [Added winddown to space drugs effect](https://github.com/space-wizards/space-station-14/pull/25652) from space-wizards [space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14) ###### `865765d4eca5483d22c5d1e496b7f7c8787833a8` PR opened by PolterTzi at 2024-02-27 18:09:49 UTC PR merged by web-flow at 2024-03-09 19:33:40 UTC --- PR changed 2 files with 14 additions and 1 deletions. The PR had the following labels: ---

Original Body

> > > > ## About the PR > > > The space drugs shader effect now gradually loses intensity as it's nearing its end. > > ## Why / Balance > > Makes for a smoother transition than going from 100% to 0% instantly. > > ## Media > > > https://github.com/space-wizards/space-station-14/assets/62557990/1dd19974-1066-4f76-a270-6844f35af042 > > > - [X] I have added screenshots/videos to this PR showcasing its changes ingame, **or** this PR does not require an ingame showcase
Co-authored-by: Flesh <62557990+PolterTzi@users.noreply.github.com> --- Content.Client/Drugs/DrugOverlaySystem.cs | 2 ++ Content.Client/Drugs/RainbowOverlay.cs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Content.Client/Drugs/DrugOverlaySystem.cs b/Content.Client/Drugs/DrugOverlaySystem.cs index 9bfa4fdf82..60fdf12f5e 100644 --- a/Content.Client/Drugs/DrugOverlaySystem.cs +++ b/Content.Client/Drugs/DrugOverlaySystem.cs @@ -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); } } diff --git a/Content.Client/Drugs/RainbowOverlay.cs b/Content.Client/Drugs/RainbowOverlay.cs index 6ef5d0f65c..e62b0dfa66 100644 --- a/Content.Client/Drugs/RainbowOverlay.cs +++ b/Content.Client/Drugs/RainbowOverlay.cs @@ -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)