diff --git a/Content.Server/Administration/Commands/RejuvenateCommand.cs b/Content.Server/Administration/Commands/RejuvenateCommand.cs index ab6364c045..88412df8c1 100644 --- a/Content.Server/Administration/Commands/RejuvenateCommand.cs +++ b/Content.Server/Administration/Commands/RejuvenateCommand.cs @@ -1,23 +1,19 @@ -using Content.Server.Atmos.Components; -using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.Miasma; using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Server.Disease.Components; using Content.Server.Disease; -using Content.Server.MobState; using Content.Server.Nutrition.Components; using Content.Server.Nutrition.EntitySystems; using Content.Shared.Administration; using Content.Shared.Damage; using Content.Shared.Jittering; -using Content.Shared.MobState.Components; using Content.Shared.Nutrition.Components; +using Content.Shared.Rejuvenate; using Content.Shared.StatusEffect; using Robust.Server.Player; using Robust.Shared.Console; - namespace Content.Server.Administration.Commands { [AdminCommand(AdminFlags.Admin)] @@ -56,47 +52,8 @@ namespace Content.Server.Administration.Commands public static void PerformRejuvenate(EntityUid target) { - var targetUid = target; - var entMan = IoCManager.Resolve(); - entMan.GetComponentOrNull(targetUid)?.ResetFood(); - - // TODO holy shit make this an event my man! - EntitySystem.Get().TryRemoveAllStatusEffects(target); - - if(entMan.TryGetComponent(target , out ThirstComponent? thirst)) - { - EntitySystem.Get().ResetThirst(thirst); - } - - if (entMan.TryGetComponent(target, out FlammableComponent? flammable)) - { - EntitySystem.Get().Extinguish(target, flammable); - } - - if (entMan.TryGetComponent(target, out DamageableComponent? damageable)) - { - EntitySystem.Get().SetAllDamage(damageable, 0); - } - - if (entMan.TryGetComponent(target, out CreamPiedComponent? creamPied)) - { - EntitySystem.Get().SetCreamPied(target, creamPied, false); - } - - if (entMan.TryGetComponent(target, out BloodstreamComponent? bloodStream)) - { - var sys = EntitySystem.Get(); - sys.TryModifyBleedAmount(target, -bloodStream.BleedAmount, bloodStream); - sys.TryModifyBloodLevel(target, bloodStream.BloodSolution.AvailableVolume, bloodStream); - } - - if (entMan.TryGetComponent(target, out var carrier)) - { - EntitySystem.Get().CureAllDiseases(target, carrier); - } - - entMan.RemoveComponent(target); - entMan.RemoveComponent(target); + var entityManager = IoCManager.Resolve(); + entityManager.EventBus.RaiseLocalEvent(target, new RejuvenateEvent()); } } } diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index 9d4b21020d..0fe5cb695b 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Content.Server.Administration.Logs; using Content.Server.Atmos.Components; using Content.Server.Stunnable; @@ -14,11 +12,9 @@ using Content.Shared.Database; using Content.Shared.Interaction; using Content.Shared.Physics; using Content.Shared.Popups; +using Content.Shared.Rejuvenate; using Content.Shared.Temperature; using Robust.Server.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Dynamics; @@ -55,10 +51,11 @@ namespace Content.Server.Atmos.EntitySystems UpdatesAfter.Add(typeof(AtmosphereSystem)); SubscribeLocalEvent(OnMapInit); - SubscribeLocalEvent(OnInteractUsingEvent); - SubscribeLocalEvent(OnCollideEvent); - SubscribeLocalEvent(OnIsHotEvent); - SubscribeLocalEvent(OnTileFireEvent); + SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnCollide); + SubscribeLocalEvent(OnIsHot); + SubscribeLocalEvent(OnTileFire); + SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(IgniteOnCollide); SubscribeLocalEvent(OnMeleeHit); } @@ -73,7 +70,6 @@ namespace Content.Server.Atmos.EntitySystems flammable.FireStacks += component.FireStacks; Ignite(entity, flammable); } - } private void IgniteOnCollide(EntityUid uid, IgniteOnCollideComponent component, ref StartCollideEvent args) @@ -104,7 +100,7 @@ namespace Content.Server.Atmos.EntitySystems }); } - private void OnInteractUsingEvent(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args) + private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args) { if (args.Handled) return; @@ -119,7 +115,7 @@ namespace Content.Server.Atmos.EntitySystems args.Handled = true; } - private void OnCollideEvent(EntityUid uid, FlammableComponent flammable, ref StartCollideEvent args) + private void OnCollide(EntityUid uid, FlammableComponent flammable, ref StartCollideEvent args) { var otherUid = args.OtherFixture.Body.Owner; @@ -157,12 +153,12 @@ namespace Content.Server.Atmos.EntitySystems } } - private void OnIsHotEvent(EntityUid uid, FlammableComponent flammable, IsHotEvent args) + private void OnIsHot(EntityUid uid, FlammableComponent flammable, IsHotEvent args) { args.IsHot = flammable.OnFire; } - private void OnTileFireEvent(EntityUid uid, FlammableComponent flammable, ref TileFireEvent args) + private void OnTileFire(EntityUid uid, FlammableComponent flammable, ref TileFireEvent args) { var tempDelta = args.Temperature - MinIgnitionTemperature; @@ -173,6 +169,11 @@ namespace Content.Server.Atmos.EntitySystems _fireEvents[flammable] = tempDelta; } + private void OnRejuvenate(EntityUid uid, FlammableComponent component, RejuvenateEvent args) + { + Extinguish(uid, component); + } + public void UpdateAppearance(EntityUid uid, FlammableComponent? flammable = null, AppearanceComponent? appearance = null) { if (!Resolve(uid, ref flammable, ref appearance)) diff --git a/Content.Server/Atmos/Miasma/MiasmaSystem.cs b/Content.Server/Atmos/Miasma/MiasmaSystem.cs index fb3c225c87..75ce405c69 100644 --- a/Content.Server/Atmos/Miasma/MiasmaSystem.cs +++ b/Content.Server/Atmos/Miasma/MiasmaSystem.cs @@ -5,6 +5,7 @@ using Content.Server.Atmos.EntitySystems; using Content.Server.Temperature.Systems; using Content.Server.Body.Components; using Content.Shared.Examine; +using Content.Shared.Rejuvenate; using Robust.Server.GameObjects; using Content.Shared.Tag; using Robust.Shared.Containers; @@ -132,6 +133,7 @@ namespace Content.Server.Atmos.Miasma SubscribeLocalEvent(OnMobStateChanged); SubscribeLocalEvent(OnGibbed); SubscribeLocalEvent(OnExamined); + SubscribeLocalEvent(OnRejuvenate); // Containers SubscribeLocalEvent(OnEntInserted); SubscribeLocalEvent(OnEntRemoved); @@ -198,6 +200,11 @@ namespace Content.Server.Atmos.Miasma args.PushMarkup(Loc.GetString(description)); } + private void OnRejuvenate(EntityUid uid, RottingComponent component, RejuvenateEvent args) + { + EntityManager.RemoveComponentDeferred(uid); + } + /// Containers private void OnEntInserted(EntityUid uid, AntiRottingContainerComponent component, EntInsertedIntoContainerMessage args) diff --git a/Content.Server/Atmos/Miasma/RottingComponent.cs b/Content.Server/Atmos/Miasma/RottingComponent.cs index 8d156bf5c1..17219efe61 100644 --- a/Content.Server/Atmos/Miasma/RottingComponent.cs +++ b/Content.Server/Atmos/Miasma/RottingComponent.cs @@ -1,9 +1,9 @@ namespace Content.Server.Atmos.Miasma { - [RegisterComponent] /// /// Tracking component for stuff that has started to rot. /// + [RegisterComponent] public sealed class RottingComponent : Component { /// diff --git a/Content.Server/Body/Systems/BloodstreamSystem.cs b/Content.Server/Body/Systems/BloodstreamSystem.cs index 1dcb81886d..ed5671e35e 100644 --- a/Content.Server/Body/Systems/BloodstreamSystem.cs +++ b/Content.Server/Body/Systems/BloodstreamSystem.cs @@ -13,6 +13,7 @@ using Content.Shared.IdentityManagement; using Content.Shared.MobState.Components; using Content.Shared.Popups; using Content.Shared.Drunk; +using Content.Shared.Rejuvenate; using Robust.Shared.Audio; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -45,6 +46,7 @@ public sealed class BloodstreamSystem : EntitySystem SubscribeLocalEvent(OnBeingGibbed); SubscribeLocalEvent(OnApplyMetabolicMultiplier); SubscribeLocalEvent(OnReactionAttempt); + SubscribeLocalEvent(OnRejuvenate); } private void OnReactionAttempt(EntityUid uid, BloodstreamComponent component, ReactionAttemptEvent args) @@ -216,6 +218,12 @@ public sealed class BloodstreamSystem : EntitySystem component.AccumulatedFrametime = component.UpdateInterval; } + private void OnRejuvenate(EntityUid uid, BloodstreamComponent component, RejuvenateEvent args) + { + TryModifyBleedAmount(uid, -component.BleedAmount, component); + TryModifyBloodLevel(uid, component.BloodSolution.AvailableVolume, component); + } + /// /// Attempt to transfer provided solution to internal solution. /// diff --git a/Content.Server/Disease/DiseaseSystem.cs b/Content.Server/Disease/DiseaseSystem.cs index 3589127bbe..8a2def106e 100644 --- a/Content.Server/Disease/DiseaseSystem.cs +++ b/Content.Server/Disease/DiseaseSystem.cs @@ -21,6 +21,7 @@ using Robust.Shared.Utility; using Content.Shared.IdentityManagement; using Content.Shared.Item; using Content.Server.MobState; +using Content.Shared.Rejuvenate; namespace Content.Server.Disease { @@ -44,6 +45,7 @@ namespace Content.Server.Disease base.Initialize(); SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnTryCureDisease); + SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(OnUserInteractDiseased); SubscribeLocalEvent(OnTargetInteractDiseased); SubscribeLocalEvent(OnEntitySpeak); @@ -188,6 +190,11 @@ namespace Content.Server.Disease } } + private void OnRejuvenate(EntityUid uid, DiseaseCarrierComponent component, RejuvenateEvent args) + { + CureAllDiseases(uid, component); + } + /// /// Called when a component with disease protection /// is equipped so it can be added to the person's diff --git a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs index 4e382cff2b..0130fb853b 100644 --- a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Audio; using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.EntitySystems; using Content.Shared.Popups; +using Content.Shared.Rejuvenate; using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; @@ -19,6 +20,13 @@ namespace Content.Server.Nutrition.EntitySystems [Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!; [Dependency] private readonly SpillableSystem _spillableSystem = default!; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnRejuvenate); + } + protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie) { SoundSystem.Play(creamPie.Sound.GetSound(), Filter.Pvs(creamPie.Owner), creamPie.Owner, AudioHelpers.WithVariation(0.125f)); @@ -36,5 +44,10 @@ namespace Content.Server.Nutrition.EntitySystems creamPied.Owner.PopupMessage(Loc.GetString("cream-pied-component-on-hit-by-message",("thrower", args.Thrown))); creamPied.Owner.PopupMessageOtherClients(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", creamPied.Owner),("thrower", args.Thrown))); } + + private void OnRejuvenate(EntityUid uid, CreamPiedComponent component, RejuvenateEvent args) + { + SetCreamPied(uid, component, false); + } } } diff --git a/Content.Server/Nutrition/EntitySystems/HungerSystem.cs b/Content.Server/Nutrition/EntitySystems/HungerSystem.cs index b66a0ae9d5..b367cbedd6 100644 --- a/Content.Server/Nutrition/EntitySystems/HungerSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/HungerSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Nutrition.Components; +using Content.Shared.Rejuvenate; using JetBrains.Annotations; namespace Content.Server.Nutrition.EntitySystems @@ -8,6 +9,13 @@ namespace Content.Server.Nutrition.EntitySystems { private float _accumulatedFrameTime; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnRejuvenate); + } + public override void Update(float frameTime) { _accumulatedFrameTime += frameTime; @@ -22,5 +30,10 @@ namespace Content.Server.Nutrition.EntitySystems _accumulatedFrameTime -= 1; } } + + private void OnRejuvenate(EntityUid uid, HungerComponent component, RejuvenateEvent args) + { + component.ResetFood(); + } } } diff --git a/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs b/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs index 0158d2ef3b..ac84b8c756 100644 --- a/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs @@ -4,6 +4,7 @@ using Robust.Shared.Random; using Content.Shared.Movement.Components; using Content.Shared.Alert; using Content.Shared.Movement.Systems; +using Content.Shared.Rejuvenate; namespace Content.Server.Nutrition.EntitySystems { @@ -25,6 +26,7 @@ namespace Content.Server.Nutrition.EntitySystems _sawmill = Logger.GetSawmill("thirst"); SubscribeLocalEvent(OnRefreshMovespeed); SubscribeLocalEvent(OnComponentStartup); + SubscribeLocalEvent(OnRejuvenate); } private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args) { @@ -47,6 +49,11 @@ namespace Content.Server.Nutrition.EntitySystems args.ModifySpeed(mod, mod); } + private void OnRejuvenate(EntityUid uid, ThirstComponent component, RejuvenateEvent args) + { + ResetThirst(component); + } + private ThirstThreshold GetThirstThreshold(ThirstComponent component, float amount) { ThirstThreshold result = ThirstThreshold.Dead; diff --git a/Content.Shared/Damage/Systems/DamageableSystem.cs b/Content.Shared/Damage/Systems/DamageableSystem.cs index 92453e9dc9..a9ed977927 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.Inventory; using Content.Shared.MobState; using Content.Shared.MobState.Components; using Content.Shared.Radiation.Events; +using Content.Shared.Rejuvenate; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -21,6 +22,7 @@ namespace Content.Shared.Damage SubscribeLocalEvent(DamageableHandleState); SubscribeLocalEvent(DamageableGetState); SubscribeLocalEvent(OnIrradiated); + SubscribeLocalEvent(OnRejuvenate); } /// @@ -245,6 +247,11 @@ namespace Content.Shared.Damage TryChangeDamage(uid, damage); } + private void OnRejuvenate(EntityUid uid, DamageableComponent component, RejuvenateEvent args) + { + SetAllDamage(component, 0); + } + private void DamageableHandleState(EntityUid uid, DamageableComponent component, ref ComponentHandleState args) { if (args.Current is not DamageableComponentState state) diff --git a/Content.Shared/Jittering/SharedJitteringSystem.cs b/Content.Shared/Jittering/SharedJitteringSystem.cs index 87f90cb708..a9fe8079d2 100644 --- a/Content.Shared/Jittering/SharedJitteringSystem.cs +++ b/Content.Shared/Jittering/SharedJitteringSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Rejuvenate; using Content.Shared.StatusEffect; using Robust.Shared.GameStates; using Robust.Shared.Timing; @@ -22,6 +23,7 @@ namespace Content.Shared.Jittering { SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnRejuvenate); } private void OnGetState(EntityUid uid, JitteringComponent component, ref ComponentGetState args) @@ -38,6 +40,11 @@ namespace Content.Shared.Jittering component.Frequency = jitteringState.Frequency; } + private void OnRejuvenate(EntityUid uid, JitteringComponent component, RejuvenateEvent args) + { + EntityManager.RemoveComponentDeferred(uid); + } + /// /// Applies a jitter effect to the specified entity. /// You can apply this to any entity whatsoever, so be careful what you use it on! diff --git a/Content.Shared/Rejuvenate/RejuvenateEvent.cs b/Content.Shared/Rejuvenate/RejuvenateEvent.cs new file mode 100644 index 0000000000..a6649c6cda --- /dev/null +++ b/Content.Shared/Rejuvenate/RejuvenateEvent.cs @@ -0,0 +1,5 @@ +namespace Content.Shared.Rejuvenate; + +public sealed class RejuvenateEvent : EntityEventArgs +{ +} diff --git a/Content.Shared/StatusEffect/StatusEffectsSystem.cs b/Content.Shared/StatusEffect/StatusEffectsSystem.cs index 2238b3a13c..495a321fad 100644 --- a/Content.Shared/StatusEffect/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffect/StatusEffectsSystem.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Content.Shared.Alert; +using Content.Shared.Rejuvenate; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -22,6 +23,7 @@ namespace Content.Shared.StatusEffect SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnRejuvenate); } public override void Update(float frameTime) @@ -82,6 +84,11 @@ namespace Content.Shared.StatusEffect } } + private void OnRejuvenate(EntityUid uid, StatusEffectsComponent component, RejuvenateEvent args) + { + TryRemoveAllStatusEffects(uid, component); + } + /// /// Tries to add a status effect to an entity, with a given component added as well. ///