mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
## Mirror of PR #23768: [haunted dungeon template](https://github.com/space-wizards/space-station-14/pull/23768) from <img src="https://avatars.githubusercontent.com/u/10567778?v=4" alt="space-wizards" width="22"/> [space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14) ###### `952b7f4c4e8e957c0c3765f7b20f2745c9297e27` PR opened by <img src="https://avatars.githubusercontent.com/u/99158783?v=4" width="16"/><a href="https://github.com/Emisse"> Emisse</a> at 2024-01-09 07:36:29 UTC --- PR changed 17 files with 4009 additions and 67 deletions. The PR had the following labels: --- <details open="true"><summary><h1>Original Body</h1></summary> > also for sloth when he gets to it > > Requires https://github.com/space-wizards/RobustToolbox/pull/4980 </details> Co-authored-by: SimpleStation14 <Unknown>
54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using System.Threading.Tasks;
|
|
using Content.Shared.Procedural;
|
|
using Content.Shared.Procedural.PostGeneration;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Procedural;
|
|
|
|
public sealed partial class DungeonJob
|
|
{
|
|
private async Task PostGen(CorridorClutterPostGen gen, Dungeon dungeon, EntityUid gridUid, MapGridComponent grid,
|
|
Random random)
|
|
{
|
|
var physicsQuery = _entManager.GetEntityQuery<PhysicsComponent>();
|
|
var count = (int) Math.Ceiling(dungeon.CorridorTiles.Count * gen.Chance);
|
|
|
|
while (count > 0)
|
|
{
|
|
var tile = random.Pick(dungeon.CorridorTiles);
|
|
|
|
var enumerator = _maps.GetAnchoredEntitiesEnumerator(_gridUid, _grid, tile);
|
|
var blocked = false;
|
|
|
|
while (enumerator.MoveNext(out var ent))
|
|
{
|
|
if (!physicsQuery.TryGetComponent(ent, out var physics) ||
|
|
!physics.CanCollide ||
|
|
!physics.Hard)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
blocked = true;
|
|
break;
|
|
}
|
|
|
|
if (blocked)
|
|
continue;
|
|
|
|
count--;
|
|
|
|
var protos = EntitySpawnCollection.GetSpawns(gen.Contents, random);
|
|
var coords = _maps.ToCenterCoordinates(_gridUid, tile, _grid);
|
|
_entManager.SpawnEntities(coords, protos);
|
|
await SuspendIfOutOfTime();
|
|
|
|
if (!ValidateResume())
|
|
return;
|
|
}
|
|
}
|
|
}
|