Skip to content

Commit

Permalink
Fix Heisentests (Simple-Station#778)
Browse files Browse the repository at this point in the history
# Description

Attempt number 5000 to get the Heisentests to STOP.

---------

Signed-off-by: VMSolidus <[email protected]>
Co-authored-by: metalgearsloth <[email protected]>
Co-authored-by: Timemaster99 <[email protected]>
Co-authored-by: DEATHB4DEFEAT <[email protected]>
  • Loading branch information
4 people authored Aug 22, 2024
1 parent 18b1ccb commit 7d4a0dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
20 changes: 16 additions & 4 deletions Content.Client/Voting/VoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
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
Expand All @@ -31,16 +34,20 @@ public interface IVoteManager

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<StandardVoteType, TimeSpan> _standardVoteTimeouts = new();
private readonly Dictionary<int, ActiveVote> _votes = new();
private readonly Dictionary<int, UI.VotePopup> _votePopups = new();
private Control? _popupContainer;

private IAudioSource? _voteSource;

public bool CanCallVote { get; private set; }

public event Action<bool>? CanCallVoteChanged;
Expand All @@ -49,6 +56,12 @@ public sealed class VoteManager : IVoteManager

public void Initialize()
{
const string sound = "/Audio/Effects/voteding.ogg";
_voteSource = _audio.CreateAudioSource(_res.GetResource<AudioResource>(sound));

if (_voteSource != null)
_voteSource.Global = true;

_netManager.RegisterNetMessage<MsgVoteData>(ReceiveVoteData);
_netManager.RegisterNetMessage<MsgVoteCanCall>(ReceiveVoteCanCall);

Expand Down Expand Up @@ -125,9 +138,8 @@ private void ReceiveVoteData(MsgVoteData message)
return;
}

_voteSource?.Restart();
@new = true;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>()
.PlayGlobal("/Audio/Effects/voteding.ogg", Filter.Local(), false);

// Refresh
var container = _popupContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ static AlertsUI FindAlertsUI(Control control)
return null;
}
// we should be seeing 3 alerts - our health, and the 2 debug alerts, in a specific order.
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(3));
// This originally was hardcoded to expect a player character to have a Human Healthbar.
// It is no longer hardcoded to demand that.
// We should be seeing 2 alerts - the 2 debug alerts, in a specific order.
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(2));
var alertControls = clientAlertsUI.AlertContainer.Children.Select(c => (AlertControl) c);
var alertIDs = alertControls.Select(ac => ac.Alert.AlertType).ToArray();
var expectedIDs = new[] { AlertType.HumanHealth, AlertType.Debug1, AlertType.Debug2 };
var expectedIDs = new[] { AlertType.Debug1, AlertType.Debug2 };
Assert.That(alertIDs, Is.SupersetOf(expectedIDs));
});

Expand All @@ -101,11 +103,11 @@ await server.WaitAssertion(() =>

await client.WaitAssertion(() =>
{
// we should be seeing 2 alerts now because one was cleared
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(2));
// We should be seeing 1 alert now because one was cleared
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(1));
var alertControls = clientAlertsUI.AlertContainer.Children.Select(c => (AlertControl) c);
var alertIDs = alertControls.Select(ac => ac.Alert.AlertType).ToArray();
var expectedIDs = new[] { AlertType.HumanHealth, AlertType.Debug2 };
var expectedIDs = new[] { AlertType.Debug2 };
Assert.That(alertIDs, Is.SupersetOf(expectedIDs));
});

Expand Down

0 comments on commit 7d4a0dd

Please sign in to comment.