improve sleeping mob state changes (#11083)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -18,5 +18,8 @@ namespace Content.Server.Sound.Components
|
||||
// Always Pvs.
|
||||
[DataField("popUp")]
|
||||
public string? PopUp;
|
||||
|
||||
[DataField("enabled")]
|
||||
public bool Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user