]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Prevent dragons from spawning off-station (#15804)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sat, 29 Apr 2023 04:51:31 +0000 (00:51 -0400)
committerGitHub <noreply@github.com>
Sat, 29 Apr 2023 04:51:31 +0000 (14:51 +1000)
Content.Server/Dragon/DragonSystem.Rule.cs
Content.Server/Dragon/DragonSystem.cs

index 0963f8c09b93dff46d22ec28907f50f5ead0dfc0..9f220bbd26e17fbdc17ff9e59d8d936b2a723c65 100644 (file)
@@ -1,6 +1,7 @@
 using System.Linq;
 using Content.Server.GameTicking;
 using Content.Server.GameTicking.Rules.Components;
+using Content.Server.Station.Components;
 using Content.Shared.Dragon;
 using Robust.Server.GameObjects;
 using Robust.Shared.Map.Components;
@@ -30,13 +31,14 @@ public sealed partial class DragonSystem
     {
         base.Started(uid, component, gameRule, args);
 
-        var spawnLocations = EntityQuery<MapGridComponent, TransformComponent>().ToList();
+        if (!_station.Stations.Any())
+            return;
 
-        if (spawnLocations.Count == 0)
+        var station = _random.Pick(_station.Stations);
+        if (_station.GetLargestGrid(EntityManager.GetComponent<StationDataComponent>(station)) is not { } grid)
             return;
 
-        var location = _random.Pick(spawnLocations);
-        Spawn("MobDragon", location.Item2.MapPosition);
+        Spawn("MobDragon", Transform(grid).MapPosition);
     }
 
     private void OnRiftRoundEnd(RoundEndTextAppendEvent args)
index f2f0e7ba991cdbc45c9014f5343dcd988e61007f..6bd1f08bdbfe193d4274c7b92b1ebe3ca5ffeafc 100644 (file)
@@ -17,6 +17,7 @@ using Robust.Shared.GameStates;
 using Robust.Shared.Map;
 using Robust.Shared.Random;
 using Content.Server.NPC.Systems;
+using Content.Server.Station.Systems;
 using Content.Shared.DoAfter;
 using Content.Shared.Humanoid;
 using Content.Shared.Mobs;
@@ -37,6 +38,7 @@ namespace Content.Server.Dragon
         [Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
         [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
         [Dependency] private readonly SharedAudioSystem _audioSystem = default!;
+        [Dependency] private readonly StationSystem _station = default!;
         [Dependency] private readonly NPCSystem _npc = default!;
 
         /// <summary>