]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
New Status Effects API Overload (#38617)
authorPrincess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
Fri, 27 Jun 2025 12:00:20 +0000 (05:00 -0700)
committerGitHub <noreply@github.com>
Fri, 27 Jun 2025 12:00:20 +0000 (14:00 +0200)
* 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>
Content.Shared/StatusEffectNew/StatusEffectSystem.API.cs

index 8f34f979307ee15724e6fc1586c95cfa5fe3bad4..14b02dd9db671da9094a7a2d71d4fc811449ac92 100644 (file)
@@ -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.
     /// </param>
+    /// <param name="statusEffect">The EntityUid of the status effect we have just created or null if it doesn't exist.</param>
     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;
     }
 
+    /// <summary>
+    /// An overload of <see cref="TryAddStatusEffect(EntityUid,EntProtoId,out EntityUid?,TimeSpan?,bool)"/>
+    /// that doesn't return a status effect EntityUid.
+    /// </summary>
+    public bool TryAddStatusEffect(
+        EntityUid target,
+        EntProtoId effectProto,
+        TimeSpan? duration = null,
+        bool resetCooldown = false
+    )
+    {
+        return TryAddStatusEffect(target, effectProto, out _, duration, resetCooldown);
+    }
+
     /// <summary>
     /// 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.