From c33ed9f996a9435a7f9d107b84b8340ce248338b Mon Sep 17 00:00:00 2001 From: AnotherCommander Date: Tue, 26 Nov 2024 12:18:04 +0200 Subject: [PATCH] Fixing bug where ECM effect does not work when no entities are on scanner - act 2 --- src/Core/Entities/PlayerEntity.m | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Core/Entities/PlayerEntity.m b/src/Core/Entities/PlayerEntity.m index 71eba3085..39de4614c 100644 --- a/src/Core/Entities/PlayerEntity.m +++ b/src/Core/Entities/PlayerEntity.m @@ -2725,6 +2725,8 @@ - (void) doBookkeeping:(double) delta_t STAGE_TRACKING_BEGIN double speed_delta = SHIP_THRUST_FACTOR * thrust; + + static BOOL gettingInterference = NO; OOSunEntity *sun = [UNIVERSE sun]; double external_temp = 0; @@ -2819,6 +2821,29 @@ - (void) doBookkeeping:(double) delta_t ecm_in_operation = NO; } } + + // ecm interference visual effect + if ([UNIVERSE useShaders] && [UNIVERSE ECMVisualFXEnabled]) + { + // we want to start and stop the effect exactly once, not start it + // or stop it on every frame + if ([self scannerFuzziness] > 0.0) + { + if (!gettingInterference) + { + [UNIVERSE setCurrentPostFX:OO_POSTFX_CRTBADSIGNAL]; + gettingInterference = YES; + } + } + else + { + if (gettingInterference) + { + [UNIVERSE setCurrentPostFX:[UNIVERSE colorblindMode]]; + gettingInterference = NO; + } + } + } // Energy Banks and Shields