2023-08-24 14:50:07 -07:00
|
|
|
using Content.Server.Discord;
|
2021-06-20 10:09:24 +02:00
|
|
|
using Content.Shared.CCVar;
|
2022-08-14 12:54:49 -07:00
|
|
|
using Content.Shared.GameTicking;
|
2021-06-20 10:09:24 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameTicking
|
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed partial class GameTicker
|
2021-06-20 10:09:24 +02:00
|
|
|
{
|
|
|
|
|
[ViewVariables]
|
2022-08-14 12:54:49 -07:00
|
|
|
public bool LobbyEnabled { get; private set; }
|
2021-06-20 10:09:24 +02:00
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public bool DummyTicker { get; private set; } = false;
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public TimeSpan LobbyDuration { get; private set; } = TimeSpan.Zero;
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public bool DisallowLateJoin { get; private set; } = false;
|
|
|
|
|
|
2023-08-24 14:50:07 -07:00
|
|
|
[ViewVariables]
|
|
|
|
|
public string? ServerName { get; private set; }
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
2023-08-25 05:53:32 +03:00
|
|
|
private string? DiscordRoundEndRole { get; set; }
|
2023-08-24 14:50:07 -07:00
|
|
|
|
|
|
|
|
private WebhookIdentifier? _webhookIdentifier;
|
|
|
|
|
|
2024-03-01 02:08:48 -08:00
|
|
|
[ViewVariables]
|
|
|
|
|
private string? RoundEndSoundCollection { get; set; }
|
|
|
|
|
|
2022-03-04 23:25:41 +01:00
|
|
|
#if EXCEPTION_TOLERANCE
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public int RoundStartFailShutdownCount { get; private set; } = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-06-20 10:09:24 +02:00
|
|
|
private void InitializeCVars()
|
|
|
|
|
{
|
2024-02-13 22:48:39 +01:00
|
|
|
Subs.CVar(_configurationManager, CCVars.GameLobbyEnabled, value =>
|
2022-08-14 12:54:49 -07:00
|
|
|
{
|
|
|
|
|
LobbyEnabled = value;
|
|
|
|
|
foreach (var (userId, status) in _playerGameStatuses)
|
|
|
|
|
{
|
|
|
|
|
if (status == PlayerGameStatus.JoinedGame)
|
|
|
|
|
continue;
|
|
|
|
|
_playerGameStatuses[userId] =
|
|
|
|
|
LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
2024-02-13 22:48:39 +01:00
|
|
|
Subs.CVar(_configurationManager, CCVars.GameDummyTicker, value => DummyTicker = value, true);
|
|
|
|
|
Subs.CVar(_configurationManager, CCVars.GameLobbyDuration, value => LobbyDuration = TimeSpan.FromSeconds(value), true);
|
|
|
|
|
Subs.CVar(_configurationManager, CCVars.GameDisallowLateJoins,
|
2022-05-10 13:43:30 -05:00
|
|
|
value => { DisallowLateJoin = value; UpdateLateJoinStatus(); }, true);
|
2024-02-13 22:48:39 +01:00
|
|
|
Subs.CVar(_configurationManager, CCVars.AdminLogsServerName, value =>
|
2023-08-24 14:50:07 -07:00
|
|
|
{
|
|
|
|
|
// TODO why tf is the server name on admin logs
|
|
|
|
|
ServerName = value;
|
|
|
|
|
}, true);
|
2024-02-13 22:48:39 +01:00
|
|
|
Subs.CVar(_configurationManager, CCVars.DiscordRoundUpdateWebhook, value =>
|
2023-08-24 14:50:07 -07:00
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(value))
|
|
|
|
|
{
|
|
|
|
|
_discord.GetWebhook(value, data => _webhookIdentifier = data.ToIdentifier());
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
2024-02-13 22:48:39 +01:00
|
|
|
Subs.CVar(_configurationManager, CCVars.DiscordRoundEndRoleWebhook, value =>
|
2023-08-24 14:50:07 -07:00
|
|
|
{
|
|
|
|
|
DiscordRoundEndRole = value;
|
|
|
|
|
|
2023-08-25 05:53:32 +03:00
|
|
|
if (value == string.Empty)
|
2023-08-24 14:50:07 -07:00
|
|
|
{
|
|
|
|
|
DiscordRoundEndRole = null;
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
2024-03-01 02:08:48 -08:00
|
|
|
Subs.CVar(_configurationManager, CCVars.RoundEndSoundCollection, value => RoundEndSoundCollection = value, true);
|
2022-03-04 23:25:41 +01:00
|
|
|
#if EXCEPTION_TOLERANCE
|
2024-02-13 22:48:39 +01:00
|
|
|
Subs.CVar(_configurationManager, CCVars.RoundStartFailShutdownCount, value => RoundStartFailShutdownCount = value, true);
|
2022-03-04 23:25:41 +01:00
|
|
|
#endif
|
2021-06-20 10:09:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|