VGRoid support (#27659)
* Dungeon spawn support for grid spawns * Recursive dungeons working * Mask approach working * zack * More work * Fix recursive dungeons * Heap of work * weh * the cud * rar * Job * weh * weh * weh * Master merges * orch * weh * vgroid most of the work * Tweaks * Tweaks * weh * do do do do do do * Basic layout * Ore spawning working * Big breaking changes * Mob gen working * weh * Finalising * emo * More finalising * reverty * Reduce distance
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.PostGeneration;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Procedural.DungeonJob;
|
||||
|
||||
public sealed partial class DungeonJob
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="CornerClutterDunGen"/>
|
||||
/// </summary>
|
||||
private async Task PostGen(CornerClutterDunGen gen, DungeonData data, Dungeon dungeon, HashSet<Vector2i> reservedTiles, Random random)
|
||||
{
|
||||
if (!data.SpawnGroups.TryGetValue(DungeonDataKey.CornerClutter, out var corner))
|
||||
{
|
||||
_sawmill.Error(Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var tile in dungeon.CorridorTiles)
|
||||
{
|
||||
var blocked = _anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask);
|
||||
|
||||
if (blocked)
|
||||
continue;
|
||||
|
||||
// If at least 2 adjacent tiles are blocked consider it a corner
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var dir = (Direction) (i * 2);
|
||||
blocked = HasWall(tile + dir.ToIntVec());
|
||||
|
||||
if (!blocked)
|
||||
continue;
|
||||
|
||||
var nextDir = (Direction) ((i + 1) * 2 % 8);
|
||||
blocked = HasWall(tile + nextDir.ToIntVec());
|
||||
|
||||
if (!blocked)
|
||||
continue;
|
||||
|
||||
if (random.Prob(gen.Chance))
|
||||
{
|
||||
var coords = _maps.GridTileToLocal(_gridUid, _grid, tile);
|
||||
var protos = EntitySpawnCollection.GetSpawns(_prototype.Index(corner).Entries, random);
|
||||
_entManager.SpawnEntities(coords, protos);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user