From cf4a883f111d57b48e37be1339808065b7ff4535 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Fri, 27 Jun 2025 05:00:20 -0700 Subject: [PATCH] New Status Effects API Overload (#38617) * I love API changes * Update Content.Shared/StatusEffectNew/StatusEffectSystem.API.cs * fix --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- .../StatusEffectNew/StatusEffectSystem.API.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Content.Shared/StatusEffectNew/StatusEffectSystem.API.cs b/Content.Shared/StatusEffectNew/StatusEffectSystem.API.cs index 8f34f97930..14b02dd9db 100644 --- a/Content.Shared/StatusEffectNew/StatusEffectSystem.API.cs +++ b/Content.Shared/StatusEffectNew/StatusEffectSystem.API.cs @@ -18,23 +18,27 @@ public abstract partial class SharedStatusEffectsSystem /// If True, the effect duration time will be reset and reapplied. If False, the effect duration time will be overlaid with the existing one. /// In the other case, the effect will either be added for the specified time or its time will be extended for the specified time. /// + /// The EntityUid of the status effect we have just created or null if it doesn't exist. public bool TryAddStatusEffect( EntityUid target, EntProtoId effectProto, + out EntityUid? statusEffect, TimeSpan? duration = null, bool resetCooldown = false ) { - if (TryGetStatusEffect(target, effectProto, out var existedEffect)) + statusEffect = null; + if (TryGetStatusEffect(target, effectProto, out var existingEffect)) { + statusEffect = existingEffect; //We don't need to add the effect if it already exists if (duration is null) return true; if (resetCooldown) - SetStatusEffectTime(existedEffect.Value, duration.Value); + SetStatusEffectTime(existingEffect.Value, duration.Value); else - AddStatusEffectTime(existedEffect.Value, duration.Value); + AddStatusEffectTime(existingEffect.Value, duration.Value); return true; } @@ -46,6 +50,7 @@ public abstract partial class SharedStatusEffectsSystem //And only if all checks passed we spawn the effect var effect = PredictedSpawnAttachedTo(effectProto, Transform(target).Coordinates); + statusEffect = effect; _transform.SetParent(effect, target); if (!_effectQuery.TryComp(effect, out var effectComp)) return false; @@ -64,6 +69,20 @@ public abstract partial class SharedStatusEffectsSystem return true; } + /// + /// An overload of + /// that doesn't return a status effect EntityUid. + /// + public bool TryAddStatusEffect( + EntityUid target, + EntProtoId effectProto, + TimeSpan? duration = null, + bool resetCooldown = false + ) + { + return TryAddStatusEffect(target, effectProto, out _, duration, resetCooldown); + } + /// /// Attempting to remove a status effect from an entity. /// Returns True if the status effect existed on the entity and was successfully removed, and False in otherwise. -- 2.51.2