]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add space dungeon support (#14619)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 24 Mar 2023 02:19:29 +0000 (13:19 +1100)
committerGitHub <noreply@github.com>
Fri, 24 Mar 2023 02:19:29 +0000 (13:19 +1100)
Content.Server/Procedural/DungeonJob.cs
Content.Server/Procedural/DungeonSystem.Commands.cs
Resources/Locale/en-US/procedural/command.ftl

index 001f0aee255a5dd99cc0b2957e86ce7bb5db461e..e2947570369246e6efffe28c567e1d39832fa8e7 100644 (file)
@@ -6,6 +6,7 @@ using Content.Server.Decals;
 using Content.Shared.Procedural;
 using Content.Shared.Procedural.DungeonGenerators;
 using Content.Shared.Procedural.PostGeneration;
+using Robust.Server.Physics;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Prototypes;
@@ -76,6 +77,7 @@ public sealed partial class DungeonJob : Job<Dungeon>
     {
         Dungeon dungeon;
         _sawmill.Info($"Generating dungeon {_gen.ID} with seed {_seed} on {_entManager.ToPrettyString(_gridUid)}");
+        _grid.CanSplit = false;
 
         switch (_gen.Generator)
         {
@@ -126,6 +128,8 @@ public sealed partial class DungeonJob : Job<Dungeon>
             ValidateResume();
         }
 
+        _grid.CanSplit = true;
+        _entManager.System<GridFixtureSystem>().CheckSplits(_gridUid);
         return dungeon;
     }
 
index 59fc86433630ff3e7600cbec73060065691d2d87..aa8a92fa57e7749cc03cd130367ba6c66e9b0657 100644 (file)
@@ -30,13 +30,6 @@ public sealed partial class DungeonSystem
         }
 
         var mapId = new MapId(mapInt);
-        var mapUid = _mapManager.GetMapEntityId(mapId);
-
-        if (!TryComp<MapGridComponent>(mapUid, out var mapGrid))
-        {
-            shell.WriteError(Loc.GetString("cmd-dungen-mapgrid"));
-            return;
-        }
 
         if (!_prototype.TryIndex<DungeonConfigPrototype>(args[1], out var dungeon))
         {
@@ -51,6 +44,15 @@ public sealed partial class DungeonSystem
         }
 
         var position = new Vector2(posX, posY);
+        var dungeonUid = _mapManager.GetMapEntityId(mapId);
+
+        if (!TryComp<MapGridComponent>(dungeonUid, out var dungeonGrid))
+        {
+            dungeonUid = EntityManager.CreateEntityUninitialized(null, new EntityCoordinates(dungeonUid, position));
+            dungeonGrid = EntityManager.AddComponent<MapGridComponent>(dungeonUid);
+            EntityManager.InitializeAndStartEntity(dungeonUid, mapId);
+        }
+
         int seed;
 
         if (args.Length >= 5)
@@ -67,7 +69,7 @@ public sealed partial class DungeonSystem
         }
 
         shell.WriteLine(Loc.GetString("cmd-dungen-start", ("seed", seed)));
-        GenerateDungeon(dungeon, mapUid, mapGrid, position, seed);
+        GenerateDungeon(dungeon, dungeonUid, dungeonGrid, position, seed);
     }
 
     private CompletionResult CompletionCallback(IConsoleShell shell, string[] args)
index 27ad1a180cd542a69c27924b6b1860702984082c..77b6476c9ca8e5e03fb3354c42f1e888e9236155 100644 (file)
@@ -1,4 +1,4 @@
-cmd-dungen-desc = Generates a procedural dungeon with the specified preset, position, and seed.
+cmd-dungen-desc = Generates a procedural dungeon with the specified preset, position, and seed. Will spawn in space if the MapId doesn't have MapGridComponent.
 cmd-dungen-help = dungen <MapId> <DungeonPreset> <PosX> <PosY> [seed]
 cmd-dungen-arg-count = Require 4 args.
 cmd-dungen-map-parse = Unable to parse MapId.