From 783fc5b9b321989db551d61a8e1df84303ff1433 Mon Sep 17 00:00:00 2001 From: Janet Blackquill Date: Thu, 20 Feb 2025 19:28:34 -0500 Subject: [PATCH] Port respawning from Frontierstation/Corvax --- .../Systems/Ghost/GhostUIController.cs | 48 ++++++ .../Systems/Ghost/Widgets/GhostGui.xaml | 1 + .../Systems/Ghost/Widgets/GhostGui.xaml.cs | 37 +++++ .../_Corvax/Respawn/RespawnSystem.cs | 22 +++ .../Controls/GhostRespawnRulesWindow.xaml | 25 +++ .../Controls/GhostRespawnRulesWindow.xaml.cs | 29 ++++ .../_Corvax/Respawn/RespawnSystem.cs | 151 ++++++++++++++++++ .../_NF/Commands/GhostRespawnCommand.cs | 71 ++++++++ .../_Corvax/Respawn/RespawnResetEvent.cs | 9 ++ Content.Shared/_NF/CCVar/NFCCVars.cs | 28 ++++ .../en-US/_NF/respawn/respawn-system.ftl | 14 ++ 11 files changed, 435 insertions(+) create mode 100644 Content.Client/_Corvax/Respawn/RespawnSystem.cs create mode 100644 Content.Client/_NF/UserInterface/Systems/Ghost/Controls/GhostRespawnRulesWindow.xaml create mode 100644 Content.Client/_NF/UserInterface/Systems/Ghost/Controls/GhostRespawnRulesWindow.xaml.cs create mode 100644 Content.Server/_Corvax/Respawn/RespawnSystem.cs create mode 100644 Content.Server/_NF/Commands/GhostRespawnCommand.cs create mode 100644 Content.Shared/_Corvax/Respawn/RespawnResetEvent.cs create mode 100644 Content.Shared/_NF/CCVar/NFCCVars.cs create mode 100644 Resources/Locale/en-US/_NF/respawn/respawn-system.ftl diff --git a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs index 53779ea41c1..d86571b699a 100644 --- a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs +++ b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs @@ -3,8 +3,13 @@ using Content.Client.UserInterface.Systems.Gameplay; using Content.Client.UserInterface.Systems.Ghost.Widgets; using Content.Shared.Ghost; +using Robust.Client.Console; // Frontier +using Robust.Shared.Console; // Frontier using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; +using Content.Client._Corvax.Respawn; // Frontier +using Content.Shared._NF.CCVar; // Frontier +using Robust.Shared.Configuration; // Frontier namespace Content.Client.UserInterface.Systems.Ghost; @@ -12,8 +17,11 @@ namespace Content.Client.UserInterface.Systems.Ghost; public sealed class GhostUIController : UIController, IOnSystemChanged { [Dependency] private readonly IEntityNetworkManager _net = default!; + [Dependency] private readonly IConsoleHost _consoleHost = default!; // Frontier + [Dependency] private readonly IConfigurationManager _cfg = default!; // Frontier [UISystemDependency] private readonly GhostSystem? _system = default; + [UISystemDependency] private readonly RespawnSystem? _respawn = default; // Frontier private GhostGui? Gui => UIManager.GetActiveUIWidgetOrNull(); @@ -56,6 +64,24 @@ public void OnSystemUnloaded(GhostSystem system) system.GhostRoleCountUpdated -= OnRoleCountUpdated; } + // Begin Frontier + public void OnSystemLoaded(RespawnSystem system) + { + system.RespawnReseted += OnRespawnReseted; + } + + public void OnSystemUnloaded(RespawnSystem system) + { + system.RespawnReseted -= OnRespawnReseted; + } + + private void OnRespawnReseted() + { + UpdateGui(); + UpdateRespawn(_respawn?.RespawnResetTime); + } + // End Frontier + public void UpdateGui() { if (Gui == null) @@ -67,6 +93,13 @@ public void UpdateGui() Gui.Update(_system?.AvailableGhostRoleCount, _system?.Player?.CanReturnToBody); } + // Begin Frontier + private void UpdateRespawn(TimeSpan? timeOfDeath) + { + Gui?.UpdateRespawn(timeOfDeath); + } + // End Frontier + private void OnPlayerRemoved(GhostComponent component) { Gui?.Hide(); @@ -83,6 +116,7 @@ private void OnPlayerAttached(GhostComponent component) return; Gui.Visible = true; + UpdateRespawn(_respawn?.RespawnResetTime); // Frontier UpdateGui(); } @@ -127,10 +161,18 @@ public void LoadGui() Gui.GhostRolesPressed += GhostRolesPressed; Gui.TargetWindow.WarpClicked += OnWarpClicked; Gui.TargetWindow.OnGhostnadoClicked += OnGhostnadoClicked; + Gui.GhostRespawnPressed += GuiOnGhostRespawnPressed; // Frontier UpdateGui(); } + // Begin Frontier + private void GuiOnGhostRespawnPressed() + { + _consoleHost.ExecuteCommand("ghostrespawn"); + } + // End Frontier + public void UnloadGui() { if (Gui == null) @@ -140,6 +182,7 @@ public void UnloadGui() Gui.ReturnToBodyPressed -= ReturnToBody; Gui.GhostRolesPressed -= GhostRolesPressed; Gui.TargetWindow.WarpClicked -= OnWarpClicked; + Gui.GhostRespawnPressed -= GuiOnGhostRespawnPressed; // Frontier Gui.Hide(); } @@ -160,4 +203,9 @@ private void GhostRolesPressed() { _system?.OpenGhostRoles(); } + + private void RespawnPressed() + { + IoCManager.Resolve().RemoteExecuteCommand(null, "ghostrespawn"); + } } diff --git a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml index 0f65debb4e7..3f111264eed 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml +++ b/Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml @@ -5,5 +5,6 @@