diff --git a/Content.Client/_CP14/Options/CP14OptionsMenuMainTab.xaml.cs b/Content.Client/_CP14/Options/CP14OptionsMenuMainTab.xaml.cs index 3342c7c1c1..062099818d 100644 --- a/Content.Client/_CP14/Options/CP14OptionsMenuMainTab.xaml.cs +++ b/Content.Client/_CP14/Options/CP14OptionsMenuMainTab.xaml.cs @@ -1,4 +1,4 @@ -using Content.Shared._CP14.Configuration; +using Content.Shared.CCVar; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; @@ -12,8 +12,8 @@ public sealed partial class CP14OptionsMenuMainTab : Control { RobustXamlLoader.Load(this); - Control.AddOptionCheckBox(CP14ConfigVars.WaveShaderEnabled, WaveShaderEnabled); - Control.AddOptionCheckBox(CP14ConfigVars.PostProcess, PostProcessCheckBox); + Control.AddOptionCheckBox(CCVars.WaveShaderEnabled, WaveShaderEnabled); + Control.AddOptionCheckBox(CCVars.PostProcess, PostProcessCheckBox); Control.Initialize(); } diff --git a/Content.Client/_CP14/Overlays/BasePostProcessOverlay.cs b/Content.Client/_CP14/Overlays/BasePostProcessOverlay.cs index 6638766af5..953ba690f3 100644 --- a/Content.Client/_CP14/Overlays/BasePostProcessOverlay.cs +++ b/Content.Client/_CP14/Overlays/BasePostProcessOverlay.cs @@ -1,5 +1,5 @@ -using Content.Shared._CP14.Configuration; using System.Numerics; +using Content.Shared.CCVar; using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.Configuration; @@ -32,7 +32,7 @@ public sealed class CP14BasePostProcessOverlay : Overlay protected override bool BeforeDraw(in OverlayDrawArgs args) { - if (!_configManager.GetCVar(CP14ConfigVars.PostProcess)) + if (!_configManager.GetCVar(CCVars.PostProcess)) return false; if (!_entityManager.TryGetComponent(_playerManager.LocalSession?.AttachedEntity, out EyeComponent? eyeComp)) @@ -74,4 +74,4 @@ public sealed class CP14BasePostProcessOverlay : Overlay worldHandle.DrawRect(viewport, Color.White); worldHandle.UseShader(null); } -} \ No newline at end of file +} diff --git a/Content.Client/_CP14/Wave/CP14WaveShaderSystem.cs b/Content.Client/_CP14/Wave/CP14WaveShaderSystem.cs index 9d43cfb2e5..ba2fc51fc2 100644 --- a/Content.Client/_CP14/Wave/CP14WaveShaderSystem.cs +++ b/Content.Client/_CP14/Wave/CP14WaveShaderSystem.cs @@ -1,8 +1,6 @@ -using Content.Shared._CP14.Configuration; +using Content.Shared.CCVar; using Robust.Client.GameObjects; using Robust.Client.Graphics; -using Robust.Client.Placement; -using Robust.Client.Player; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -23,7 +21,7 @@ public sealed class CP14WaveShaderSystem : EntitySystem base.Initialize(); _shader = _protoMan.Index("Wave").InstanceUnique(); - _enabled = _configuration.GetCVar(CP14ConfigVars.WaveShaderEnabled); + _enabled = _configuration.GetCVar(CCVars.WaveShaderEnabled); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnShutdown); diff --git a/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.CBT.cs b/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.CBT.cs new file mode 100644 index 0000000000..2a199a091e --- /dev/null +++ b/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.CBT.cs @@ -0,0 +1,68 @@ +using Content.Server.GameTicking; +using Content.Shared.CCVar; +using Robust.Shared.Audio; +using Robust.Shared.Console; + +namespace Content.Server._CP14.RoundEnd; + +public sealed partial class CP14RoundEndSystem +{ + [Dependency] private readonly IConsoleHost _consoleHost = default!; + [Dependency] private readonly GameTicker _ticker = default!; + + private TimeSpan _nextUpdateTime = TimeSpan.Zero; + private readonly TimeSpan _updateFrequency = TimeSpan.FromSeconds(45f); + + private bool _enabled; + + private void InitCbt() + { + _enabled = _configManager.GetCVar(CCVars.CP14ClosedBetaTest); + _configManager.OnValueChanged(CCVars.CP14ClosedBetaTest, _ => { _enabled = _configManager.GetCVar(CCVars.CP14ClosedBetaTest); }, true); + } + + // Вы можете сказать: Эд, ты ебанулся? Это же лютый щиткод! + // И я вам отвечу: Да. Но сама система ограничения времени работы сервера - временная штука на этап разработки, которая будет удалена. Мне просто лень каждый раз запускать и выключать сервер ручками. + private void UpdateCbt(float _) + { + if (!_enabled) + return; + + if (_nextUpdateTime > _timing.CurTime) + return; + + _nextUpdateTime = _timing.CurTime + _updateFrequency; + + DateTime nowMoscow = DateTime.UtcNow.AddHours(3); + + //Disable any round timers + if (nowMoscow.Hour is < 18 or > 20) + { + if (_ticker.RunLevel == GameRunLevel.InRound) + _roundEnd.EndRound(); + + if (!_ticker.Paused) + _ticker.TogglePause(); + } + else + { + if (_ticker.Paused) + _ticker.TogglePause(); + } + + if (nowMoscow.Hour == 17 && nowMoscow.Minute == 45) + { + _consoleHost.ExecuteCommand("shutdown"); //Restart server, load updates and other + } + + if (nowMoscow.Hour == 20 && nowMoscow.Minute == 45) + { + _chatSystem.DispatchGlobalAnnouncement("ВНИМАНИЕ: Сервер автоматически завершит раунд через 15 минут", announcementSound: new SoundPathSpecifier("/Audio/Effects/beep1.ogg"), sender: "Сервер"); + } + if (nowMoscow.Hour == 21 && nowMoscow.Minute == 02) + { + _consoleHost.ExecuteCommand("golobby"); + _consoleHost.ExecuteCommand("set-motd Плейтест на сегодня уже закончен. Следующий запуск в 18:00 МСК."); + } + } +} diff --git a/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.cs b/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.cs index 61fa6d45ce..ee3afa44c0 100644 --- a/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.cs +++ b/Content.Server/_CP14/RoundEnd/CP14RoundEndSystem.cs @@ -15,7 +15,6 @@ public sealed partial class CP14RoundEndSystem : EntitySystem { [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly ChatSystem _chatSystem = default!; - [Dependency] private readonly GameTicker _gameTicker = default!; [Dependency] private readonly CP14DemiplaneSystem _demiplane = default!; [Dependency] private readonly RoundEndSystem _roundEnd = default!; [Dependency] private readonly IConfigurationManager _configManager = default!; @@ -27,6 +26,8 @@ public sealed partial class CP14RoundEndSystem : EntitySystem { base.Initialize(); + InitCbt(); + SubscribeLocalEvent(OnFinisherMagicEnergyLevelChange); SubscribeNetworkEvent(OnRoundEndMessage); } @@ -34,19 +35,25 @@ public sealed partial class CP14RoundEndSystem : EntitySystem private void OnRoundEndMessage(RoundEndMessageEvent ev) { _roundEndMoment = TimeSpan.Zero; //Reset timer, so it cant affect next round in any case + _demiplane.DeleteAllDemiplanes(safe: false); + + _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("cp14-round-end"), + announcementSound: new SoundPathSpecifier("/Audio/_CP14/Ambience/event_boom.ogg")); } public override void Update(float frameTime) { base.Update(frameTime); + UpdateCbt(frameTime); + if (_roundEndMoment == TimeSpan.Zero) return; if (_roundEndMoment > _timing.CurTime) return; - EndRound(); + _roundEnd.EndRound(); } private void OnFinisherMagicEnergyLevelChange(Entity ent, @@ -103,16 +110,4 @@ public sealed partial class CP14RoundEndSystem : EntitySystem _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("cp14-round-end-monolith-recharged"), announcementSound: new SoundPathSpecifier("/Audio/_CP14/Ambience/event_boom.ogg")); } - - private void EndRound() - { - if (_gameTicker.RunLevel != GameRunLevel.InRound) - return; - - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("cp14-round-end"), - announcementSound: new SoundPathSpecifier("/Audio/_CP14/Ambience/event_boom.ogg")); - _roundEndMoment = TimeSpan.Zero; - _roundEnd.EndRound(); - _demiplane.DeleteAllDemiplanes(safe: false); - } } diff --git a/Content.Shared/_CP14/CCvar/CCvars.CP14Demiplanes.cs b/Content.Shared/_CP14/CCvar/CCvars.CP14Demiplanes.cs deleted file mode 100644 index 3ed2e7d3a7..0000000000 --- a/Content.Shared/_CP14/CCvar/CCvars.CP14Demiplanes.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Robust.Shared.Configuration; - -namespace Content.Shared.CCVar; - -public sealed partial class CCVars -{ - public static readonly CVarDef CP14RoundEndMinutes = - CVarDef.Create("cp14_demiplane.round_end_minutes", 15, CVar.SERVERONLY); -} diff --git a/Content.Shared/_CP14/CCvar/CCvars.CP14Misc.cs b/Content.Shared/_CP14/CCvar/CCvars.CP14Misc.cs new file mode 100644 index 0000000000..667bc5bc86 --- /dev/null +++ b/Content.Shared/_CP14/CCvar/CCvars.CP14Misc.cs @@ -0,0 +1,15 @@ +using Robust.Shared.Configuration; + +namespace Content.Shared.CCVar; + +public sealed partial class CCVars +{ + public static readonly CVarDef CP14RoundEndMinutes = + CVarDef.Create("cp14.round_end_minutes", 15, CVar.SERVERONLY); + + /// + /// Automatically shuts down the server outside of the CBT plytime. Shitcoded enough, but it's temporary anyway + /// + public static readonly CVarDef CP14ClosedBetaTest = + CVarDef.Create("cp14.closet_beta_test", false, CVar.SERVERONLY); +} diff --git a/Content.Shared/_CP14/Configuration/CP14ConfigVars.cs b/Content.Shared/_CP14/CCvar/CCvars.CP14Shaders.cs similarity index 63% rename from Content.Shared/_CP14/Configuration/CP14ConfigVars.cs rename to Content.Shared/_CP14/CCvar/CCvars.CP14Shaders.cs index ec1206c68c..bc28d9f2f8 100644 --- a/Content.Shared/_CP14/Configuration/CP14ConfigVars.cs +++ b/Content.Shared/_CP14/CCvar/CCvars.CP14Shaders.cs @@ -1,13 +1,12 @@ using Robust.Shared; using Robust.Shared.Configuration; -namespace Content.Shared._CP14.Configuration; +namespace Content.Shared.CCVar; -[CVarDefs] -public sealed class CP14ConfigVars : CVars +public sealed partial class CCVars { public static readonly CVarDef - WaveShaderEnabled = CVarDef.Create("cp14_rendering.wave_shader_enabled", true, CVar.CLIENT | CVar.ARCHIVE); + WaveShaderEnabled = CVarDef.Create("cp14_shaders.wave_shader_enabled", true, CVar.CLIENT | CVar.ARCHIVE); /// /// Toggle for non-gameplay-affecting or otherwise status indicative post-process effects, such additive lighting. @@ -15,5 +14,5 @@ public sealed class CP14ConfigVars : CVars /// However, for now (mid-July of 2024), this only applies specifically to a particularly cheap shader: additive lighting. /// public static readonly CVarDef - PostProcess = CVarDef.Create("cp14_graphics.post_process", true, CVar.CLIENTONLY | CVar.ARCHIVE); + PostProcess = CVarDef.Create("cp14_shaders.post_process", true, CVar.CLIENTONLY | CVar.ARCHIVE); } diff --git a/Resources/ConfigPresets/_CP14/Dev.toml b/Resources/ConfigPresets/_CP14/Dev.toml index c65ab5e2de..5a52f1e5a5 100644 --- a/Resources/ConfigPresets/_CP14/Dev.toml +++ b/Resources/ConfigPresets/_CP14/Dev.toml @@ -61,3 +61,4 @@ enable_during_round = true [cp14] discord_auth_enabled = true +closet_beta_test = true \ No newline at end of file