Fix emergency evac shuttle console early launch mispredict (#39751)

* Fix

* Yes

* Mess

* Update

* Like that?
This commit is contained in:
Winkarst-cpu
2025-09-10 16:56:18 +03:00
committed by GitHub
parent 3da0b0299f
commit ebfcddc62f
6 changed files with 61 additions and 32 deletions

View File

@@ -117,7 +117,7 @@ public sealed partial class CCVars
/// Is the emergency shuttle allowed to be early launched.
/// </summary>
public static readonly CVarDef<bool> EmergencyEarlyLaunchAllowed =
CVarDef.Create("shuttle.emergency_early_launch_allowed", false, CVar.SERVERONLY);
CVarDef.Create("shuttle.emergency_early_launch_allowed", false, CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// How long the emergency shuttle remains docked with the station, in seconds.

View File

@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Shuttles.Components;
[RegisterComponent, NetworkedComponent]
public sealed partial class EmergencyShuttleConsoleComponent : Component
{
// TODO: Okay doing it by string is kinda suss but also ID card tracking doesn't seem to be robust enough
/// <summary>
/// ID cards that have been used to authorize an early launch.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("authorized")]
public HashSet<string> AuthorizedEntities = new();
[ViewVariables(VVAccess.ReadWrite), DataField("authorizationsRequired")]
public int AuthorizationsRequired = 3;
}

View File

@@ -0,0 +1,34 @@
using Content.Shared.CCVar;
using Content.Shared.Popups;
using Content.Shared.Shuttles.Components;
using Content.Shared.UserInterface;
using Robust.Shared.Configuration;
namespace Content.Shared.Shuttles.Systems;
public abstract class SharedEmergencyShuttleSystem : EntitySystem
{
[Dependency] protected readonly IConfigurationManager ConfigManager = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!;
private bool _emergencyEarlyLaunchAllowed;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, ActivatableUIOpenAttemptEvent>(OnEmergencyOpenAttempt);
Subs.CVar(ConfigManager, CCVars.EmergencyEarlyLaunchAllowed, value => _emergencyEarlyLaunchAllowed = value, true);
}
private void OnEmergencyOpenAttempt(Entity<EmergencyShuttleConsoleComponent> ent, ref ActivatableUIOpenAttemptEvent args)
{
// I'm hoping ActivatableUI checks it's open before allowing these messages.
if (_emergencyEarlyLaunchAllowed)
return;
args.Cancel();
Popup.PopupClient(Loc.GetString("emergency-shuttle-console-no-early-launches"), ent, args.User);
}
}