From 1e62627ecbfce364d635f209d46142e4735e3b3b Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Wed, 7 Sep 2022 00:37:32 -0400 Subject: [PATCH] improve sleeping mob state changes (#11083) --- Content.Server/Bed/Sleep/SleepingSystem.cs | 10 +++++----- .../Sound/Components/SpamEmitSoundComponent.cs | 3 +++ Content.Server/Sound/EmitSoundSystem.cs | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Content.Server/Bed/Sleep/SleepingSystem.cs b/Content.Server/Bed/Sleep/SleepingSystem.cs index 1c9f60e124..ae6cd54140 100644 --- a/Content.Server/Bed/Sleep/SleepingSystem.cs +++ b/Content.Server/Bed/Sleep/SleepingSystem.cs @@ -57,7 +57,7 @@ namespace Content.Server.Bed.Sleep var emitSound = EnsureComp(uid); - // TODO WTF is this, these should a data fields and not hard-coded. + // TODO WTF is this, these should a data fields and not hard-coded. emitSound.Sound = new SoundCollectionSpecifier("Snores", AudioParams.Default.WithVariation(0.2f)); emitSound.PlayChance = 0.33f; emitSound.RollInterval = 5f; @@ -107,14 +107,14 @@ namespace Content.Server.Bed.Sleep /// private void OnMobStateChanged(EntityUid uid, SleepingComponent component, MobStateChangedEvent args) { - if (_mobStateSystem.IsCritical(uid) && !HasComp(uid)) + if (args.CurrentMobState == DamageState.Dead) { + RemComp(uid); RemComp(uid); return; } - - if (_mobStateSystem.IsDead(uid)) - RemComp(uid); + if (TryComp(uid, out var spam)) + spam.Enabled = (args.CurrentMobState == DamageState.Alive) ? true : false; } private void AddWakeVerb(EntityUid uid, SleepingComponent component, GetVerbsEvent args) diff --git a/Content.Server/Sound/Components/SpamEmitSoundComponent.cs b/Content.Server/Sound/Components/SpamEmitSoundComponent.cs index 3378421be9..3058a3c65c 100644 --- a/Content.Server/Sound/Components/SpamEmitSoundComponent.cs +++ b/Content.Server/Sound/Components/SpamEmitSoundComponent.cs @@ -18,5 +18,8 @@ namespace Content.Server.Sound.Components // Always Pvs. [DataField("popUp")] public string? PopUp; + + [DataField("enabled")] + public bool Enabled = true; } } diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index 58dd21186b..64a5c34535 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -36,6 +36,9 @@ namespace Content.Server.Sound base.Update(frameTime); foreach (var soundSpammer in EntityQuery()) { + if (!soundSpammer.Enabled) + continue; + soundSpammer.Accumulator += frameTime; if (soundSpammer.Accumulator < soundSpammer.RollInterval) {