From d00f9a054b2a8fbc71aae6fb3f2c566cfbe623d0 Mon Sep 17 00:00:00 2001 From: Anri Date: Sat, 11 Jan 2025 15:52:36 +0300 Subject: [PATCH] Audio hater's PR (#2473) --- Content.Server/Telephone/TelephoneSystem.cs | 16 +++++++++++++++- .../Movement/Systems/MovementSoundSystem.cs | 14 ++++++++++++++ .../Movement/Systems/SharedMoverController.cs | 6 +++++- .../SS220/CCVars/CCVars220.Performance.cs | 12 ++++++++++++ Content.Shared/SS220/CCVars/CCVars220.cs | 2 +- Content.Shared/Sound/SharedEmitSoundSystem.cs | 12 +++++++++++- 6 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 Content.Shared/SS220/CCVars/CCVars220.Performance.cs diff --git a/Content.Server/Telephone/TelephoneSystem.cs b/Content.Server/Telephone/TelephoneSystem.cs index b4874191074c..c1d51f413d78 100644 --- a/Content.Server/Telephone/TelephoneSystem.cs +++ b/Content.Server/Telephone/TelephoneSystem.cs @@ -22,6 +22,8 @@ using Content.Shared.Silicons.StationAi; using Content.Shared.Silicons.Borgs.Components; using Content.Shared.SS220.TTS; +using Content.Shared.SS220.CCVars; +using Robust.Shared.Configuration; namespace Content.Server.Telephone; @@ -38,6 +40,11 @@ public sealed class TelephoneSystem : SharedTelephoneSystem [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IReplayRecordingManager _replay = default!; + // SS220 performance-test-begin + [Dependency] private readonly IConfigurationManager _configManager = default!; + private bool _lessSound; + // SS220 performance-test-end + // Has set used to prevent telephone feedback loops private HashSet<(EntityUid, string, Entity)> _recentChatMessages = new(); @@ -50,6 +57,8 @@ public override void Initialize() SubscribeLocalEvent(OnAttemptListen); SubscribeLocalEvent(OnListen); SubscribeLocalEvent(OnTelephoneMessageReceived); + + Subs.CVar(_configManager, CCVars220.LessSoundSources, value => _lessSound = value, true); // SS220 performance-test } #region: Events @@ -151,6 +160,11 @@ public override void Update(float frameTime) if (_timing.CurTime > telephone.StateStartTime + TimeSpan.FromSeconds(telephone.RingingTimeout)) EndTelephoneCalls(entity); + // SS220 performance-test + if (_lessSound) + break; + // SS220 performace-test + else if (telephone.RingTone != null && _timing.CurTime > telephone.NextRingToneTime) { @@ -160,7 +174,7 @@ public override void Update(float frameTime) break; - // Try to hang up if their has been no recent in-call activity + // Try to hang up if their has been no recent in-call activity case TelephoneState.InCall: if (_timing.CurTime > telephone.StateStartTime + TimeSpan.FromSeconds(telephone.IdlingTimeout)) EndTelephoneCalls(entity); diff --git a/Content.Shared/Movement/Systems/MovementSoundSystem.cs b/Content.Shared/Movement/Systems/MovementSoundSystem.cs index 9a1146779fac..a37b37f3cf35 100644 --- a/Content.Shared/Movement/Systems/MovementSoundSystem.cs +++ b/Content.Shared/Movement/Systems/MovementSoundSystem.cs @@ -1,6 +1,8 @@ using Content.Shared.Movement.Components; using Content.Shared.Movement.Events; +using Content.Shared.SS220.CCVars; using Robust.Shared.Audio.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -14,10 +16,17 @@ public sealed class MovementSoundSystem : EntitySystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + // SS220 performance-test-begin + [Dependency] private readonly IConfigurationManager _configManager = default!; + private bool _lessSound; + // SS220 performance-test-end + public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnMoveInput); + + Subs.CVar(_configManager, CCVars220.LessSoundSources, value => _lessSound = value, true); // SS220 performance-test } private void OnMoveInput(Entity ent, ref MoveInputEvent args) @@ -31,6 +40,11 @@ private void OnMoveInput(Entity ent, ref MoveInputEvent if (oldMoving == moving) return; + // SS220 performance-test + if (_lessSound) + return; + // SS220 performace-test + if (moving) { DebugTools.Assert(ent.Comp.SoundEntity == null); diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index 472d56b1d692..ca8c4cd47d3e 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -9,6 +9,7 @@ using Content.Shared.Mobs.Systems; using Content.Shared.Movement.Components; using Content.Shared.Movement.Events; +using Content.Shared.SS220.CCVars; using Content.Shared.Tag; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; @@ -66,6 +67,7 @@ public abstract partial class SharedMoverController : VirtualController private float _stopSpeed; private bool _relativeMovement; + private bool _lessSound; // SS220 Performance-test /// /// Cache the mob movement calculation to re-use elsewhere. @@ -93,6 +95,7 @@ public override void Initialize() InitializeRelay(); Subs.CVar(_configManager, CCVars.RelativeMovement, value => _relativeMovement = value, true); Subs.CVar(_configManager, CCVars.StopSpeed, value => _stopSpeed = value, true); + Subs.CVar(_configManager, CCVars220.LessSoundSources, value => _lessSound = value, true); // SS220 performance-test UpdatesBefore.Add(typeof(TileFrictionController)); } @@ -401,7 +404,8 @@ private bool TryGetSound( { sound = null; - if (!CanSound() || !_tags.HasTag(uid, "FootstepSound")) + // if (!CanSound() || !_tags.HasTag(uid, "FootstepSound") // SS220 performance test + if (!CanSound() || !_tags.HasTag(uid, "FootstepSound") || _lessSound) // SS220 performance test return false; var coordinates = xform.Coordinates; diff --git a/Content.Shared/SS220/CCVars/CCVars220.Performance.cs b/Content.Shared/SS220/CCVars/CCVars220.Performance.cs new file mode 100644 index 000000000000..402dd88df16c --- /dev/null +++ b/Content.Shared/SS220/CCVars/CCVars220.Performance.cs @@ -0,0 +1,12 @@ +using Robust.Shared.Configuration; + +namespace Content.Shared.SS220.CCVars; + +public sealed partial class CCVars220 +{ + /// + /// Cvar which turns off most of player generatish sounds like steps, telephones and etc. Do not affect TTS. + /// + public static readonly CVarDef LessSoundSources = + CVarDef.Create("audio.less_sound_sources", false, CVar.SERVER | CVar.REPLICATED, "serve to turn off most of player generatish sounds like steps, telephones and etc. Do not affect TTS."); +} diff --git a/Content.Shared/SS220/CCVars/CCVars220.cs b/Content.Shared/SS220/CCVars/CCVars220.cs index c03fed725852..a1b14a110161 100644 --- a/Content.Shared/SS220/CCVars/CCVars220.cs +++ b/Content.Shared/SS220/CCVars/CCVars220.cs @@ -3,7 +3,7 @@ namespace Content.Shared.SS220.CCVars; [CVarDefs] -public sealed class CCVars220 +public sealed partial class CCVars220 { /// /// Whether is bloom lighting eanbled or not diff --git a/Content.Shared/Sound/SharedEmitSoundSystem.cs b/Content.Shared/Sound/SharedEmitSoundSystem.cs index f92b30250e08..940734e53503 100644 --- a/Content.Shared/Sound/SharedEmitSoundSystem.cs +++ b/Content.Shared/Sound/SharedEmitSoundSystem.cs @@ -7,12 +7,14 @@ using Content.Shared.Mobs; using Content.Shared.Popups; using Content.Shared.Sound.Components; +using Content.Shared.SS220.CCVars; using Content.Shared.Throwing; using Content.Shared.UserInterface; using Content.Shared.Whitelist; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; @@ -39,6 +41,11 @@ public abstract class SharedEmitSoundSystem : EntitySystem [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; + // SS220 performance-test-begin + [Dependency] private readonly IConfigurationManager _configManager = default!; + private bool _lessSound; + // SS220 performance-test-end + public override void Initialize() { base.Initialize(); @@ -55,6 +62,8 @@ public override void Initialize() SubscribeLocalEvent(OnEmitSoundOnCollide); SubscribeLocalEvent(OnMobState); + + Subs.CVar(_configManager, CCVars220.LessSoundSources, value => _lessSound = value, true); // SS220 performance-test } private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args) @@ -143,7 +152,8 @@ private void OnEmitSoundOnInteractUsing(Entity