* 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>
64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using System.Threading.Tasks;
|
|
using Content.Shared.Procedural;
|
|
using Content.Shared.Procedural.DungeonLayers;
|
|
|
|
namespace Content.Server.Procedural.DungeonJob;
|
|
|
|
public sealed partial class DungeonJob
|
|
{
|
|
/// <summary>
|
|
/// <see cref="Shared.Procedural.DungeonLayers.FillGridDunGen"/>
|
|
/// </summary>
|
|
private async Task GenerateFillDunGen(FillGridDunGen fill, List<Dungeon> dungeons, HashSet<Vector2i> reservedTiles)
|
|
{
|
|
foreach (var dungeon in dungeons)
|
|
{
|
|
foreach (var tile in dungeon.AllTiles)
|
|
{
|
|
if (reservedTiles.Contains(tile))
|
|
continue;
|
|
|
|
await SuspendDungeon();
|
|
if (!ValidateResume())
|
|
return;
|
|
|
|
if (!_maps.TryGetTileDef(_grid, tile, out var tileDef))
|
|
continue;
|
|
|
|
if (fill.AllowedTiles != null && !fill.AllowedTiles.Contains(tileDef.ID))
|
|
continue;
|
|
|
|
// If noise then check it matches.
|
|
if (fill.ReservedNoise != null)
|
|
{
|
|
var value = fill.ReservedNoise.GetNoise(tile.X, tile.Y);
|
|
|
|
if (fill.DistanceConfig != null)
|
|
{
|
|
// Need to get dx - dx in a range from -1 -> 1
|
|
var dx = 2 * tile.X / fill.Size.X;
|
|
var dy = 2 * tile.Y / fill.Size.Y;
|
|
|
|
var distance = GetDistance(dx, dy, fill.DistanceConfig);
|
|
|
|
value = MathHelper.Lerp(value, 1f - distance, fill.DistanceConfig.BlendWeight);
|
|
}
|
|
|
|
value *= (fill.Invert ? -1 : 1);
|
|
|
|
if (value < fill.Threshold)
|
|
continue;
|
|
}
|
|
|
|
if (!_anchorable.TileFree((_gridUid, _grid), tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
|
continue;
|
|
|
|
var gridPos = _maps.GridTileToLocal(_gridUid, _grid, tile);
|
|
var uid = _entManager.SpawnEntity(fill.Entity, gridPos);
|
|
|
|
AddLoadedEntity(tile, uid);
|
|
}
|
|
}
|
|
}
|
|
}
|