diff --git a/Content.Client/Voting/VoteManager.cs b/Content.Client/Voting/VoteManager.cs index 63c706c86b..a7c799b58f 100644 --- a/Content.Client/Voting/VoteManager.cs +++ b/Content.Client/Voting/VoteManager.cs @@ -6,12 +6,15 @@ using Robust.Client; using Robust.Client.Audio; using Robust.Client.Console; using Robust.Client.GameObjects; +using Robust.Client.ResourceManagement; using Robust.Client.UserInterface; using Robust.Shared.IoC; using Robust.Shared.Network; using Robust.Shared.Timing; using Robust.Shared.Player; using Robust.Shared.Audio; +using Robust.Shared.Audio.Sources; +using Robust.Shared.ContentPack; namespace Content.Client.Voting @@ -31,16 +34,20 @@ namespace Content.Client.Voting public sealed class VoteManager : IVoteManager { + [Dependency] private readonly IAudioManager _audio = default!; + [Dependency] private readonly IBaseClient _client = default!; + [Dependency] private readonly IClientConsoleHost _console = default!; [Dependency] private readonly IClientNetManager _netManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; - [Dependency] private readonly IClientConsoleHost _console = default!; - [Dependency] private readonly IBaseClient _client = default!; + [Dependency] private readonly IResourceCache _res = default!; private readonly Dictionary _standardVoteTimeouts = new(); private readonly Dictionary _votes = new(); private readonly Dictionary _votePopups = new(); private Control? _popupContainer; + private IAudioSource? _voteSource; + public bool CanCallVote { get; private set; } public event Action? CanCallVoteChanged; @@ -49,6 +56,14 @@ namespace Content.Client.Voting public void Initialize() { + const string sound = "/Audio/Effects/voteding.ogg"; + _voteSource = _audio.CreateAudioSource(_res.GetResource(sound)); + + if (_voteSource != null) + { + _voteSource.Global = true; + } + _netManager.RegisterNetMessage(ReceiveVoteData); _netManager.RegisterNetMessage(ReceiveVoteCanCall); @@ -125,9 +140,8 @@ namespace Content.Client.Voting return; } + _voteSource?.Restart(); @new = true; - IoCManager.Resolve().GetEntitySystem() - .PlayGlobal("/Audio/Effects/voteding.ogg", Filter.Local(), false); // Refresh var container = _popupContainer;