Biome rework (#37735)
* 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>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.NPC;
|
||||
@@ -13,15 +14,22 @@ public sealed partial class DungeonJob
|
||||
/// <summary>
|
||||
/// <see cref="ExteriorDunGen"/>
|
||||
/// </summary>
|
||||
private async Task<List<Dungeon>> GenerateExteriorDungen(Vector2i position, ExteriorDunGen dungen, HashSet<Vector2i> reservedTiles, Random random)
|
||||
private async Task<List<Dungeon>> GenerateExteriorDungen(int runCount, int maxRuns, Vector2i position, ExteriorDunGen dungen, HashSet<Vector2i> reservedTiles, Random random)
|
||||
{
|
||||
DebugTools.Assert(_grid.ChunkCount > 0);
|
||||
|
||||
var aabb = new Box2i(_grid.LocalAABB.BottomLeft.Floored(), _grid.LocalAABB.TopRight.Floored());
|
||||
var angle = random.NextAngle();
|
||||
// TODO: Cross-layer seeding. Need this because we need to be able to spread the dungeons out.
|
||||
var angle = new Random(_seed).NextAngle();
|
||||
var divisors = new Angle(Angle.FromDegrees(360) / maxRuns);
|
||||
|
||||
// Offset each dungeon so they don't generate on top of each other.
|
||||
for (var i = 0; i < runCount; i++)
|
||||
{
|
||||
angle += (random.NextFloat(0.6f, 1.4f)) * divisors;
|
||||
}
|
||||
|
||||
var distance = Math.Max(aabb.Width / 2f + 1f, aabb.Height / 2f + 1f);
|
||||
|
||||
var startTile = new Vector2i(0, (int) distance).Rotate(angle);
|
||||
|
||||
Vector2i? dungeonSpawn = null;
|
||||
@@ -47,9 +55,19 @@ public sealed partial class DungeonJob
|
||||
};
|
||||
}
|
||||
|
||||
var config = _prototype.Index(dungen.Proto);
|
||||
// Move it further in based on the spawn angle.
|
||||
if (dungen.Penetration.Y > 0)
|
||||
{
|
||||
var penetration = random.Next(dungen.Penetration.X, dungen.Penetration.Y);
|
||||
var diff = dungeonSpawn.Value - startTile;
|
||||
var diffVec = new Vector2(diff.X, diff.Y);
|
||||
dungeonSpawn = (diffVec.Normalized() * (penetration + diffVec.Length())).Floored() + startTile;
|
||||
}
|
||||
|
||||
var subConfig = _prototype.Index(dungen.Proto);
|
||||
var nextSeed = random.Next();
|
||||
var dungeons = await GetDungeons(dungeonSpawn.Value, config, config.Layers, reservedTiles, nextSeed, new Random(nextSeed));
|
||||
var (dungeons, newReserved) = await GetDungeons(dungeonSpawn.Value, subConfig, subConfig.Layers, nextSeed, new Random(nextSeed), reserved: reservedTiles);
|
||||
reservedTiles.UnionWith(newReserved);
|
||||
|
||||
return dungeons;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user