Fix two small ambient sound bugs. (#13249)

This commit is contained in:
Leon Friedrich
2023-01-01 13:40:22 +13:00
committed by GitHub
parent c2d3aedc58
commit ccac9efc26
2 changed files with 3 additions and 8 deletions

View File

@@ -86,6 +86,7 @@ namespace Content.Client.Audio
{ {
base.Initialize(); base.Initialize();
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
UpdatesAfter.Add(typeof(AmbientSoundTreeSystem));
_cfg.OnValueChanged(CCVars.AmbientCooldown, SetCooldown, true); _cfg.OnValueChanged(CCVars.AmbientCooldown, SetCooldown, true);
_cfg.OnValueChanged(CCVars.MaxAmbientSources, SetAmbientCount, true); _cfg.OnValueChanged(CCVars.MaxAmbientSources, SetAmbientCount, true);

View File

@@ -15,18 +15,12 @@ namespace Content.Server.Audio
private void HandlePowerSupply(EntityUid uid, AmbientOnPoweredComponent component, ref PowerNetBatterySupplyEvent args) private void HandlePowerSupply(EntityUid uid, AmbientOnPoweredComponent component, ref PowerNetBatterySupplyEvent args)
{ {
if (!EntityManager.TryGetComponent<AmbientSoundComponent>(uid, out var ambientSound)) return; SetAmbience(uid, args.Supply);
if (ambientSound.Enabled == args.Supply) return;
ambientSound.Enabled = args.Supply;
Dirty(ambientSound);
} }
private void HandlePowerChange(EntityUid uid, AmbientOnPoweredComponent component, ref PowerChangedEvent args) private void HandlePowerChange(EntityUid uid, AmbientOnPoweredComponent component, ref PowerChangedEvent args)
{ {
if (!EntityManager.TryGetComponent<AmbientSoundComponent>(uid, out var ambientSound)) return; SetAmbience(uid, args.Powered);
if (ambientSound.Enabled == args.Powered) return;
ambientSound.Enabled = args.Powered;
Dirty(ambientSound);
} }
} }
} }