]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixup playerspawn stuff (#31546)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Thu, 29 Aug 2024 05:27:47 +0000 (15:27 +1000)
committerGitHub <noreply@github.com>
Thu, 29 Aug 2024 05:27:47 +0000 (15:27 +1000)
* Fixup playerspawn stuff

- Also removed arrivals forcing, this should just turn containerspawnpoint off.

* fix this one

* test fix

* really fix

Content.IntegrationTests/Tests/PostMapInitTest.cs
Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs
Content.Server/Station/Systems/StationSpawningSystem.cs
Content.Shared/CCVar/CCVars.cs
Resources/Prototypes/Entities/Mobs/Player/silicon.yml

index 5771e0f06c088301c0d7c49d6474b64d1e19814a..b08f774271c25693c6b332392b3df9cb174f01c5 100644 (file)
@@ -248,14 +248,14 @@ namespace Content.IntegrationTests.Tests
                     var jobs = new HashSet<ProtoId<JobPrototype>>(comp.SetupAvailableJobs.Keys);
 
                     var spawnPoints = entManager.EntityQuery<SpawnPointComponent>()
-                        .Where(x => x.SpawnType == SpawnPointType.Job)
-                        .Select(x => x.Job!.Value);
+                        .Where(x => x.SpawnType == SpawnPointType.Job && x.Job != null)
+                        .Select(x => x.Job.Value);
 
                     jobs.ExceptWith(spawnPoints);
 
                     spawnPoints = entManager.EntityQuery<ContainerSpawnPointComponent>()
-                        .Where(x => x.SpawnType == SpawnPointType.Job)
-                        .Select(x => x.Job!.Value);
+                        .Where(x => x.SpawnType is SpawnPointType.Job or SpawnPointType.Unset && x.Job != null)
+                        .Select(x => x.Job.Value);
 
                     jobs.ExceptWith(spawnPoints);
 
index 0b86383faa8a8ae3068d4c69f75b826a1b99e69c..9b94d6024e2a4072e44b95cb0b8c716705ec3e8d 100644 (file)
@@ -11,6 +11,7 @@ using Content.Server.Screens.Components;
 using Content.Server.Shuttles.Components;
 using Content.Server.Shuttles.Events;
 using Content.Server.Spawners.Components;
+using Content.Server.Spawners.EntitySystems;
 using Content.Server.Station.Components;
 using Content.Server.Station.Events;
 using Content.Server.Station.Systems;
@@ -69,11 +70,6 @@ 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>
@@ -95,6 +91,8 @@ public sealed class ArrivalsSystem : EntitySystem
     {
         base.Initialize();
 
+        SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(ContainerSpawnPointSystem), typeof(SpawnPointSystem)});
+
         SubscribeLocalEvent<StationArrivalsComponent, StationPostInitEvent>(OnStationPostInit);
 
         SubscribeLocalEvent<ArrivalsShuttleComponent, ComponentStartup>(OnShuttleStartup);
@@ -112,11 +110,9 @@ 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);
-        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
@@ -339,7 +335,7 @@ public sealed class ArrivalsSystem : EntitySystem
             return;
 
         // Only works on latejoin even if enabled.
-        if (!Enabled || !Forced && _ticker.RunLevel != GameRunLevel.InRound)
+        if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound)
             return;
 
         if (!HasComp<StationArrivalsComponent>(ev.Station))
index e213f29d07b5c953d4a0270ba0ac00ff0a05bffc..ef0ece524c02023471370ddd60318db9b0838968 100644 (file)
@@ -15,6 +15,12 @@ public sealed class ContainerSpawnPointSystem : EntitySystem
     [Dependency] private readonly StationSystem _station = default!;
     [Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
 
+    public override void Initialize()
+    {
+        base.Initialize();
+        SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(SpawnPointSystem) });
+    }
+
     public void HandlePlayerSpawning(PlayerSpawningEvent args)
     {
         if (args.SpawnResult != null)
index fcbc3aa52f69871711126b9cf40aa3b094b1453d..3090f1588067e09804c7ddda9795cba8058c786e 100644 (file)
@@ -56,27 +56,11 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
 
     private bool _randomizeCharacters;
 
-    private Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>> _spawnerCallbacks = new();
-
     /// <inheritdoc/>
     public override void Initialize()
     {
         base.Initialize();
         Subs.CVar(_configurationManager, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
-
-        _spawnerCallbacks = new Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>>()
-        {
-            { SpawnPriorityPreference.Arrivals, _arrivalsSystem.HandlePlayerSpawning },
-            {
-                SpawnPriorityPreference.Cryosleep, ev =>
-                {
-                    if (_arrivalsSystem.Forced)
-                        _arrivalsSystem.HandlePlayerSpawning(ev);
-                    else
-                        _containerSpawnPointSystem.HandlePlayerSpawning(ev);
-                }
-            }
-        };
     }
 
     /// <summary>
@@ -98,33 +82,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
 
         var ev = new PlayerSpawningEvent(job, profile, station);
 
-        if (station != null && profile != null)
-        {
-            // Try to call the character's preferred spawner first.
-            if (_spawnerCallbacks.TryGetValue(profile.SpawnPriority, out var preferredSpawner))
-            {
-                preferredSpawner(ev);
-
-                foreach (var (key, remainingSpawner) in _spawnerCallbacks)
-                {
-                    if (key == profile.SpawnPriority)
-                        continue;
-
-                    remainingSpawner(ev);
-                }
-            }
-            else
-            {
-                // Call all of them in the typical order.
-                foreach (var typicalSpawner in _spawnerCallbacks.Values)
-                {
-                    typicalSpawner(ev);
-                }
-            }
-        }
-
         RaiseLocalEvent(ev);
-
         DebugTools.Assert(ev.SpawnResult is { Valid: true } or null);
 
         return ev.SpawnResult;
index 4d1ba39a3ebf955e893e0589b9c50daddfef4de6..95fb7bd692c597f835fb49b5ac62abc24e98e30f 100644 (file)
@@ -1478,12 +1478,6 @@ 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>
index e1348c7b389f32304818ebc31d4447f5b6082705..1425531282559e80147540989fd4786f41e52776 100644 (file)
   suffix: Job spawn
   components:
   - type: ContainerSpawnPoint
-    spawnType: Job
     containerId: station_ai_mind_slot
     job: StationAi
   - type: Sprite