* DungeonData rework Back to fields, serializes better, just make new layers dumby. * wawawewa * Fix this * Fixes * Port the work over * wawawewa * zoom * Kinda workin * Adjust wawa * Unloading work * Ore + entitytable fixes Iterate every dungeon not just last. * Big shot * wawawewa * Fixes * true * Fixes # Conflicts: # Content.Server/Procedural/DungeonJob/DungeonJob.cs * wawawewa * Fixes * Fix * Lot of work * wawawewa * Fixing * eh? * a * Fix a heap of stuff * Better ignored check * Reserve tile changes * biome * changes * wawawewa * Fixes & snow * Shadow fixes * wawawewa * smol * Add layer API * More work * wawawewa * Preloads and running again * wawawewa * Modified * Replacements and command * Runtime support * werk * Fix expeds + dungeon alltiles * reh --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System.Threading.Tasks;
|
|
using Content.Shared.Procedural;
|
|
using Content.Shared.Procedural.DungeonGenerators;
|
|
using Content.Shared.Procedural.PostGeneration;
|
|
|
|
namespace Content.Server.Procedural.DungeonJob;
|
|
|
|
public sealed partial class DungeonJob
|
|
{
|
|
/// <summary>
|
|
/// <see cref="BiomeDunGen"/>
|
|
/// </summary>
|
|
private async Task<Dungeon> PostGen(ChunkDunGen dunGen, HashSet<Vector2i> reservedTiles, Random random)
|
|
{
|
|
var dungeon = new Dungeon();
|
|
var tiles = new HashSet<Vector2i>();
|
|
var tr = _position + new Vector2i(dunGen.Size, dunGen.Size);
|
|
var oldSeed = dunGen.Noise?.GetSeed() ?? 0;
|
|
dunGen.Noise?.SetSeed(_seed + oldSeed);
|
|
|
|
for (var x = 0; x < dunGen.Size; x++)
|
|
{
|
|
for (var y = 0; y < dunGen.Size; y++)
|
|
{
|
|
var index = new Vector2i(_position.X + x, _position.Y + y);
|
|
|
|
if (reservedTiles.Contains(index))
|
|
continue;
|
|
|
|
if (dunGen.Noise?.GetNoise(x, y) < dunGen.Threshold)
|
|
continue;
|
|
|
|
tiles.Add(index);
|
|
}
|
|
}
|
|
|
|
dunGen.Noise?.SetSeed(oldSeed);
|
|
var room = new DungeonRoom(tiles, (tr - _position) / 2 + _position, new Box2i(_position, tr), new HashSet<Vector2i>());
|
|
dungeon.AddRoom(room);
|
|
return dungeon;
|
|
}
|
|
}
|