Files
OldThink/Content.Server/_Honk/RoundEndVote/RoundEndVoteSystem.cs

59 lines
1.7 KiB
C#
Raw Normal View History

2024-08-25 23:54:21 +03:00
using Content.Server.GameTicking;
using Content.Server.RoundEnd;
using Content.Server.Voting.Managers;
using Content.Shared.Voting;
2024-10-01 21:02:34 +03:00
using Robust.Server.Player;
2024-11-19 00:08:32 +03:00
using Robust.Shared.Timing;
2024-08-25 23:54:21 +03:00
namespace Content.Server._Honk.RoundEndVote;
public sealed class RoundEndVoteSystem : EntitySystem
{
[Dependency] private readonly IVoteManager _voteManager = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
2024-10-01 23:37:57 +03:00
[Dependency] private readonly IPlayerManager _playerManager = default!;
2024-08-25 23:54:21 +03:00
public override void Initialize()
{
SubscribeLocalEvent<RoundEndSystemChangedEvent>(OnRoundEndSystemChange);
}
private void OnRoundEndSystemChange(RoundEndSystemChangedEvent ev)
{
2024-10-01 23:37:57 +03:00
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
2024-08-25 23:54:21 +03:00
return;
2024-11-19 00:08:32 +03:00
if (_playerManager.PlayerCount == 0)
{
_gameTicker.DelayStart(TimeSpan.FromSeconds(60));
Timer.Spawn(60 * 1000, () =>
{
if (_playerManager.PlayerCount >= 15)
{
_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
}
else if (_playerManager.PlayerCount >= 5)
{
_gameTicker.SetGamePreset("Extended");
}
});
}
2024-11-18 20:09:01 +03:00
if (_playerManager.PlayerCount >= 15)
2024-10-01 23:37:57 +03:00
{
_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
}
2024-11-18 20:09:01 +03:00
else if (_playerManager.PlayerCount >= 5)
{
_gameTicker.SetGamePreset("Extended");
}
2024-10-01 23:37:57 +03:00
else
{
2024-11-18 20:09:01 +03:00
_gameTicker.SetGamePreset("Greenshift");
2024-10-01 23:37:57 +03:00
}
2024-08-26 16:47:47 +03:00
_voteManager.CreateStandardVote(null, StandardVoteType.Map);
2024-08-25 23:54:21 +03:00
}
}