diff --git a/Content.Server/Atmos/Miasma/MiasmaSystem.cs b/Content.Server/Atmos/Miasma/MiasmaSystem.cs index 75ce405c69..f298a37041 100644 --- a/Content.Server/Atmos/Miasma/MiasmaSystem.cs +++ b/Content.Server/Atmos/Miasma/MiasmaSystem.cs @@ -6,8 +6,8 @@ using Content.Server.Temperature.Systems; using Content.Server.Body.Components; using Content.Shared.Examine; using Content.Shared.Rejuvenate; +using Content.Shared.MobState.EntitySystems; using Robust.Server.GameObjects; -using Content.Shared.Tag; using Robust.Shared.Containers; using Robust.Shared.Physics.Components; using Robust.Shared.Random; @@ -19,6 +19,8 @@ namespace Content.Server.Atmos.Miasma [Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!; + [Dependency] private readonly SharedMobStateSystem _mobState = default!; + [Dependency] private readonly IRobustRandom _random = default!; /// System Variables @@ -66,7 +68,7 @@ namespace Content.Server.Atmos.Miasma /// private float _poolAccumulator = 0f; - /// + /// /// How long without an infection before we pick a new disease. /// private TimeSpan _poolRepickTime = TimeSpan.FromMinutes(5); @@ -165,7 +167,7 @@ namespace Content.Server.Atmos.Miasma private void OnMobStateChanged(EntityUid uid, PerishableComponent component, MobStateChangedEvent args) { - if (args.Component.IsDead()) + if (_mobState.IsDead(uid)) EnsureComp(uid); } @@ -218,7 +220,9 @@ namespace Content.Server.Atmos.Miasma private void OnEntRemoved(EntityUid uid, AntiRottingContainerComponent component, EntRemovedFromContainerMessage args) { - if (TryComp(args.Entity, out var perishable) && !Terminating(uid)) + // If we get de-parented due to entity shutdown don't add more flies. + if (TryComp(args.Entity, out var perishable) && + TryComp(uid, out var metadata) && metadata.EntityLifeStage < EntityLifeStage.Terminating) { ModifyPreservationSource(args.Entity, false); ToggleDecomposition(args.Entity, true, perishable); @@ -230,7 +234,6 @@ namespace Content.Server.Atmos.Miasma private void OnFliesInit(EntityUid uid, FliesComponent component, ComponentInit args) { component.VirtFlies = EntityManager.SpawnEntity("AmbientSoundSourceFlies", Transform(uid).Coordinates); - Transform(component.VirtFlies).AttachParent(uid); } private void OnFliesShutdown(EntityUid uid, FliesComponent component, ComponentShutdown args)