# 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: NFVGRoidChromite
  layers:
    - !type:PrototypeDunGen
      proto: NFVGRoidBlobChromite
    - !type:PrototypeDunGen
      proto: NFVGRoidExteriorChromite
#    - !type:PrototypeDunGen
#      proto: NFVGRoidSmallerChromite
    - !type:PrototypeDunGen
      proto: NFVGRoidSmallPathsChromite
    - !type:EntityTableDunGen
      minCount: 7
      maxCount: 12
      table:
        id: NFVGRoidInteriorRoomMarker
    - !type:BiomeDunGen
      biomeTemplate: NFVGRoidShadow
      tileMask:
      - FloorChromite
    # Fill
    # - !type:PrototypeDunGen
      # proto: NFVGRoidFillChromite
    # "WarpPoint"
    - !type:OreDunGen
      tileMask:
      - FloorChromite
      entity: WarpPointDungeon
      count: 1
      minGroupSize: 1
      maxGroupSize: 1
    # "Ores"
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: NFChromiteElementalSpawner
      count: 100
      minGroupSize: 1
      maxGroupSize: 1
    # Ores
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteTin
      count: 50
      minGroupSize: 10
      maxGroupSize: 15
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteCoal
      count: 50
      minGroupSize: 8
      maxGroupSize: 12
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteQuartz
      count: 50
      minGroupSize: 10
      maxGroupSize: 15
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteSalt
      count: 50
      minGroupSize: 8
      maxGroupSize: 12
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteGold
      count: 40
      minGroupSize: 8
      maxGroupSize: 12
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteSilver
      count: 40
      minGroupSize: 8
      maxGroupSize: 12
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromitePlasma
      count: 35
      minGroupSize: 4
      maxGroupSize: 8
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteUranium
      count: 35
      minGroupSize: 4
      maxGroupSize: 8
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: NFWallChromiteCobblebrick
      count: 100
      minGroupSize: 6
      maxGroupSize: 16
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteArtifactFragment
      count: 25
      minGroupSize: 1
      maxGroupSize: 3
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: WallRockChromiteDiamond
      count: 15
      minGroupSize: 1
      maxGroupSize: 2
    - !type:OreDunGen
      entityMask:
      - WallRockChromite
      entity: NFWallRockChromiteBluespace
      count: 10
      minGroupSize: 1
      maxGroupSize: 1
    # Decoration
    # - !type:OreDunGen
      # tileMask:
      # - FloorChromite
      # entity: FloraRockSolid
      # count: 20
      # minGroupSize: 1
      # maxGroupSize: 1
    # Mobs
    - !type:OreDunGen
      tileMask:
      - FloorChromite
      entity: SpawnMobBloodCultLeech
      count: 5
      minGroupSize: 1
      maxGroupSize: 1

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

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

- type: dungeonConfig
  id: NFVGRoidExteriorChromite
  reserveTiles: true
  layers:
  - !type:PrototypeDunGen
    proto: NFVGRoidExteriorDungeonsChromite
  - !type:SplineDungeonConnectorDunGen
    tile: FloorDarkHerringbone
    widenTile: FloorChromite

- type: dungeonConfig
  id: NFVGRoidExteriorDungeonsChromite
  reserveTiles: true
  minCount: 2
  maxCount: 3
  layers:
  - !type:ExteriorDunGen
    proto: NFVirologyLab
  - !type:EntityTableDunGen
    minCount: 25
    maxCount: 40
    table: !type:NestedSelector
      tableId: SalvageScrapSpawnerCommon
    perDungeon: true
  - !type:EntityTableDunGen
    minCount: 30
    maxCount: 40
    table: !type:NestedSelector
      tableId: SalvageScrapSpawnerValuable
    perDungeon: true
  - !type:EntityTableDunGen
    minCount: 15
    maxCount: 25
    table: !type:NestedSelector
      tableId: SalvageTreasureSpawnerCommon
    perDungeon: true
  - !type:EntityTableDunGen
    minCount: 15
    maxCount: 25
    table: !type:NestedSelector
      tableId: SalvageEquipmentSpawnerCommon
    perDungeon: true
  - !type:EntityTableDunGen
    minCount: 15
    maxCount: 20
    table: !type:NestedSelector
      tableId: SalvageTreasureSpawnerValuable
    perDungeon: true
  - !type:EntityTableDunGen
    minCount: 15
    maxCount: 20
    table: !type:NestedSelector
      tableId: SalvageEquipmentSpawnerValuable
    perDungeon: true
  - !type:EntityTableDunGen # Concealed mines
    minCount: 0
    maxCount: 3
    table: !type:NestedSelector
      tableId: NFTableRandomConcealedMine
    perDungeon: true
  - !type:MobsDunGen
    minCount: 1
    maxCount: 2
    contents: SpawnMobBloodCultistPriestTable
  - !type:MobsDunGen
    minCount: 1
    maxCount: 2
    contents: SpawnMobBloodCultistAcolyteTable
  - !type:MobsDunGen
    minCount: 1
    maxCount: 2
    contents: SpawnMobBloodCultistZealotMeleeTable
  - !type:MobsDunGen
    minCount: 1
    maxCount: 2
    contents: SpawnMobBloodCultistZealotRangedTable
  - !type:MobsDunGen
    minCount: 1
    maxCount: 2
    contents: SpawnMobBloodCultistCasterTable
  - !type:MobsDunGen
    minCount: 0
    maxCount: 1
    contents: SpawnMobBloodCultistAscendedTable # Boss
  # - !type:MobsDunGen # Dies to barotrauma - equip it for space if you want this restored
  #   minCount: 1
  #   maxCount: 1
  #   contents:SpawnMobCatBloodCultLowChanceTable

- type: entityTable
  id: SpawnMobBloodCultistPriestTable
  table: !type:GroupSelector
    children:
    - id: SpawnMobBloodCultistPriest
      amount: 1

- type: entityTable
  id: SpawnMobBloodCultistAcolyteTable
  table: !type:GroupSelector
    children:
    - id: SpawnMobBloodCultistAcolyte
      amount: 1

- type: entityTable
  id: SpawnMobBloodCultistZealotMeleeTable
  table: !type:GroupSelector
    children:
    - id: SpawnMobBloodCultistZealotMelee
      amount: 1

- type: entityTable
  id: SpawnMobBloodCultistZealotRangedTable
  table: !type:GroupSelector
    children:
    - id: SpawnMobBloodCultistZealotRanged
      amount: 1

- type: entityTable
  id: SpawnMobBloodCultistCasterTable
  table: !type:GroupSelector
    children:
    - id: SpawnMobBloodCultistCaster
      amount: 1

- type: entityTable
  id: SpawnMobBloodCultistAscendedTable
  table: !type:GroupSelector
    children:
    - id: SpawnMobBloodCultistAscended
      amount: 1

# Dies to barotrauma - equip it for space if you want this restored
#- type: entityTable
#  id: SpawnMobCatBloodCultLowChanceTable
#  table: !type:GroupSelector
#    children:
#    - id: SpawnMobCatBloodCultLowChance
#      amount: 1

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

- type: dungeonConfig
  id: NFVGRoidSmallPathsChromite
  reserveTiles: true
  layers:
  - !type:ReplaceTileDunGen
    layers:
    - tile: FloorChromite
      threshold: 0.75
      noise:
        frequency: 0.040
        noiseType: OpenSimplex2
        fractalType: Ridged
        lacunarity: 1.5
        octaves: 2
        gain: 2.0

# Shadow -> Derived from lava
- type: biomeTemplate
  id: NFVGRoidShadow
  layers:
    - !type:BiomeEntityLayer
      threshold: 0.70
      noise:
        frequency: 1
        seed: 3
      allowedTiles:
        - FloorChromite
      entities:
        - ShadowBasaltOne
        - ShadowBasaltTwo
        - ShadowBasaltThree
        - ShadowBasaltFour
        - ShadowBasaltFive
    - !type:BiomeEntityLayer
      threshold: 0.97
      noise:
        frequency: 1
        seed: 2
      allowedTiles:
        - FloorChromite
      entities:
        - CrystalPink
    - !type:BiomeEntityLayer
      threshold: 0.97
      noise:
        seed: 1
        noiseType: OpenSimplex2
        frequency: 1
      allowedTiles:
        - FloorChromite
      entities:
        - ShadowTree
        - CrystalPink
    # Rock formations
    - !type:BiomeEntityLayer
      threshold: -0.2
      invert: true
      noise:
        seed: 0
        noiseType: Perlin
        fractalType: FBm
        octaves: 3
        frequency: 0.3
        gain: 0
      allowedTiles:
        - FloorChromite
      entities:
        - WallRockChromite
    - !type:BiomeDummyLayer
      id: Loot
    # Fill chromite
    - !type:BiomeTileLayer
      threshold: -1
      tile: FloorChromite
