Browse Source

Add method for checking whether `SideEffect` is active

pull/13/head
Anton Tarasenko 2 years ago
parent
commit
3d2518ccdd
  1. 18
      sources/BaseAPI/API/SideEffects/SideEffectAPI.uc

18
sources/BaseAPI/API/SideEffects/SideEffectAPI.uc

@ -120,6 +120,24 @@ public function SideEffect Add_S(
return newSideEffect; 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. /// 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 /// This method will fail if its argument is `none`, non-initialized or a side effect with that

Loading…
Cancel
Save