]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Don't enable ghost roles for salvage spawns (#15598)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 21 Apr 2023 05:06:22 +0000 (15:06 +1000)
committerGitHub <noreply@github.com>
Fri, 21 Apr 2023 05:06:22 +0000 (15:06 +1000)
Content.Server/Parallax/BiomeSystem.cs
Content.Server/Salvage/SpawnSalvageMissionJob.cs

index 66a0a6cf22c91d9e823eec15bebf2ed82b301920..a679ab2648e1389a944a1cfdaebd216392a484d8 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Server.Decals;
+using Content.Server.Ghost.Roles.Components;
 using Content.Server.Shuttles.Events;
 using Content.Shared.Decals;
 using Content.Shared.Parallax.Biomes;
@@ -313,6 +314,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
 
     #region Load
 
+    /// <summary>
+    /// Loads all of the chunks for a particular biome, as well as handle any marker chunks.
+    /// </summary>
     private void LoadChunks(
         BiomeComponent component,
         EntityUid gridUid,
@@ -358,7 +362,13 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
 
                         for (var k = 0; k < layerProto.GroupCount; k++)
                         {
-                            Spawn(layerProto.Prototype, new EntityCoordinates(gridUid, point));
+                            // If it is a ghost role then purge it
+                            // TODO: This is *kind* of a bandaid but natural mobs spawns needs a lot more work.
+                            // Ideally we'd just have ghost role and non-ghost role variants for some stuff.
+                            var uid = EntityManager.CreateEntityUninitialized(layerProto.Prototype, new EntityCoordinates(gridUid, point));
+                            RemComp<GhostTakeoverAvailableComponent>(uid);
+                            RemComp<GhostRoleComponent>(uid);
+                            EntityManager.InitializeAndStartEntity(uid);
                         }
 
                         break;
@@ -381,6 +391,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
         }
     }
 
+    /// <summary>
+    /// Loads a particular queued chunk for a biome.
+    /// </summary>
     private void LoadChunk(
         BiomeComponent component,
         EntityUid gridUid,
@@ -494,6 +507,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
 
     #region Unload
 
+    /// <summary>
+    /// Handles all of the queued chunk unloads for a particular biome.
+    /// </summary>
     private void UnloadChunks(BiomeComponent component, EntityUid gridUid, MapGridComponent grid, FastNoiseLite noise)
     {
         var active = _activeChunks[component];
@@ -510,6 +526,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
         }
     }
 
+    /// <summary>
+    /// Unloads a specific biome chunk.
+    /// </summary>
     private void UnloadChunk(BiomeComponent component, EntityUid gridUid, MapGridComponent grid, Vector2i chunk, FastNoiseLite noise, List<(Vector2i, Tile)> tiles)
     {
         // Reverse order to loading
index b7de8fac2729a31d345e598d8aa8ceeabcb6251f..862e49561421a05c5d91bbddb098e75eeae4aae7 100644 (file)
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
 using Content.Server.Atmos;
 using Content.Server.Atmos.Components;
 using Content.Server.CPUJob.JobQueues;
+using Content.Server.Ghost.Roles.Components;
 using Content.Server.Parallax;
 using Content.Server.Procedural;
 using Content.Server.Salvage.Expeditions;
@@ -359,7 +360,10 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
 
                 foreach (var entry in EntitySpawnCollection.GetSpawns(mobGroup.Entries, random))
                 {
-                    _entManager.SpawnEntity(entry, spawnPosition);
+                    var uid = _entManager.CreateEntityUninitialized(entry, spawnPosition);
+                    _entManager.RemoveComponent<GhostTakeoverAvailableComponent>(uid);
+                    _entManager.RemoveComponent<GhostRoleComponent>(uid);
+                    _entManager.InitializeAndStartEntity(uid);
                 }
 
                 await SuspendIfOutOfTime();