NoiseDunGen.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Content.Shared.Procedural.Distance;
  2. using Robust.Shared.Noise;
  3. namespace Content.Shared.Procedural.DungeonGenerators;
  4. /// <summary>
  5. /// Generates dungeon flooring based on the specified noise.
  6. /// </summary>
  7. public sealed partial class NoiseDunGen : IDunGenLayer
  8. {
  9. /*
  10. * Floodfills out from 0 until it finds a valid tile.
  11. * From here it then floodfills until it can no longer fill in an area and generates a dungeon from that.
  12. */
  13. // At some point we may want layers masking each other like a simpler version of biome code but for now
  14. // we'll just make it circular.
  15. /// <summary>
  16. /// How many areas of noise to fill out. Useful if we just want 1 blob area to fill out.
  17. /// </summary>
  18. [DataField]
  19. public int Iterations = int.MaxValue;
  20. /// <summary>
  21. /// Cap on how many tiles to include.
  22. /// </summary>
  23. [DataField]
  24. public int TileCap = 128;
  25. /// <summary>
  26. /// Standard deviation of tilecap.
  27. /// </summary>
  28. [DataField]
  29. public float CapStd = 8f;
  30. [DataField(required: true)]
  31. public List<NoiseDunGenLayer> Layers = new();
  32. }
  33. [DataRecord]
  34. public partial record struct NoiseDunGenLayer
  35. {
  36. /// <summary>
  37. /// If the noise value is above this then it gets output.
  38. /// </summary>
  39. [DataField]
  40. public float Threshold;
  41. [DataField(required: true)]
  42. public string Tile;
  43. [DataField(required: true)]
  44. public FastNoiseLite Noise;
  45. }