using Content.Shared.StatusEffectNew;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects.StatusEffects;
///
/// Applies a given status effect to this entity.
/// Duration is modified by scale.
///
///
public sealed partial class ModifyStatusEffectEntityEffectSystem : EntityEffectSystem
{
[Dependency] private readonly StatusEffectsSystem _status = default!;
protected override void Effect(Entity entity, ref EntityEffectEvent args)
{
var time = args.Effect.Time * args.Scale;
var delay = args.Effect.Delay;
switch (args.Effect.Type)
{
case StatusEffectMetabolismType.Update:
_status.TryUpdateStatusEffectDuration(entity, args.Effect.EffectProto, time, delay);
break;
case StatusEffectMetabolismType.Add:
if (time != null)
_status.TryAddStatusEffectDuration(entity, args.Effect.EffectProto, time.Value, delay);
else
_status.TryUpdateStatusEffectDuration(entity, args.Effect.EffectProto, time, delay);
break;
case StatusEffectMetabolismType.Remove:
_status.TryRemoveTime(entity, args.Effect.EffectProto, time);
break;
case StatusEffectMetabolismType.Set:
_status.TrySetStatusEffectDuration(entity, args.Effect.EffectProto, time, delay);
break;
}
}
}
///
public sealed partial class ModifyStatusEffect : BaseStatusEntityEffect
{
///
/// Prototype of the status effect we're modifying.
///
[DataField(required: true)]
public EntProtoId EffectProto;
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Time == null
? Loc.GetString(
"entity-effect-guidebook-status-effect-indef",
("chance", Probability),
("type", Type),
("key", prototype.Index(EffectProto).Name),
("delay", Delay.TotalSeconds))
: Loc.GetString(
"entity-effect-guidebook-status-effect",
("chance", Probability),
("type", Type),
("time", Time.Value.TotalSeconds),
("key", prototype.Index(EffectProto).Name),
("delay", Delay.TotalSeconds));
}