# SPDX-FileCopyrightText: 2024 Aiden <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Weide <64257676+Lyacs@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lanse12 <cloudability.ez@gmail.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 yglop <95057024+yglop@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Okay so my general thought is this:
# 1. Generate the large mass
# 2. Generate smaller masses offset
# 3. Generate N normal dungeons around the larger mass, preferably near the border
# 4. Generate large paths / small paths around the place
# 5. Spawn ores + fill the rest and the normal stuff

# If you want mobs they needed to be added at specific steps due to how dungeons work at the moment.

- type: dungeonConfig
  id: VGRoid
  layers:
    - !type:PrototypeDunGen
      proto: VGRoidBlob
    - !type:PrototypeDunGen
      proto: VGRoidExterior
    - !type:PrototypeDunGen
      proto: VGRoidSmaller
    - !type:PrototypeDunGen
      proto: VGRoidSmallPaths
      inheritDungeons: All
    - !type:EntityTableDunGen
      minCount: 7
      maxCount: 12
      table:
        id: VGRoidInteriorRoomMarker
    # Fill
    - !type:PrototypeDunGen
      proto: VGRoidFill
      inheritDungeons: All
    # Ores
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockIron
      count: 50
      minGroupSize: 20
      maxGroupSize: 30
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockCoal
      count: 50
      minGroupSize: 15
      maxGroupSize: 20
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockQuartz
      count: 50
      minGroupSize: 20
      maxGroupSize: 30
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockGold
      count: 50
      minGroupSize: 10
      maxGroupSize: 20
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockSilver
      count: 50
      minGroupSize: 10
      maxGroupSize: 20
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockPlasma
      count: 50
      minGroupSize: 10
      maxGroupSize: 20
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockUranium
      count: 50
      minGroupSize: 10
      maxGroupSize: 20
    - !type:OreDunGen #Goob wiznerf partial revert
      replacement: IronRock
      entity: IronRockBananium
      count: 50
      minGroupSize: 5
      maxGroupSize: 10
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockArtifactFragment
      count: 50
      minGroupSize: 2
      maxGroupSize: 4
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockDiamond
      count: 15
      minGroupSize: 1
      maxGroupSize: 2
    - !type:OreDunGen # Goobstation
      replacement: IronRock
      entity: IronRockBSCrystal
      count: 40
      minGroupSize: 2
      maxGroupSize: 5
    - !type:OreDunGen
      replacement: IronRock
      entity: IronRockGibtonite
      count: 60 # you don't really hit it on purpose so it should be common
      minGroupSize: 1
      maxGroupSize: 1

# Configs
- type: dungeonConfig
  id: VGRoidBlob
  layers:
  - !type:NoiseDistanceDunGen
    size: 272, 272
    distanceConfig: !type:DunGenEuclideanSquaredDistance
      blendWeight: 0.80
    layers:
    - tile: FloorAsteroidSand
      threshold: 0.50
      noise:
        frequency: 0.010
        noiseType: OpenSimplex2
        fractalType: FBm
        octaves: 5
        lacunarity: 2
        gain: 0.5

- type: dungeonConfig
  id: VGRoidSmaller
  minOffset: 40
  maxOffset: 60
  layers:
  - !type:NoiseDistanceDunGen
    size: 150, 150
    distanceConfig: !type:DunGenEuclideanSquaredDistance
    layers:
    - tile: FloorAsteroidSand
      threshold: 0.50
      noise:
        frequency: 0.080
        noiseType: OpenSimplex2
        fractalType: FBm
        octaves: 5
        lacunarity: 1.5
        gain: 0.5

- type: dungeonConfig
  id: VGRoidExterior
  reserveTiles: true
  layers:
  - !type:PrototypeDunGen
    proto: VGRoidExteriorDungeons
  - !type:SplineDungeonConnectorDunGen
    tile: PlatingAsteroid
    widenTile: FloorAsteroidSand

- type: dungeonConfig
  id: VGRoidExteriorDungeons
  reserveTiles: true
  minCount: 2
  maxCount: 3
  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: 30
    maxCount: 45
    table: !type:NestedSelector
      tableId: SalvageTreasureSpawnerCommon
  - !type:EntityTableDunGen
    minCount: 30
    maxCount: 45
    table: !type:NestedSelector
      tableId: SalvageTreasureSpawnerValuable
  - !type:MobsDunGen
    minCount: 8
    maxCount: 15
    contents: VGRoidExteriorDungeonsMobs

- type: entityTable
  id: VGRoidExteriorDungeonsMobs
  table: !type:GroupSelector
    children:
    - id: SalvageSpawnerMobMiningAsteroid
      amount: 1

#- type: dungeonConfig
#  id: VGRoidInteriorDungeons
#  minCount: 3
#  maxCount: 5
#  # Just randomly spawn these in bounds, doesn't really matter if they go out.

- type: dungeonConfig
  id: VGRoidSmallPaths
  reserveTiles: true
  layers:
  - !type:ReplaceTileDunGen
    layers:
    - tile: FloorAsteroidSand
      threshold: 0.75
      noise:
        frequency: 0.040
        noiseType: OpenSimplex2
        fractalType: Ridged
        lacunarity: 1.5
        octaves: 2
        gain: 2.0
  # Mobs
  # If you want exterior dungeon mobs add them under the prototype.
  - !type:MobsDunGen
    minCount: 25
    maxCount: 35
    contents: VGRoidSmallPathsMobs

- type: entityTable
  id: VGRoidSmallPathsMobs
  table: !type:GroupSelector
    children:
    - id: SalvageSpawnerMobMiningAsteroid
      amount: 1

#- type: dungeonConfig
#  id: VGRoidOres

# Fill with rocks.
- type: dungeonConfig
  id: VGRoidFill
  layers:
  - !type:FillGridDunGen
    entity: IronRock
    allowedTiles:
    - FloorAsteroidSand