From 4077f006f4ed45bf28e640787823cdcb1fbcdf79 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 23 Dec 2025 14:41:43 -0600 Subject: [PATCH] Converted SupressPain and Suppress Addiction to the new ECS system. --- .../_DV/Addictions/SharedAddictionSystem.cs | 23 ++++++----- .../Effects/SuppressAddiction.cs | 31 -------------- .../SuppressAddictionEntityEffectSystem.cs | 8 ++-- .../_DV/EntityEffects/Effects/SuppressPain.cs | 38 ----------------- .../Effects/SuppressPainEntityEffectSystem.cs | 41 +++++++++++++++++++ .../Prototypes/_CD/Reagents/medicine.yml | 6 +-- .../_DV/Entities/StatusEffects/misc.yml | 18 ++++---- 7 files changed, 72 insertions(+), 93 deletions(-) delete mode 100644 Content.Shared/_DV/EntityEffects/Effects/SuppressAddiction.cs delete mode 100644 Content.Shared/_DV/EntityEffects/Effects/SuppressPain.cs create mode 100644 Content.Shared/_DV/EntityEffects/Effects/SuppressPainEntityEffectSystem.cs diff --git a/Content.Shared/_DV/Addictions/SharedAddictionSystem.cs b/Content.Shared/_DV/Addictions/SharedAddictionSystem.cs index 6cebe55d7f..234157f38a 100644 --- a/Content.Shared/_DV/Addictions/SharedAddictionSystem.cs +++ b/Content.Shared/_DV/Addictions/SharedAddictionSystem.cs @@ -1,4 +1,4 @@ -using Content.Shared.StatusEffectNew; +using Content.Shared.StatusEffect; using Robust.Shared.Prototypes; namespace Content.Shared._DV.Addictions; @@ -7,33 +7,34 @@ public abstract class SharedAddictionSystem : EntitySystem { [Dependency] private readonly StatusEffectsSystem _statusEffects = default!; - public EntProtoId AddictedStatusEffectProto = "Addicted"; + public ProtoId StatusEffectKey = "Addicted"; protected abstract void UpdateTime(EntityUid uid); - public virtual void TryApplyAddiction(Entity ent, float addictionTime) + public virtual void TryApplyAddiction(EntityUid uid, float addictionTime, StatusEffectsComponent? status = null) { - if (!Resolve(ent.Owner, ref ent.Comp, false)) + if (!Resolve(uid, ref status, false)) return; - UpdateTime(ent.Owner); + UpdateTime(uid); - if (!_statusEffects.HasStatusEffect(ent.Owner, StatusEffectKey, ent.Comp)) + if (!_statusEffects.HasStatusEffect(uid, StatusEffectKey, status)) { - _statusEffects.TryAddStatusEffect(ent.Owner, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), true, ent.Comp); + _statusEffects.TryAddStatusEffect(uid, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), true, status); } else { - _statusEffects.TryAddTime(ent.Owner, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), ent.Comp); + _statusEffects.TryAddTime(uid, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), status); } } - public virtual void TrySuppressAddiction(Entity ent, float duration) + public virtual void TrySuppressAddiction(EntityUid uid, float duration) { - if (!Resolve(ent.Owner, ref ent.Comp, false)) + if (!TryComp(uid, out var comp)) return; - UpdateAddictionSuppression((ent.Owner, ent.Comp), duration); + var ent = new Entity(uid, comp); + UpdateAddictionSuppression(ent, duration); } protected virtual void UpdateAddictionSuppression(Entity ent, float duration) diff --git a/Content.Shared/_DV/EntityEffects/Effects/SuppressAddiction.cs b/Content.Shared/_DV/EntityEffects/Effects/SuppressAddiction.cs deleted file mode 100644 index c4a37cc6de..0000000000 --- a/Content.Shared/_DV/EntityEffects/Effects/SuppressAddiction.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Content.Shared._DV.Addictions; -using Content.Shared.EntityEffects; -using Robust.Shared.Prototypes; - -namespace Content.Shared._DV.EntityEffects.Effects; - -public sealed partial class SuppressAddiction : EntityEffect -{ - /// - /// How long should the addiction suppression last for each metabolism cycle - /// - [DataField] - public float SuppressionTime = 30f; - - protected override string ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) - => Loc.GetString("reagent-effect-guidebook-addiction-suppression", - ("chance", Probability)); - - public override void Effect(EntityEffectBaseArgs args) - { - var suppressionTime = SuppressionTime; - - if (args is EntityEffectReagentArgs reagentArgs) - { - suppressionTime *= reagentArgs.Scale.Float(); - } - - var addictionSystem = args.EntityManager.System(); - addictionSystem.TrySuppressAddiction(args.TargetEntity, suppressionTime); - } -} diff --git a/Content.Shared/_DV/EntityEffects/Effects/SuppressAddictionEntityEffectSystem.cs b/Content.Shared/_DV/EntityEffects/Effects/SuppressAddictionEntityEffectSystem.cs index fd1ebf40c1..b00cc0da96 100644 --- a/Content.Shared/_DV/EntityEffects/Effects/SuppressAddictionEntityEffectSystem.cs +++ b/Content.Shared/_DV/EntityEffects/Effects/SuppressAddictionEntityEffectSystem.cs @@ -13,7 +13,9 @@ public sealed partial class SuppressAddictionEntityEffectSystem : EntityEffectSy [Dependency] private readonly SharedAddictionSystem _addiction = default!; protected override void Effect(Entity entity, ref EntityEffectEvent args) { - // Effect goes here. + var suppressionTime = args.Effect.Time * args.Scale; + + _addiction.TrySuppressAddiction(entity.Owner, suppressionTime); } } @@ -21,10 +23,10 @@ public sealed partial class SuppressAddictionEntityEffectSystem : EntityEffectSy public sealed partial class SuppressAddition : EntityEffectBase { /// - /// Amount we're adjusting temperature by. + /// Amount of time that 1u suppresses addiction. /// [DataField] - public float SuppressionTime = 30; + public float Time = 30f; public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-addiction-suppression", diff --git a/Content.Shared/_DV/EntityEffects/Effects/SuppressPain.cs b/Content.Shared/_DV/EntityEffects/Effects/SuppressPain.cs deleted file mode 100644 index a0d058da18..0000000000 --- a/Content.Shared/_DV/EntityEffects/Effects/SuppressPain.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Content.Shared._DV.Pain; -using Content.Shared.EntityEffects; -using Robust.Shared.Prototypes; - -namespace Content.Shared._DV.EntityEffects.Effects; - -public sealed partial class SuppressPain : EntityEffect -{ - /// - /// How long should the pain suppression last for each metabolism cycle - /// - [DataField] - public float SuppressionTime = 30f; - - /// - /// The strength level of the pain suppression - /// - [DataField] - public PainSuppressionLevel SuppressionLevel = PainSuppressionLevel.Normal; - - protected override string ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) - => Loc.GetString("reagent-effect-guidebook-pain-suppression", - ("chance", Probability), - ("level", SuppressionLevel.ToString().ToLowerInvariant())); - - public override void Effect(EntityEffectBaseArgs args) - { - var suppressionTime = SuppressionTime; - - if (args is EntityEffectReagentArgs reagentArgs) - { - suppressionTime *= reagentArgs.Scale.Float(); - } - - var painSystem = args.EntityManager.System(); - painSystem.TrySuppressPain(args.TargetEntity, suppressionTime, SuppressionLevel); - } -} diff --git a/Content.Shared/_DV/EntityEffects/Effects/SuppressPainEntityEffectSystem.cs b/Content.Shared/_DV/EntityEffects/Effects/SuppressPainEntityEffectSystem.cs new file mode 100644 index 0000000000..cdd346187d --- /dev/null +++ b/Content.Shared/_DV/EntityEffects/Effects/SuppressPainEntityEffectSystem.cs @@ -0,0 +1,41 @@ +using Content.Shared._DV.Pain; +using Content.Shared.EntityEffects; +using Robust.Shared.Prototypes; + +namespace Content.Shared._DV.EntityEffects.Effects; + +/// +/// A brief summary of the effect. +/// +/// +public sealed partial class SuppressPainEntityEffectSystem : EntityEffectSystem +{ + [Dependency] private readonly SharedPainSystem _pain = default!; + protected override void Effect(Entity entity, ref EntityEffectEvent args) + { + var suppressionTime = args.Effect.Time * args.Scale; + + _pain.TrySuppressPain(entity, suppressionTime, args.Effect.Level); + } +} + +/// +public sealed partial class SuppressPain : EntityEffectBase +{ + /// + /// How long should the pain suppression last for each metabolism cycle + /// + [DataField] + public float Time = 30f; + + /// + /// The strength level of the pain suppression. + /// + [DataField] + public PainSuppressionLevel Level = PainSuppressionLevel.Normal; + + public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) + => Loc.GetString("reagent-effect-guidebook-pain-suppression", + ("chance", Probability), + ("level", Level.ToString().ToLowerInvariant())); +} diff --git a/Resources/Prototypes/_CD/Reagents/medicine.yml b/Resources/Prototypes/_CD/Reagents/medicine.yml index c90441d60a..4358af4a5a 100644 --- a/Resources/Prototypes/_CD/Reagents/medicine.yml +++ b/Resources/Prototypes/_CD/Reagents/medicine.yml @@ -444,7 +444,7 @@ metabolismRate : 0.02 effects: - !type:SuppressPain - suppressionLevel: Mild + level: Mild - !type:PopupMessage type: Local visualType: Medium @@ -502,7 +502,7 @@ metabolismRate : 0.01 effects: - !type:SuppressPain - suppressionLevel: Normal + level: Normal - !type:SuppressAddiction - !type:PopupMessage type: Local @@ -550,7 +550,7 @@ metabolismRate : 0.01 effects: - !type:SuppressPain - suppressionLevel: Strong + level: Strong - !type:SuppressAddiction - !type:PopupMessage type: Local diff --git a/Resources/Prototypes/_DV/Entities/StatusEffects/misc.yml b/Resources/Prototypes/_DV/Entities/StatusEffects/misc.yml index 2337d9dac7..ef4e8afb04 100644 --- a/Resources/Prototypes/_DV/Entities/StatusEffects/misc.yml +++ b/Resources/Prototypes/_DV/Entities/StatusEffects/misc.yml @@ -1,7 +1,11 @@ -# Blurs your vision and makes you randomly fall asleep -- type: entity - parent: MobStatusEffectDebuff - id: StatusEffectAddicted - name: addicted - components: - - type: AddictedStatusEffect \ No newline at end of file +# TODO: Migrate the following OLD status effects + +# * addicted +# * + +#- type: entity +# parent: MobStatusEffectDebuff +# id: StatusEffectAddicted +# name: addicted +# components: +# - type: AddictedStatusEffect \ No newline at end of file