]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
SS-28662 Add cvars to support forcing people to departures and making those at depart...
authorHannah Giovanna Dawson <karakkaraz@gmail.com>
Fri, 14 Jun 2024 11:15:42 +0000 (12:15 +0100)
committerGitHub <noreply@github.com>
Fri, 14 Jun 2024 11:15:42 +0000 (04:15 -0700)
* SS-28662 Add cvar to force spawn everyone at departures

This cvar means everyone must spawn at departures. This
could be handy for an admin event? But mostly it's so the
tutorial departures terminal can be seen by all newbies on
gateway servers.

* Small fix to ArrivalsSystem flow

* Remove incorrect todo

* Add godmode arrivals cvar

Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Content.Server/Station/Systems/StationSpawningSystem.cs
Content.Shared/CCVar/CCVars.cs

index eb1f9796b27a55c620487e93756a7c657375a5d8..47ccc3c3c41d9276ce7afef807df88a36955671f 100644 (file)
@@ -15,6 +15,7 @@ using Content.Server.Station.Events;
 using Content.Server.Station.Systems;
 using Content.Shared.Administration;
 using Content.Shared.CCVar;
+using Content.Shared.Damage.Components;
 using Content.Shared.DeviceNetwork;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Movement.Components;
@@ -63,6 +64,16 @@ public sealed class ArrivalsSystem : EntitySystem
     /// </summary>
     public bool Enabled { get; private set; }
 
+    /// <summary>
+    /// Flags if all players must arrive via the Arrivals system, or if they can spawn in other ways.
+    /// </summary>
+    public bool Forced { get; private set; }
+
+    /// <summary>
+    /// Flags if all players spawning at the departure terminal have godmode until they leave the terminal.
+    /// </summary>
+    public bool ArrivalsGodmode { get; private set; }
+
     /// <summary>
     ///     The first arrival is a little early, to save everyone 10s
     /// </summary>
@@ -94,7 +105,12 @@ public sealed class ArrivalsSystem : EntitySystem
 
         // Don't invoke immediately as it will get set in the natural course of things.
         Enabled = _cfgManager.GetCVar(CCVars.ArrivalsShuttles);
-        Subs.CVar(_cfgManager, CCVars.ArrivalsShuttles, SetArrivals);
+        Forced = _cfgManager.GetCVar(CCVars.ForceArrivals);
+        ArrivalsGodmode = _cfgManager.GetCVar(CCVars.GodmodeArrivals);
+
+        _cfgManager.OnValueChanged(CCVars.ArrivalsShuttles, SetArrivals);
+        _cfgManager.OnValueChanged(CCVars.ForceArrivals, b => Forced = b);
+        _cfgManager.OnValueChanged(CCVars.GodmodeArrivals, b => ArrivalsGodmode = b);
 
         // Command so admins can set these for funsies
         _console.RegisterCommand("arrivals", ArrivalsCommand, ArrivalsCompletion);
@@ -250,6 +266,9 @@ public sealed class ArrivalsSystem : EntitySystem
             // The player has successfully left arrivals and is also not on the shuttle. Remove their warp coupon.
             RemCompDeferred<PendingClockInComponent>(pUid);
             RemCompDeferred<AutoOrientComponent>(pUid);
+
+            if (ArrivalsGodmode)
+                RemCompDeferred<GodmodeComponent>(pUid);
         }
     }
 
@@ -309,7 +328,7 @@ public sealed class ArrivalsSystem : EntitySystem
             return;
 
         // Only works on latejoin even if enabled.
-        if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound)
+        if (!Enabled || !Forced && _ticker.RunLevel != GameRunLevel.InRound)
             return;
 
         if (!HasComp<StationArrivalsComponent>(ev.Station))
@@ -317,33 +336,37 @@ public sealed class ArrivalsSystem : EntitySystem
 
         TryGetArrivals(out var arrivals);
 
-        if (TryComp(arrivals, out TransformComponent? arrivalsXform))
-        {
-            var mapId = arrivalsXform.MapID;
+        if (!TryComp(arrivals, out TransformComponent? arrivalsXform))
+            return;
 
-            var points = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
-            var possiblePositions = new List<EntityCoordinates>();
-            while (points.MoveNext(out var uid, out var spawnPoint, out var xform))
-            {
-                if (spawnPoint.SpawnType != SpawnPointType.LateJoin || xform.MapID != mapId)
-                    continue;
+        var mapId = arrivalsXform.MapID;
 
-                possiblePositions.Add(xform.Coordinates);
-            }
+        var points = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
+        var possiblePositions = new List<EntityCoordinates>();
+        while (points.MoveNext(out var uid, out var spawnPoint, out var xform))
+        {
+            if (spawnPoint.SpawnType != SpawnPointType.LateJoin || xform.MapID != mapId)
+                continue;
 
-            if (possiblePositions.Count > 0)
-            {
-                var spawnLoc = _random.Pick(possiblePositions);
-                ev.SpawnResult = _stationSpawning.SpawnPlayerMob(
-                    spawnLoc,
-                    ev.Job,
-                    ev.HumanoidCharacterProfile,
-                    ev.Station);
-
-                EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
-                EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
-            }
+            possiblePositions.Add(xform.Coordinates);
         }
+
+        if (possiblePositions.Count <= 0)
+            return;
+
+        var spawnLoc = _random.Pick(possiblePositions);
+        ev.SpawnResult = _stationSpawning.SpawnPlayerMob(
+            spawnLoc,
+            ev.Job,
+            ev.HumanoidCharacterProfile,
+            ev.Station);
+
+        EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
+        EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
+
+        // If you're forced to spawn, you're invincible until you leave wherever you were forced to spawn.
+        if (ArrivalsGodmode)
+            EnsureComp<GodmodeComponent>(ev.SpawnResult.Value);
     }
 
     private bool TryTeleportToMapSpawn(EntityUid player, EntityUid stationId, TransformComponent? transform = null)
index b91082ff2616b5e08df3fcc6a83b50e5ec177ce0..d30c9fc111d4e8ce81716c442ebe22d78e962c4a 100644 (file)
@@ -65,7 +65,15 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
         _spawnerCallbacks = new Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>>()
         {
             { SpawnPriorityPreference.Arrivals, _arrivalsSystem.HandlePlayerSpawning },
-            { SpawnPriorityPreference.Cryosleep, _containerSpawnPointSystem.HandlePlayerSpawning }
+            {
+                SpawnPriorityPreference.Cryosleep, ev =>
+                {
+                    if (_arrivalsSystem.Forced)
+                        _arrivalsSystem.HandlePlayerSpawning(ev);
+                    else
+                        _containerSpawnPointSystem.HandlePlayerSpawning(ev);
+                }
+            }
         };
     }
 
@@ -308,4 +316,4 @@ public sealed class PlayerSpawningEvent : EntityEventArgs
         HumanoidCharacterProfile = humanoidCharacterProfile;
         Station = station;
     }
-}
\ No newline at end of file
+}
index f3025f326aa8d127955541091cae539a809e9504..e3f0f6543873bb4f8f3946994c543e3b2be80137 100644 (file)
@@ -1425,6 +1425,18 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> ArrivalsReturns =
             CVarDef.Create("shuttle.arrivals_returns", false, CVar.SERVERONLY);
 
+        /// <summary>
+        /// Should all players be forced to spawn at departures, even on roundstart, even if their loadout says they spawn in cryo?
+        /// </summary>
+        public static readonly CVarDef<bool> ForceArrivals =
+            CVarDef.Create("shuttle.force_arrivals", false, CVar.SERVERONLY);
+
+        /// <summary>
+        /// Should all players who spawn at arrivals have godmode until they leave the map?
+        /// </summary>
+        public static readonly CVarDef<bool> GodmodeArrivals =
+            CVarDef.Create("shuttle.godmode_arrivals", false, CVar.SERVERONLY);
+
         /// <summary>
         /// Whether to automatically spawn escape shuttles.
         /// </summary>