GameTicker.CVars.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Content.Server.Discord;
  2. using Content.Shared.CCVar;
  3. using Content.Shared.GameTicking;
  4. namespace Content.Server.GameTicking
  5. {
  6. public sealed partial class GameTicker
  7. {
  8. [ViewVariables]
  9. public bool LobbyEnabled { get; private set; }
  10. [ViewVariables]
  11. public bool DummyTicker { get; private set; } = false;
  12. [ViewVariables]
  13. public TimeSpan LobbyDuration { get; private set; } = TimeSpan.Zero;
  14. [ViewVariables]
  15. public bool DisallowLateJoin { get; private set; } = false;
  16. [ViewVariables]
  17. public string? ServerName { get; private set; }
  18. [ViewVariables]
  19. private string? DiscordRoundEndRole { get; set; }
  20. private WebhookIdentifier? _webhookIdentifier;
  21. [ViewVariables]
  22. private string? RoundEndSoundCollection { get; set; }
  23. #if EXCEPTION_TOLERANCE
  24. [ViewVariables]
  25. public int RoundStartFailShutdownCount { get; private set; } = 0;
  26. #endif
  27. private void InitializeCVars()
  28. {
  29. Subs.CVar(_cfg, CCVars.GameLobbyEnabled, value =>
  30. {
  31. LobbyEnabled = value;
  32. foreach (var (userId, status) in _playerGameStatuses)
  33. {
  34. if (status == PlayerGameStatus.JoinedGame)
  35. continue;
  36. _playerGameStatuses[userId] =
  37. LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
  38. }
  39. }, true);
  40. Subs.CVar(_cfg, CCVars.GameDummyTicker, value => DummyTicker = value, true);
  41. Subs.CVar(_cfg, CCVars.GameLobbyDuration, value => LobbyDuration = TimeSpan.FromSeconds(value), true);
  42. Subs.CVar(_cfg, CCVars.GameDisallowLateJoins,
  43. value => { DisallowLateJoin = value; UpdateLateJoinStatus(); }, true);
  44. Subs.CVar(_cfg, CCVars.AdminLogsServerName, value =>
  45. {
  46. // TODO why tf is the server name on admin logs
  47. ServerName = value;
  48. }, true);
  49. Subs.CVar(_cfg, CCVars.DiscordRoundUpdateWebhook, value =>
  50. {
  51. if (!string.IsNullOrWhiteSpace(value))
  52. {
  53. _discord.GetWebhook(value, data => _webhookIdentifier = data.ToIdentifier());
  54. }
  55. }, true);
  56. Subs.CVar(_cfg, CCVars.DiscordRoundEndRoleWebhook, value =>
  57. {
  58. DiscordRoundEndRole = value;
  59. if (value == string.Empty)
  60. {
  61. DiscordRoundEndRole = null;
  62. }
  63. }, true);
  64. Subs.CVar(_cfg, CCVars.RoundEndSoundCollection, value => RoundEndSoundCollection = value, true);
  65. #if EXCEPTION_TOLERANCE
  66. Subs.CVar(_cfg, CCVars.RoundStartFailShutdownCount, value => RoundStartFailShutdownCount = value, true);
  67. #endif
  68. }
  69. }
  70. }