improve sleeping mob state changes (#11083)

This commit is contained in:
Rane
2022-09-07 00:37:32 -04:00
committed by GitHub
parent d320ad950b
commit 1e62627ecb
3 changed files with 11 additions and 5 deletions

View File

@@ -107,14 +107,14 @@ namespace Content.Server.Bed.Sleep
/// </summary>
private void OnMobStateChanged(EntityUid uid, SleepingComponent component, MobStateChangedEvent args)
{
if (_mobStateSystem.IsCritical(uid) && !HasComp<ForcedSleepingComponent>(uid))
if (args.CurrentMobState == DamageState.Dead)
{
RemComp<SpamEmitSoundComponent>(uid);
RemComp<SleepingComponent>(uid);
return;
}
if (_mobStateSystem.IsDead(uid))
RemComp<SleepingComponent>(uid);
if (TryComp<SpamEmitSoundComponent>(uid, out var spam))
spam.Enabled = (args.CurrentMobState == DamageState.Alive) ? true : false;
}
private void AddWakeVerb(EntityUid uid, SleepingComponent component, GetVerbsEvent<AlternativeVerb> args)

View File

@@ -18,5 +18,8 @@ namespace Content.Server.Sound.Components
// Always Pvs.
[DataField("popUp")]
public string? PopUp;
[DataField("enabled")]
public bool Enabled = true;
}
}

View File

@@ -36,6 +36,9 @@ namespace Content.Server.Sound
base.Update(frameTime);
foreach (var soundSpammer in EntityQuery<SpamEmitSoundComponent>())
{
if (!soundSpammer.Enabled)
continue;
soundSpammer.Accumulator += frameTime;
if (soundSpammer.Accumulator < soundSpammer.RollInterval)
{