]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add more dungeon layouts (#14924)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 31 Mar 2023 05:54:17 +0000 (16:54 +1100)
committerGitHub <noreply@github.com>
Fri, 31 Mar 2023 05:54:17 +0000 (22:54 -0700)
Content.Server/Procedural/DungeonSystem.Commands.cs
Content.Server/Procedural/DungeonSystem.cs
Resources/Locale/en-US/procedural/command.ftl
Resources/Prototypes/Procedural/dungeon_configs.yml
Resources/Prototypes/Procedural/dungeon_presets.yml
Resources/Prototypes/Procedural/dungeon_room_packs.yml

index aa8a92fa57e7749cc03cd130367ba6c66e9b0657..3b0058ca9af4a48c649b6780cae46fecf93bb926 100644 (file)
@@ -101,4 +101,131 @@ public sealed partial class DungeonSystem
 
         return CompletionResult.Empty;
     }
+
+    [AdminCommand(AdminFlags.Mapping)]
+    private void DungeonPackVis(IConsoleShell shell, string argstr, string[] args)
+    {
+        if (args.Length != 2)
+        {
+            return;
+        }
+
+        if (!int.TryParse(args[0], out var mapInt))
+        {
+            return;
+        }
+
+        var mapId = new MapId(mapInt);
+        var mapUid = _mapManager.GetMapEntityId(mapId);
+
+        if (!_prototype.TryIndex<DungeonRoomPackPrototype>(args[1], out var pack))
+        {
+            return;
+        }
+
+        var grid = EnsureComp<MapGridComponent>(mapUid);
+        var tile = new Tile(_tileDefManager["FloorSteel"].TileId);
+        var tiles = new List<(Vector2i, Tile)>();
+
+        foreach (var room in pack.Rooms)
+        {
+            for (var x = room.Left; x < room.Right; x++)
+            {
+                for (var y = room.Bottom; y < room.Top; y++)
+                {
+                    var index = new Vector2i(x, y);
+                    tiles.Add((index, tile));
+                }
+            }
+        }
+
+        // Fill the rest out with a blank tile to make it easier to see
+        var dummyTile = new Tile(_tileDefManager["FloorAsteroidIronsand1"].TileId);
+
+        for (var x = 0; x < pack.Size.X; x++)
+        {
+            for (var y = 0; y < pack.Size.Y; y++)
+            {
+                var index = new Vector2i(x, y);
+                if (tiles.Contains((index, tile)))
+                    continue;
+
+                tiles.Add((index, dummyTile));
+            }
+        }
+
+        grid.SetTiles(tiles);
+        shell.WriteLine(Loc.GetString("cmd-dungen_pack_vis"));
+    }
+
+    [AdminCommand(AdminFlags.Mapping)]
+    private void DungeonPresetVis(IConsoleShell shell, string argstr, string[] args)
+    {
+        if (args.Length != 2)
+        {
+            return;
+        }
+
+        if (!int.TryParse(args[0], out var mapInt))
+        {
+            return;
+        }
+
+        var mapId = new MapId(mapInt);
+        var mapUid = _mapManager.GetMapEntityId(mapId);
+
+        if (!_prototype.TryIndex<DungeonPresetPrototype>(args[1], out var preset))
+        {
+            return;
+        }
+
+        var grid = EnsureComp<MapGridComponent>(mapUid);
+        var tile = new Tile(_tileDefManager["FloorSteel"].TileId);
+        var tiles = new List<(Vector2i, Tile)>();
+
+        foreach (var room in preset.RoomPacks)
+        {
+            for (var x = room.Left; x < room.Right; x++)
+            {
+                for (var y = room.Bottom; y < room.Top; y++)
+                {
+                    var index = new Vector2i(x, y);
+                    tiles.Add((index, tile));
+                }
+            }
+        }
+
+        grid.SetTiles(tiles);
+        shell.WriteLine(Loc.GetString("cmd-dungen_pack_vis"));
+    }
+
+    private CompletionResult PresetCallback(IConsoleShell shell, string[] args)
+    {
+        if (args.Length == 1)
+        {
+            return CompletionResult.FromHintOptions(CompletionHelper.MapIds(EntityManager), Loc.GetString("cmd-dungen-hint-map"));
+        }
+
+        if (args.Length == 2)
+        {
+            return CompletionResult.FromOptions(CompletionHelper.PrototypeIDs<DungeonPresetPrototype>(proto: _prototype));
+        }
+
+        return CompletionResult.Empty;
+    }
+
+    private CompletionResult PackCallback(IConsoleShell shell, string[] args)
+    {
+        if (args.Length == 1)
+        {
+            return CompletionResult.FromHintOptions(CompletionHelper.MapIds(EntityManager), Loc.GetString("cmd-dungen-hint-map"));
+        }
+
+        if (args.Length == 2)
+        {
+            return CompletionResult.FromOptions(CompletionHelper.PrototypeIDs<DungeonRoomPackPrototype>(proto: _prototype));
+        }
+
+        return CompletionResult.Empty;
+    }
 }
index 7f2a5f33a3d95daa093f0a17de4180928d77cc37..eca622cc44a0e48d3805c53fc3284a867f675b6a 100644 (file)
@@ -40,6 +40,8 @@ public sealed partial class DungeonSystem : EntitySystem
         base.Initialize();
         _sawmill = Logger.GetSawmill("dungen");
         _console.RegisterCommand("dungen", Loc.GetString("cmd-dungen-desc"), Loc.GetString("cmd-dungen-help"), GenerateDungeon, CompletionCallback);
+        _console.RegisterCommand("dungen_preset_vis", Loc.GetString("cmd-dungen_preset_vis-desc"), Loc.GetString("cmd-dungen_preset_vis-help"), DungeonPresetVis, PresetCallback);
+        _console.RegisterCommand("dungen_pack_vis", Loc.GetString("cmd-dungen_pack_vis-desc"), Loc.GetString("cmd-dungen_pack_vis-help"), DungeonPackVis, PackCallback);
         _prototype.PrototypesReloaded += PrototypeReload;
         SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
     }
index 77b6476c9ca8e5e03fb3354c42f1e888e9236155..26887f77f21c0cdc270219aa95e691ccf5456ef1 100644 (file)
@@ -13,3 +13,10 @@ cmd-dungen-hint-config = Dungeon config
 cmd-dungen-hint-posx = Position X
 cmd-dungen-hint-posy = Position Y
 cmd-dungen-hint-seed = [Seed]
+
+cmd-dungen_preset_vis-desc = Generates a tile-based preview of a dungeon preset.
+cmd-dungen_preset_vis-help = dungen_preset_vis <mapid> <preset>
+
+cmd-dungen_pack_vis-success = Success
+cmd-dungen_pack_vis-desc = Generates a tile-based preview of a dungeon pack.
+cmd-dungen_pack_vis-help = dungen_pack_vis <mapid> <pack>
index 9a63ce9825e9de649695c89ad0e5a9da72b3879f..ddb84815d242ea46e5f20f9fec0f6272bc6d056f 100644 (file)
@@ -5,6 +5,8 @@
       - SalvageExperiment
     presets:
       - Cross
+      - SpaceMan
+      - FourSquare
   postGeneration:
     - !type:MiddleConnectionPostGen
       overlapCount: 3
@@ -64,6 +66,8 @@
       - LavaBrig
     presets:
       - Cross
+      - SpaceMan
+      - FourSquare
   postGeneration:
     - !type:MiddleConnectionPostGen
       overlapCount: 3
index 4fbe4af7ce695d4fef6a9c8f21a8f5b9ad521d3c..aed6fbf92c6258005ff1ddf00d2b192865611399 100644 (file)
     - -2,36,3,53
     - -20,18,-3,35
     - 4,18,21,35
+
+# Two stumpy legs at the bottom, middle torso, then fat top
+- type: dungeonPreset
+  id: SpaceMan
+  roomPacks:
+    - -14,0,-9,17
+    - -8,12,9,17
+    - 10,0,15,17
+    - -8,18,-3,23
+    - 4,18,9,23
+    - -2,18,3,35
+    - -8,36,9,53
+    - -14,36,-9,53
+    - 10,36,15,53
+
+- type: dungeonPreset
+  id: FourSquare
+  roomPacks:
+    - -26,-5,-9,12
+    - 4,13,21,30
+    - 34,-5,51,12
+    - 4,-23,21,-6
+    - 10,-5,15,12
+    - -8,1,9,6
+    - 16,1,33,6
index 3f04cc235b4b47bfd39c44ce4ba6681567a62f97..63766a0693a0681b6ec47ff7db7d62eae2ccbac2 100644 (file)
     - 7,9,12,16
     - 1,5,6,12
 
+# 17x5 corridor through middle with 2 7x5 rooms off to the side.
+- type: dungeonRoomPack
+  id: LargeArea6
+  size: 17,17
+  rooms:
+    - 0,6,17,11
+    - 0,0,7,5
+    - 10,0,17,5
+
+# 3x7 corridor leading to 7x7 room.
+- type: dungeonRoomPack
+  id: LargeArea7
+  size: 17,17
+  rooms:
+    - 0,7,7,10
+    - 8,5,15,12
+
+# 17x5 corridor to 7x7
+- type: dungeonRoomPack
+  id: LargeArea8
+  size: 17,17
+  rooms:
+    - 0,1,17,6
+    - 5,7,12,14
+
 # Medium
 # Whole area room
-#- type: dungeonRoomPack
-#  id: MediumArea1
-#  size: 5,17
-#  rooms:
-#    - 0,6,15,9
-#    - 11,12,16,17
-#    - 11,0,16,5
-#  roomConnections:
-#    - 13,5
-#    - 13,9
+- type: dungeonRoomPack
+  id: MediumArea1
+  size: 5,17
+  rooms:
+    - 0,0,5,17
 
 # Three 5x5 rooms
 - type: dungeonRoomPack
     - 0,6,5,11
     - 1,12,4,17
 
+# 3x5 then a 13x3
+- type: dungeonRoomPack
+  id: MediumArea5
+  size: 5,17
+  rooms:
+    - 0,0,5,3
+    - 1,4,4,17
+
+# 5x5 then a 11x3
+- type: dungeonRoomPack
+  id: MediumArea6
+  size: 5,17
+  rooms:
+    - 0,0,5,5
+    - 1,6,4,17
+
+# 5x5 then a 11x5
+- type: dungeonRoomPack
+  id: MediumArea7
+  size: 5,17
+  rooms:
+    - 0,0,5,5
+    - 0,6,5,17
+
 # Small
 - type: dungeonRoomPack
   id: SmallArea1