]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add new salv loot into the vgroid procgen (#31290)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sat, 24 Aug 2024 02:06:37 +0000 (22:06 -0400)
committerGitHub <noreply@github.com>
Sat, 24 Aug 2024 02:06:37 +0000 (12:06 +1000)
add new loot into vgroid procgen

Content.Server/Procedural/DungeonJob/DungeonJob.EntityTableDunGen.cs [new file with mode: 0644]
Content.Server/Procedural/DungeonJob/DungeonJob.cs
Content.Shared/Procedural/DungeonLayers/EntityTableDunGen.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Markers/Spawners/Random/Salvage/spawners.yml
Resources/Prototypes/Procedural/vgroid.yml

diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.EntityTableDunGen.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.EntityTableDunGen.cs
new file mode 100644 (file)
index 0000000..8f9be82
--- /dev/null
@@ -0,0 +1,59 @@
+using System.Linq;
+using System.Threading.Tasks;
+using Content.Server.Ghost.Roles.Components;
+using Content.Server.NPC.Systems;
+using Content.Shared.EntityTable;
+using Content.Shared.Physics;
+using Content.Shared.Procedural;
+using Content.Shared.Procedural.DungeonLayers;
+using Robust.Shared.Collections;
+
+namespace Content.Server.Procedural.DungeonJob;
+
+public sealed partial class DungeonJob
+{
+    private async Task PostGen(
+        EntityTableDunGen gen,
+        Dungeon dungeon,
+        Random random)
+    {
+        var availableRooms = new ValueList<DungeonRoom>();
+        availableRooms.AddRange(dungeon.Rooms);
+        var availableTiles = new ValueList<Vector2i>(dungeon.AllTiles);
+
+        var count = random.Next(gen.MinCount, gen.MaxCount + 1);
+        var npcs = _entManager.System<NPCSystem>();
+
+        for (var i = 0; i < count; i++)
+        {
+            while (availableTiles.Count > 0)
+            {
+                var tile = availableTiles.RemoveSwap(random.Next(availableTiles.Count));
+
+                if (!_anchorable.TileFree(_grid,
+                        tile,
+                        (int) CollisionGroup.MachineLayer,
+                        (int) CollisionGroup.MachineLayer))
+                {
+                    continue;
+                }
+
+                var entities = _entManager.System<EntityTableSystem>().GetSpawns(gen.Table, random).ToList();
+                foreach (var ent in entities)
+                {
+                    var uid = _entManager.SpawnAtPosition(ent, _maps.GridTileToLocal(_gridUid, _grid, tile));
+                    _entManager.RemoveComponent<GhostRoleComponent>(uid);
+                    _entManager.RemoveComponent<GhostTakeoverAvailableComponent>(uid);
+                    npcs.SleepNPC(uid);
+                }
+
+                break;
+            }
+
+            await SuspendDungeon();
+
+            if (!ValidateResume())
+                return;
+        }
+    }
+}
index 6631eb24b01267f908976d2eb140ff8048c710d5..5a6a8510fff3d2c3cd90d5d4293705e5692b0a66 100644 (file)
@@ -239,6 +239,9 @@ public sealed partial class DungeonJob : Job<List<Dungeon>>
             case MobsDunGen mob:
                 await PostGen(mob, dungeons[^1], random);
                 break;
+            case EntityTableDunGen entityTable:
+                await PostGen(entityTable, dungeons[^1], random);
+                break;
             case NoiseDistanceDunGen distance:
                 dungeons.Add(await GenerateNoiseDistanceDunGen(position, distance, reservedTiles, seed, random));
                 break;
diff --git a/Content.Shared/Procedural/DungeonLayers/EntityTableDunGen.cs b/Content.Shared/Procedural/DungeonLayers/EntityTableDunGen.cs
new file mode 100644 (file)
index 0000000..71e9bae
--- /dev/null
@@ -0,0 +1,21 @@
+using Content.Shared.EntityTable.EntitySelectors;
+
+namespace Content.Shared.Procedural.DungeonLayers;
+
+
+/// <summary>
+/// Spawns entities inside of the dungeon randomly.
+/// </summary>
+public sealed partial class EntityTableDunGen : IDunGenLayer
+{
+    // Counts separate to config to avoid some duplication.
+
+    [DataField]
+    public int MinCount = 1;
+
+    [DataField]
+    public int MaxCount = 1;
+
+    [DataField(required: true)]
+    public EntityTableSelector Table;
+}
index 81a71095751ee1bc7f723eae688fa3c347f6a3cf..503fcc33802b18defecac80d49688963f3e72141 100644 (file)
       tableId: SalvageScrapSpawnerValuable
       prob: 0.75
 
+- type: entityTable
+  id: SalvageTreasureSpawnerCommon
+  table: !type:GroupSelector
+    children:
+    # 80% chance of some treasure
+    - !type:GroupSelector
+      weight: 80
+      children:
+      - !type:NestedSelector
+        tableId: SalvageTreasureCommon
+        weight: 60
+      - !type:NestedSelector
+        tableId: SalvageTreasureUncommon
+        weight: 30
+      - !type:NestedSelector
+        tableId: SalvageTreasureRare
+        weight: 9
+      - !type:NestedSelector
+        tableId: SalvageTreasureLegendary
+        weight: 1
+    # 10% chance of low-level equipment
+    - !type:GroupSelector
+      weight: 10
+      children:
+      - !type:NestedSelector
+        tableId: SalvageEquipmentCommon
+        weight: 60
+      - !type:NestedSelector
+        tableId: SalvageEquipmentUncommon
+        weight: 40
+    # 5% chance of moderate scrap
+    - !type:GroupSelector
+      weight: 5
+      children:
+      - !type:NestedSelector
+        tableId: SalvageScrapLowValue
+        weight: 60
+      - !type:NestedSelector
+        tableId: SalvageScrapHighValue
+        weight: 30
+      - !type:NestedSelector
+        tableId: SalvageScrapLarge
+        weight: 10
+    # 5% chance of maintenance fluff
+    - !type:NestedSelector
+      tableId: MaintFluffTable
+      weight: 5
+
 - type: entity
   parent: MarkerBase
   id: SalvageSpawnerTreasure
       state: diamond
   - type: EntityTableSpawner
     offset: 0.4
-    table: !type:GroupSelector
+    table: !type:NestedSelector
+      tableId: SalvageTreasureSpawnerCommon
       prob: 0.75
+
+- type: entityTable
+  id: SalvageTreasureSpawnerValuable
+  table: !type:GroupSelector
+    children:
+    # 80% chance of some treasure
+    - !type:GroupSelector
+      weight: 80
       children:
-      # 80% chance of some treasure
-      - !type:GroupSelector
-        weight: 80
-        children:
-        - !type:NestedSelector
-          tableId: SalvageTreasureCommon
-          weight: 60
-        - !type:NestedSelector
-          tableId: SalvageTreasureUncommon
-          weight: 30
-        - !type:NestedSelector
-          tableId: SalvageTreasureRare
-          weight: 9
-        - !type:NestedSelector
-          tableId: SalvageTreasureLegendary
-          weight: 1
-      # 10% chance of low-level equipment
-      - !type:GroupSelector
-        weight: 10
-        children:
-        - !type:NestedSelector
-          tableId: SalvageEquipmentCommon
-          weight: 60
-        - !type:NestedSelector
-          tableId: SalvageEquipmentUncommon
-          weight: 40
-      # 5% chance of moderate scrap
-      - !type:GroupSelector
-        weight: 5
-        children:
-        - !type:NestedSelector
-          tableId: SalvageScrapLowValue
-          weight: 60
-        - !type:NestedSelector
-          tableId: SalvageScrapHighValue
-          weight: 30
-        - !type:NestedSelector
-          tableId: SalvageScrapLarge
-          weight: 10
-      # 5% chance of maintenance fluff
       - !type:NestedSelector
-        tableId: MaintFluffTable
+        tableId: SalvageTreasureCommon
+        weight: 45
+      - !type:NestedSelector
+        tableId: SalvageTreasureUncommon
+        weight: 35
+      - !type:NestedSelector
+        tableId: SalvageTreasureRare
+        weight: 15
+      - !type:NestedSelector
+        tableId: SalvageTreasureLegendary
         weight: 5
+    # 10% chance of low-level equipment
+    - !type:GroupSelector
+      weight: 10
+      children:
+      - !type:NestedSelector
+        tableId: SalvageEquipmentCommon
+        weight: 50
+      - !type:NestedSelector
+        tableId: SalvageEquipmentUncommon
+        weight: 40
+      - !type:NestedSelector
+        tableId: SalvageEquipmentUncommon
+        weight: 10
+    # 5% chance of moderate scrap
+    - !type:GroupSelector
+      weight: 5
+      children:
+      - !type:NestedSelector
+        tableId: SalvageScrapLowValue
+        weight: 30
+      - !type:NestedSelector
+        tableId: SalvageScrapHighValue
+        weight: 45
+      - !type:NestedSelector
+        tableId: SalvageScrapLarge
+        weight: 25
+    # 5% chance of maintenance fluff
+    - !type:NestedSelector
+      tableId: MaintFluffTable
+      weight: 5
+      rolls: !type:RangeNumberSelector
+        range: 1, 2
 
 - type: entity
   parent: MarkerBase
       state: diamond
   - type: EntityTableSpawner
     offset: 0.4
-    table: !type:GroupSelector
+    table: !type:NestedSelector
+      tableId: SalvageTreasureSpawnerValuable
       prob: 0.75
+
+- type: entityTable
+  id: SalvageEquipmentSpawnerCommon
+  table: !type:GroupSelector
+    children:
+    # 80% chance of equipment item
+    - !type:GroupSelector
+      weight: 80
       children:
-      # 80% chance of some treasure
-      - !type:GroupSelector
-        weight: 80
-        children:
-        - !type:NestedSelector
-          tableId: SalvageTreasureCommon
-          weight: 45
-        - !type:NestedSelector
-          tableId: SalvageTreasureUncommon
-          weight: 35
-        - !type:NestedSelector
-          tableId: SalvageTreasureRare
-          weight: 15
-        - !type:NestedSelector
-          tableId: SalvageTreasureLegendary
-          weight: 5
-      # 10% chance of low-level equipment
-      - !type:GroupSelector
-        weight: 10
-        children:
-        - !type:NestedSelector
-          tableId: SalvageEquipmentCommon
-          weight: 50
-        - !type:NestedSelector
-          tableId: SalvageEquipmentUncommon
-          weight: 40
-        - !type:NestedSelector
-          tableId: SalvageEquipmentUncommon
-          weight: 10
-      # 5% chance of moderate scrap
-      - !type:GroupSelector
+      - !type:NestedSelector
+        tableId: SalvageEquipmentCommon
+        weight: 60
+      - !type:NestedSelector
+        tableId: SalvageEquipmentUncommon
+        weight: 30
+      - !type:NestedSelector
+        tableId: SalvageEquipmentRare
+        weight: 9
+      - !type:NestedSelector
+        tableId: SalvageEquipmentLegendary
+        weight: 1
+    # 15% chance of decent-ish treasure
+    - !type:GroupSelector
+      weight: 15
+      children:
+      - !type:NestedSelector
+        tableId: SalvageTreasureCommon
+        weight: 75
+      - !type:NestedSelector
+        tableId: SalvageTreasureUncommon
+        weight: 20
+      - !type:NestedSelector
+        tableId: SalvageTreasureRare
         weight: 5
-        children:
-        - !type:NestedSelector
-          tableId: SalvageScrapLowValue
-          weight: 30
-        - !type:NestedSelector
-          tableId: SalvageScrapHighValue
-          weight: 45
-        - !type:NestedSelector
-          tableId: SalvageScrapLarge
-          weight: 25
-      # 5% chance of maintenance fluff
+    # 5% chance of decent maintenance loot
+    - !type:GroupSelector
+      weight: 5
+      children:
+      - !type:NestedSelector
+        tableId: MaintToolsTable
       - !type:NestedSelector
         tableId: MaintFluffTable
-        weight: 5
-        rolls: !type:RangeNumberSelector
-          range: 1, 2
 
 - type: entity
   parent: MarkerBase
       state: walkietalkie
   - type: EntityTableSpawner
     offset: 0.4
-    table: !type:GroupSelector
+    table: !type:NestedSelector
+      tableId: SalvageEquipmentSpawnerCommon
       prob: 0.75
+
+- type: entityTable
+  id: SalvageEquipmentSpawnerValuable
+  table: !type:GroupSelector
+    children:
+    # 80% chance of equipment item
+    - !type:GroupSelector
+      weight: 80
       children:
-      # 80% chance of equipment item
-      - !type:GroupSelector
-        weight: 80
-        children:
-        - !type:NestedSelector
-          tableId: SalvageEquipmentCommon
-          weight: 60
-        - !type:NestedSelector
-          tableId: SalvageEquipmentUncommon
-          weight: 30
-        - !type:NestedSelector
-          tableId: SalvageEquipmentRare
-          weight: 9
-        - !type:NestedSelector
-          tableId: SalvageEquipmentLegendary
-          weight: 1
-      # 15% chance of decent-ish treasure
-      - !type:GroupSelector
+      - !type:NestedSelector
+        tableId: SalvageEquipmentCommon
+        weight: 45
+      - !type:NestedSelector
+        tableId: SalvageEquipmentUncommon
+        weight: 35
+      - !type:NestedSelector
+        tableId: SalvageEquipmentRare
         weight: 15
-        children:
-        - !type:NestedSelector
-          tableId: SalvageTreasureCommon
-          weight: 75
-        - !type:NestedSelector
-          tableId: SalvageTreasureUncommon
-          weight: 20
-        - !type:NestedSelector
-          tableId: SalvageTreasureRare
-          weight: 5
-      # 5% chance of decent maintenance loot
-      - !type:GroupSelector
+      - !type:NestedSelector
+        tableId: SalvageEquipmentLegendary
         weight: 5
-        children:
-        - !type:NestedSelector
-          tableId: MaintToolsTable
-        - !type:NestedSelector
-          tableId: MaintFluffTable
+    # 14% chance of decent-ish treasure
+    - !type:GroupSelector
+      weight: 14
+      children:
+      - !type:NestedSelector
+        tableId: SalvageTreasureCommon
+        weight: 60
+      - !type:NestedSelector
+        tableId: SalvageTreasureUncommon
+        weight: 30
+      - !type:NestedSelector
+        tableId: SalvageTreasureRare
+        weight: 10
+    # 5% chance of decent maintenance loot
+    - !type:GroupSelector
+      weight: 5
+      children:
+      - !type:NestedSelector
+        tableId: MaintToolsTable
+      - !type:NestedSelector
+        tableId: MaintFluffTable
+    # 1% chance of syndie maintenance loot
+    - !type:GroupSelector
+      weight: 1
+      children:
+      - !type:NestedSelector
+        tableId: SyndieMaintLoot
 
 - type: entity
   parent: MarkerBase
       state: walkietalkie
   - type: EntityTableSpawner
     offset: 0.4
-    table: !type:GroupSelector
+    table: !type:NestedSelector
+      tableId: SalvageEquipmentSpawnerValuable
       prob: 0.75
-      children:
-      # 80% chance of equipment item
-      - !type:GroupSelector
-        weight: 80
-        children:
-        - !type:NestedSelector
-          tableId: SalvageEquipmentCommon
-          weight: 45
-        - !type:NestedSelector
-          tableId: SalvageEquipmentUncommon
-          weight: 35
-        - !type:NestedSelector
-          tableId: SalvageEquipmentRare
-          weight: 15
-        - !type:NestedSelector
-          tableId: SalvageEquipmentLegendary
-          weight: 5
-      # 14% chance of decent-ish treasure
-      - !type:GroupSelector
-        weight: 14
-        children:
-        - !type:NestedSelector
-          tableId: SalvageTreasureCommon
-          weight: 60
-        - !type:NestedSelector
-          tableId: SalvageTreasureUncommon
-          weight: 30
-        - !type:NestedSelector
-          tableId: SalvageTreasureRare
-          weight: 10
-      # 5% chance of decent maintenance loot
-      - !type:GroupSelector
-        weight: 5
-        children:
-        - !type:NestedSelector
-          tableId: MaintToolsTable
-        - !type:NestedSelector
-          tableId: MaintFluffTable
-      # 1% chance of syndie maintenance loot
-      - !type:GroupSelector
-        weight: 1
-        children:
-        - !type:NestedSelector
-          tableId: SyndieMaintLoot
 
 - type: entity
   name: Salvage Canister Spawner
index 315f908fad2aa43dbee2ba271829f9380957a51f..8c8d9147c42e8fe9665959dfa7869bd76d6fa5f2 100644 (file)
   layers:
   - !type:ExteriorDunGen
     proto: Experiment
+  - !type:EntityTableDunGen
+    minCount: 25
+    maxCount: 40
+    table: !type:NestedSelector
+      tableId: SalvageScrapSpawnerCommon
+  - !type:EntityTableDunGen
+    minCount: 30
+    maxCount: 40
+    table: !type:NestedSelector
+      tableId: SalvageScrapSpawnerValuable
+  - !type:EntityTableDunGen
+    minCount: 15
+    maxCount: 25
+    table: !type:NestedSelector
+      tableId: SalvageTreasureSpawnerCommon
+  - !type:EntityTableDunGen
+    minCount: 15
+    maxCount: 25
+    table: !type:NestedSelector
+      tableId: SalvageEquipmentSpawnerCommon
+  - !type:EntityTableDunGen
+    minCount: 15
+    maxCount: 20
+    table: !type:NestedSelector
+      tableId: SalvageTreasureSpawnerValuable
+  - !type:EntityTableDunGen
+    minCount: 15
+    maxCount: 20
+    table: !type:NestedSelector
+      tableId: SalvageEquipmentSpawnerValuable
   - !type:MobsDunGen
-    minCount: 5
-    maxCount: 8
+    minCount: 8
+    maxCount: 15
     groups:
     - id: MobGoliath
       amount: 1