Files
tbd-station-14/Content.Shared/EntityEffects/Effects/StatusEffects/GenericStatusEffect.cs
Red 78a94730be New status effect system (#37238)
* spectra

* documentation

* added into liquid anomaly

* Update TemporaryStealthComponent.cs

* Update TemporaryStealthComponent.cs

* integrated

* new system

* mark old status effect system as obsolete

* ForcedSleeping new status effect

* work with reagents

* networking???

* Revert "integrated"

This reverts commit bca02b82bae18ae131af593d7eb86e6de2745157.

* Revert "Update TemporaryStealthComponent.cs"

This reverts commit 4a5be8c4b704a0d1ff9544b2e245d8b2701ec580.

* Revert "Update TemporaryStealthComponent.cs"

This reverts commit a4875bcb41347638854bd723d96a51c3e6d38034.

* Revert "added into liquid anomaly"

This reverts commit df5086b14bb35f1467158a36807c0f2163a16d99.

* Revert "documentation"

This reverts commit 3629b9466758cbdfa4dd5e67ece122fa2f181138.

* Revert "spectra"

This reverts commit 2d03d88c16d16ad6831c19a7921b84600daeb284.

* drowsiness status effect remove

* reagents work

* polish, remove test changes

* first Fildrance review part

* Update misc.yml

* more fildrance review

* final part

* fix trailing spaces

* sleeping status effect

* drowsiness status effect

* Create ModifyStatusEffect.cs

* some tweak

* Yay!!! Manual networking

* minor nitpick

* oopsie

* refactor: xml-docs, notnullwhen attributes, whitespaces

* fildrance and emo review

* refactor: simplify check in SharedStatusEffectsSystem by using pattern matching, TryEffectsWithComp now returns set of Entity<T, StatusEffectComponent>

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-06-25 07:41:35 -04:00

76 lines
2.5 KiB
C#

using Content.Shared.Chemistry.Reagent;
using Content.Shared.StatusEffect;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects.StatusEffects;
/// <summary>
/// Adds a generic status effect to the entity,
/// not worrying about things like how to affect the time it lasts for
/// or component fields or anything. Just adds a component to an entity
/// for a given time. Easy.
/// </summary>
/// <remarks>
/// Can be used for things like adding accents or something. I don't know. Go wild.
/// </remarks>
[Obsolete("Use ModifyStatusEffect with StatusEffectNewSystem instead")]
public sealed partial class GenericStatusEffect : EntityEffect
{
[DataField(required: true)]
public string Key = default!;
[DataField]
public string Component = String.Empty;
[DataField]
public float Time = 2.0f;
/// <remarks>
/// true - refresh status effect time, false - accumulate status effect time
/// </remarks>
[DataField]
public bool Refresh = true;
/// <summary>
/// Should this effect add the status effect, remove time from it, or set its cooldown?
/// </summary>
[DataField]
public StatusEffectMetabolismType Type = StatusEffectMetabolismType.Add;
public override void Effect(EntityEffectBaseArgs args)
{
var statusSys = args.EntityManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>();
var time = Time;
if (args is EntityEffectReagentArgs reagentArgs)
time *= reagentArgs.Scale.Float();
if (Type == StatusEffectMetabolismType.Add && Component != String.Empty)
{
statusSys.TryAddStatusEffect(args.TargetEntity, Key, TimeSpan.FromSeconds(time), Refresh, Component);
}
else if (Type == StatusEffectMetabolismType.Remove)
{
statusSys.TryRemoveTime(args.TargetEntity, Key, TimeSpan.FromSeconds(time));
}
else if (Type == StatusEffectMetabolismType.Set)
{
statusSys.TrySetTime(args.TargetEntity, Key, TimeSpan.FromSeconds(time));
}
}
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString(
"reagent-effect-guidebook-status-effect",
("chance", Probability),
("type", Type),
("time", Time),
("key", $"reagent-effect-status-effect-{Key}"));
}
public enum StatusEffectMetabolismType
{
Add,
Remove,
Set
}