Random spontaneous cleanup PR (#25131)
* Use new Subs.CVar helper Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe. This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown. * Fix a bunch of warnings * More warning fixes * Use new DateTime serializer to get rid of ISerializationHooks in changelog code. * Get rid of some more ISerializationHooks for enums * And a little more * Apply suggestions from code review Co-authored-by: 0x6273 <0x40@keemail.me> --------- Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
committed by
GitHub
parent
d0c174388c
commit
68ce53ae17
@@ -99,10 +99,10 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
|
||||
UpdatesOutsidePrediction = true;
|
||||
UpdatesAfter.Add(typeof(AmbientSoundTreeSystem));
|
||||
|
||||
_cfg.OnValueChanged(CCVars.AmbientCooldown, SetCooldown, true);
|
||||
_cfg.OnValueChanged(CCVars.MaxAmbientSources, SetAmbientCount, true);
|
||||
_cfg.OnValueChanged(CCVars.AmbientRange, SetAmbientRange, true);
|
||||
_cfg.OnValueChanged(CCVars.AmbienceVolume, SetAmbienceGain, true);
|
||||
Subs.CVar(_cfg, CCVars.AmbientCooldown, SetCooldown, true);
|
||||
Subs.CVar(_cfg, CCVars.MaxAmbientSources, SetAmbientCount, true);
|
||||
Subs.CVar(_cfg, CCVars.AmbientRange, SetAmbientRange, true);
|
||||
Subs.CVar(_cfg, CCVars.AmbienceVolume, SetAmbienceGain, true);
|
||||
SubscribeLocalEvent<AmbientSoundComponent, ComponentShutdown>(OnShutdown);
|
||||
}
|
||||
|
||||
@@ -138,11 +138,6 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
|
||||
{
|
||||
base.Shutdown();
|
||||
ClearSounds();
|
||||
|
||||
_cfg.UnsubValueChanged(CCVars.AmbientCooldown, SetCooldown);
|
||||
_cfg.UnsubValueChanged(CCVars.MaxAmbientSources, SetAmbientCount);
|
||||
_cfg.UnsubValueChanged(CCVars.AmbientRange, SetAmbientRange);
|
||||
_cfg.UnsubValueChanged(CCVars.AmbienceVolume, SetAmbienceGain);
|
||||
}
|
||||
|
||||
private int PlayingCount(string countSound)
|
||||
|
||||
@@ -34,8 +34,8 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_configManager.OnValueChanged(CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged);
|
||||
_configManager.OnValueChanged(CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged);
|
||||
Subs.CVar(_configManager, CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged);
|
||||
Subs.CVar(_configManager, CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged);
|
||||
|
||||
_stateManager.OnStateChanged += StateManagerOnStateChanged;
|
||||
|
||||
@@ -50,9 +50,6 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_configManager.UnsubValueChanged(CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged);
|
||||
_configManager.UnsubValueChanged(CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged);
|
||||
|
||||
_stateManager.OnStateChanged -= StateManagerOnStateChanged;
|
||||
|
||||
_client.PlayerLeaveServer -= OnLeave;
|
||||
|
||||
@@ -26,11 +26,11 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
||||
SubscribeNetworkEvent<AdminSoundEvent>(PlayAdminSound);
|
||||
_cfg.OnValueChanged(CCVars.AdminSoundsEnabled, ToggleAdminSound, true);
|
||||
Subs.CVar(_cfg, CCVars.AdminSoundsEnabled, ToggleAdminSound, true);
|
||||
|
||||
SubscribeNetworkEvent<StationEventMusicEvent>(PlayStationEventMusic);
|
||||
SubscribeNetworkEvent<StopStationEventMusic>(StopStationEventMusic);
|
||||
_cfg.OnValueChanged(CCVars.EventMusicEnabled, ToggleStationEventMusic, true);
|
||||
Subs.CVar(_cfg, CCVars.EventMusicEnabled, ToggleStationEventMusic, true);
|
||||
|
||||
SubscribeNetworkEvent<GameGlobalSoundEvent>(PlayGameSound);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public sealed partial class ContentAudioSystem
|
||||
|
||||
private void InitializeAmbientMusic()
|
||||
{
|
||||
_configManager.OnValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged, true);
|
||||
Subs.CVar(_configManager, CCVars.AmbientMusicVolume, AmbienceCVarChanged, true);
|
||||
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("audio.ambience");
|
||||
|
||||
// Reset audio
|
||||
@@ -84,7 +84,6 @@ public sealed partial class ContentAudioSystem
|
||||
|
||||
private void ShutdownAmbientMusic()
|
||||
{
|
||||
_configManager.UnsubValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged);
|
||||
_state.OnStateChanged -= OnStateChange;
|
||||
_ambientMusicStream = _audio.Stop(_ambientMusicStream);
|
||||
}
|
||||
@@ -229,7 +228,7 @@ public sealed partial class ContentAudioSystem
|
||||
|
||||
private AmbientMusicPrototype? GetAmbience()
|
||||
{
|
||||
var player = _player.LocalPlayer?.ControlledEntity;
|
||||
var player = _player.LocalEntity;
|
||||
|
||||
if (player == null)
|
||||
return null;
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Client.Audio;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using AudioComponent = Robust.Shared.Audio.Components.AudioComponent;
|
||||
|
||||
namespace Content.Client.Audio;
|
||||
|
||||
public sealed partial class ContentAudioSystem : SharedContentAudioSystem
|
||||
{
|
||||
[Dependency] private readonly IAudioManager _audioManager = default!;
|
||||
[Dependency] private readonly IResourceCache _cache = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
||||
|
||||
// Need how much volume to change per tick and just remove it when it drops below "0"
|
||||
private readonly Dictionary<EntityUid, float> _fadingOut = new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user