diff --git a/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs b/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs index d10600ab56..feb5dd4140 100644 --- a/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs +++ b/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs @@ -1,14 +1,19 @@ using Content.Shared.Damage.Components; using Content.Shared.Damage.Events; using Content.Shared.Destructible; +using Content.Shared.Prototypes; using Content.Shared.Rejuvenate; using Content.Shared.Slippery; +using Content.Shared.StatusEffect; using Content.Shared.StatusEffectNew; +using Content.Shared.StatusEffectNew.Components; +using Robust.Shared.Prototypes; namespace Content.Shared.Damage.Systems; public abstract class SharedGodmodeSystem : EntitySystem { + [Dependency] private readonly IPrototypeManager _protoMan = default!; [Dependency] private readonly DamageableSystem _damageable = default!; public override void Initialize() @@ -17,6 +22,7 @@ public abstract class SharedGodmodeSystem : EntitySystem SubscribeLocalEvent(OnBeforeDamageChanged); SubscribeLocalEvent(OnBeforeStatusEffect); + SubscribeLocalEvent(OnBeforeOldStatusEffect); SubscribeLocalEvent(OnBeforeStaminaDamage); SubscribeLocalEvent(OnSlipAttempt); SubscribeLocalEvent(OnDestruction); @@ -34,6 +40,13 @@ public abstract class SharedGodmodeSystem : EntitySystem private void OnBeforeStatusEffect(EntityUid uid, GodmodeComponent component, ref BeforeStatusEffectAddedEvent args) { + if (_protoMan.Index(args.Effect).HasComponent(Factory)) + args.Cancelled = true; + } + + private void OnBeforeOldStatusEffect(Entity ent, ref BeforeOldStatusEffectAddedEvent args) + { + // Old status effect system doesn't distinguish between good and bad status effects args.Cancelled = true; } diff --git a/Content.Shared/StatusEffect/StatusEffectsSystem.cs b/Content.Shared/StatusEffect/StatusEffectsSystem.cs index b56acd3cc5..c0c409d168 100644 --- a/Content.Shared/StatusEffect/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffect/StatusEffectsSystem.cs @@ -353,7 +353,7 @@ namespace Content.Shared.StatusEffect if (!Resolve(uid, ref status, false)) return false; - var ev = new BeforeStatusEffectAddedEvent(key); + var ev = new BeforeOldStatusEffectAddedEvent(key); RaiseLocalEvent(uid, ref ev); if (ev.Cancelled) return false; @@ -481,6 +481,13 @@ namespace Content.Shared.StatusEffect } } + /// + /// Raised on an entity before a status effect is added to determine if adding it should be cancelled. + /// Obsolete version of + /// + [ByRefEvent, Obsolete("Migration to StatusEffectNew.StatusEffectsSystem is required")] + public record struct BeforeOldStatusEffectAddedEvent(string EffectKey, bool Cancelled = false); + public readonly struct StatusEffectAddedEvent { public readonly EntityUid Uid; diff --git a/Content.Shared/StatusEffectNew/Components/RejuvenateRemovedStatusEffectComponent.cs b/Content.Shared/StatusEffectNew/Components/RejuvenateRemovedStatusEffectComponent.cs new file mode 100644 index 0000000000..808830f7e2 --- /dev/null +++ b/Content.Shared/StatusEffectNew/Components/RejuvenateRemovedStatusEffectComponent.cs @@ -0,0 +1,14 @@ +using Content.Shared.Damage.Components; +using Content.Shared.Rejuvenate; +using Robust.Shared.GameStates; + +namespace Content.Shared.StatusEffectNew.Components; + +/// +/// Marker component for a status effect that should be removed on rejuvenation +/// and should not be applied on targets with . +/// Only applies to effects using the new . +/// +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class RejuvenateRemovedStatusEffectComponent : Component; diff --git a/Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs b/Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs index 96ef012168..0c4c5cf1f7 100644 --- a/Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs +++ b/Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs @@ -1,5 +1,6 @@ using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; +using Content.Shared.Rejuvenate; using Content.Shared.StatusEffectNew.Components; using Content.Shared.Stunnable; using Robust.Shared.Player; @@ -12,6 +13,7 @@ public sealed partial class StatusEffectsSystem { SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); + SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); diff --git a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs index ce595109b3..7f8eef5102 100644 --- a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Content.Shared.Rejuvenate; using Content.Shared.StatusEffectNew.Components; using Content.Shared.Whitelist; using Robust.Shared.Containers; @@ -32,6 +33,8 @@ public sealed partial class StatusEffectsSystem : EntitySystem SubscribeLocalEvent(OnEntityInserted); SubscribeLocalEvent(OnEntityRemoved); + SubscribeLocalEvent>(OnRejuvenate); + _containerQuery = GetEntityQuery(); _effectQuery = GetEntityQuery(); } @@ -115,6 +118,12 @@ public sealed partial class StatusEffectsSystem : EntitySystem Dirty(args.Entity, statusComp); } + private void OnRejuvenate(Entity ent, + ref StatusEffectRelayedEvent args) + { + PredictedQueueDel(ent.Owner); + } + private void SetStatusEffectTime(EntityUid effect, TimeSpan? duration) { if (!_effectQuery.TryComp(effect, out var effectComp)) diff --git a/Resources/Prototypes/Entities/StatusEffects/misc.yml b/Resources/Prototypes/Entities/StatusEffects/misc.yml index 273a52c0a8..3ce81081c0 100644 --- a/Resources/Prototypes/Entities/StatusEffects/misc.yml +++ b/Resources/Prototypes/Entities/StatusEffects/misc.yml @@ -19,8 +19,17 @@ components: - MobState +# Things that should be removed by rejuvenation should parent to this +# Also blocks the status effect being added to godmode-ed entities. - type: entity - parent: StatusEffectBase + parent: MobStatusEffectBase + id: MobStatusEffectDebuff + abstract: true + components: + - type: RejuvenateRemovedStatusEffect + +- type: entity + parent: MobStatusEffectDebuff id: MobStandStatusEffectBase abstract: true components: @@ -36,7 +45,7 @@ # The creature sleeps so heavily that nothing can wake him up. Not even its own death. - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectDebuff id: StatusEffectForcedSleeping name: forced sleep components: @@ -46,7 +55,7 @@ # This creature is asleep because it's disconnected from the game. - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectBase # Not even rejuvenate can cure SSD... id: StatusEffectSSDSleeping name: forced sleep components: @@ -56,7 +65,7 @@ # Blurs your vision and makes you randomly fall asleep - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectDebuff id: StatusEffectDrowsiness name: drowsiness components: @@ -64,7 +73,7 @@ # Adds drugs overlay - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectDebuff id: StatusEffectSeeingRainbow name: hallucinations components: diff --git a/Resources/Prototypes/Entities/StatusEffects/movement.yml b/Resources/Prototypes/Entities/StatusEffects/movement.yml index b6fa426f72..a6cbd20724 100644 --- a/Resources/Prototypes/Entities/StatusEffects/movement.yml +++ b/Resources/Prototypes/Entities/StatusEffects/movement.yml @@ -1,5 +1,5 @@ - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectDebuff id: StatusEffectSlowdown abstract: true name: slowdown @@ -35,7 +35,7 @@ # Makes you more slippery, or perhaps less slippery. - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectDebuff # Debatable if this should be MobStatusEffectBase or not id: StatusEffectFriction name: friction components: @@ -44,7 +44,7 @@ # Stunnable Status Effect - type: entity - parent: MobStatusEffectBase + parent: MobStatusEffectDebuff id: StatusEffectStunned name: stunned components: