From 3d2518ccddf5b3c14556422264cedd3d22c36585 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sun, 9 Apr 2023 18:08:33 +0700 Subject: [PATCH] Add method for checking whether `SideEffect` is active --- .../BaseAPI/API/SideEffects/SideEffectAPI.uc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sources/BaseAPI/API/SideEffects/SideEffectAPI.uc b/sources/BaseAPI/API/SideEffects/SideEffectAPI.uc index 7e58b91..3317c59 100644 --- a/sources/BaseAPI/API/SideEffects/SideEffectAPI.uc +++ b/sources/BaseAPI/API/SideEffects/SideEffectAPI.uc @@ -120,6 +120,24 @@ public function SideEffect Add_S( return newSideEffect; } +/// Checks whether specified [`SideEffect`] is currently active. +/// +/// Check is done via contents and not instance equality. +/// Returns `true` if specified [`SideEffect`] is currently active and `false` otherwise. +public function bool IsRegistered(SideEffect sideEffectToCheck) { + local int i; + + if (sideEffectToCheck == none) return false; + if (!sideEffectToCheck.IsInitialized()) return false; + + for (i = 0; i < activeSideEffects.length; i += 1) { + if (activeSideEffects[i].IsEqual(sideEffectToCheck)) { + return true; + } + } + return false; +} + /// Adds a new side effect to the list of active side effects. /// /// This method will fail if its argument is `none`, non-initialized or a side effect with that