From a04b0d8ab2306f323a77c548f84952ba6b2aef86 Mon Sep 17 00:00:00 2001 From: KloopRE <100780612+KloopRE@users.noreply.github.com> Date: Wed, 23 Sep 2026 22:54:16 +0300 Subject: [PATCH] Golobby (#3730) --- .../Corvax/Ghost/GhostGoLobbyButton.cs | 86 +++++++++++++++++++ Content.Client/Ghost/GhostSystem.cs | 6 -- .../Systems/Ghost/GhostUIController.cs | 36 +------- .../Systems/Ghost/Widgets/GhostGui.xaml | 4 +- .../Systems/Ghost/Widgets/GhostGui.xaml.cs | 5 +- .../Ghost/GhostGoLobbyDeathTimeCommand.cs | 34 ++++++++ .../Ghost/GhostGoLobbyEnabledCommand.cs | 33 +++++++ .../Corvax/Ghost/GhostGoLobbySystem.cs | 71 +++++++++------ .../GameTicking/ServerGameTicker.Spawning.cs | 10 ++- Content.Shared/Corvax/CCCVars/CCCVars.cs | 9 ++ .../Corvax/Ghost/GhostGoLobbyComponent.cs | 10 +++ .../corvax/ghost/golobby/ghost-go-lobby.ftl | 7 ++ .../corvax/ghost/golobby/ghost-go-lobby.ftl | 7 ++ 13 files changed, 241 insertions(+), 77 deletions(-) create mode 100644 Content.Client/Corvax/Ghost/GhostGoLobbyButton.cs create mode 100644 Content.Server/Corvax/Ghost/GhostGoLobbyDeathTimeCommand.cs create mode 100644 Content.Server/Corvax/Ghost/GhostGoLobbyEnabledCommand.cs create mode 100644 Content.Shared/Corvax/Ghost/GhostGoLobbyComponent.cs diff --git a/Content.Client/Corvax/Ghost/GhostGoLobbyButton.cs b/Content.Client/Corvax/Ghost/GhostGoLobbyButton.cs new file mode 100644 index 0000000000..3d87bd2111 --- /dev/null +++ b/Content.Client/Corvax/Ghost/GhostGoLobbyButton.cs @@ -0,0 +1,86 @@ +using Content.Shared.Corvax.CCCVars; +using Content.Shared.Corvax.Events; +using Content.Shared.Corvax.Ghost; +using Robust.Client.Player; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Configuration; +using Robust.Shared.Timing; + +namespace Content.Client.Corvax.Ghost; + +public sealed partial class GhostGoLobbyButton : Button +{ + [Dependency] private IEntityManager _entMan = default!; + [Dependency] private IPlayerManager _players = default!; + [Dependency] private IEntityNetworkManager _net = default!; + [Dependency] private IConfigurationManager _cfg = default!; + [Dependency] private IGameTiming _timing = default!; + + private static readonly Color Waiting = Color.FromHex("#8B2E2E"); + private static readonly Color Ready = Color.FromHex("#2E8B3E"); + + private GhostGoLobbyConfirmWindow? _confirmWindow; + + public GhostGoLobbyButton() + { + IoCManager.InjectDependencies(this); + + OnPressed += _ => OnPress(); + } + + protected override void EnteredTree() + { + base.EnteredTree(); + _cfg.OnValueChanged(CCCVars.GhostGoLobbyEnabled, OnEnabledChanged, true); + } + + protected override void ExitedTree() + { + _cfg.UnsubValueChanged(CCCVars.GhostGoLobbyEnabled, OnEnabledChanged); + _confirmWindow?.Close(); + base.ExitedTree(); + } + + private void OnEnabledChanged(bool enabled) + { + Visible = enabled; + } + + private void OnPress() + { + if (_confirmWindow is { Disposed: false }) + { + _confirmWindow.MoveToFront(); + return; + } + + _confirmWindow = new GhostGoLobbyConfirmWindow(); + _confirmWindow.ContinuePressed += () => _net.SendSystemNetworkMessage(new GhostGoLobbyEvent()); + _confirmWindow.OnClose += () => _confirmWindow = null; + _confirmWindow.OpenCentered(); + } + + protected override void FrameUpdate(FrameEventArgs args) + { + base.FrameUpdate(args); + + var remaining = _players.LocalEntity is { } player + && _entMan.TryGetComponent(player, out var lobby) + ? lobby.AvailableAt - _timing.CurTime + : TimeSpan.Zero; + + if (remaining > TimeSpan.Zero) + { + var text = $"{(int)remaining.TotalMinutes:D2}:{remaining.Seconds:D2}"; + Text = Loc.GetString("ghost-go-lobby-button-waiting", ("time", text)); + Disabled = true; + ModulateSelfOverride = Waiting; + } + else + { + Text = Loc.GetString("ghost-go-lobby-button"); + Disabled = false; + ModulateSelfOverride = Ready; + } + } +} diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index 3bb6738f49..3d65e993be 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -1,5 +1,4 @@ using Content.Client.Movement.Systems; -using Content.Shared.Corvax.Events; using Content.Shared.Actions; using Content.Shared.Ghost.Components; using Content.Shared.Ghost.Systems; @@ -188,11 +187,6 @@ namespace Content.Client.Ghost RaiseNetworkEvent(new GhostWarpsRequestEvent()); } - public void GhostGoLobby() // Corvax-GoLobby - { - RaiseNetworkEvent(new GhostGoLobbyEvent()); - } - public void ReturnToBody() { var msg = new GhostReturnToBodyRequest(); diff --git a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs index a1306b6d5a..db583b9875 100644 --- a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs +++ b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs @@ -1,14 +1,11 @@ -using Content.Client.Corvax.Ghost; using Content.Client.Gameplay; using Content.Client.Ghost; using Content.Client.UserInterface.Systems.Gameplay; using Content.Client.UserInterface.Systems.Ghost.Widgets; -using Content.Shared.Corvax.CCCVars; using Content.Shared.Ghost.Components; using Content.Shared.Ghost.Systems; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; -using Robust.Shared.Configuration; namespace Content.Client.UserInterface.Systems.Ghost; @@ -16,15 +13,11 @@ namespace Content.Client.UserInterface.Systems.Ghost; public sealed partial class GhostUIController : UIController, IOnSystemChanged { [Dependency] private IEntityNetworkManager _net = default!; - [Dependency] private IConfigurationManager _cfg = default!; // Corvax-GoLobby [UISystemDependency] private readonly GhostSystem? _system = default; private GhostGui? Gui => UIManager.GetActiveUIWidgetOrNull(); - private GhostGoLobbyConfirmWindow? _goLobbyConfirmWindow; // Corvax-GoLobby - private bool _goLobbyEnabled = true; // Corvax-GoLobby - public override void Initialize() { base.Initialize(); @@ -32,15 +25,6 @@ public sealed partial class GhostUIController : UIController, IOnSystemChanged(); gameplayStateLoad.OnScreenLoad += OnScreenLoad; gameplayStateLoad.OnScreenUnload += OnScreenUnload; - - // Corvax-GoLobby - _cfg.OnValueChanged(CCCVars.GhostGoLobbyEnabled, OnGoLobbyEnabledChanged, true); - } - - private void OnGoLobbyEnabledChanged(bool enabled) // Corvax-GoLobby - { - _goLobbyEnabled = enabled; - UpdateGui(); } private void OnScreenLoad() @@ -81,7 +65,7 @@ public sealed partial class GhostUIController : UIController, IOnSystemChanged _system?.GhostGoLobby(); - _goLobbyConfirmWindow.OnClose += () => _goLobbyConfirmWindow = null; - _goLobbyConfirmWindow.OpenCentered(); - } - // Corvax-Changes-End - private void RequestWarps() { _system?.RequestWarps(); diff --git a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml index 44b934801f..5750fe9b73 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml +++ b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml @@ -1,11 +1,11 @@