* 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
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using System.Threading.Tasks;
|
|
using Content.Server.Ghost.Roles.Components;
|
|
using Content.Server.NPC.Components;
|
|
using Content.Server.NPC.Systems;
|
|
using Content.Shared.Physics;
|
|
using Content.Shared.Procedural;
|
|
using Content.Shared.Procedural.DungeonLayers;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Collections;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Procedural.DungeonJob;
|
|
|
|
public sealed partial class DungeonJob
|
|
{
|
|
private async Task PostGen(
|
|
MobsDunGen gen,
|
|
Dungeon dungeon,
|
|
Random random)
|
|
{
|
|
var availableRooms = new ValueList<DungeonRoom>();
|
|
availableRooms.AddRange(dungeon.Rooms);
|
|
var availableTiles = new ValueList<Vector2i>(dungeon.AllTiles);
|
|
|
|
var entities = EntitySpawnCollection.GetSpawns(gen.Groups, random);
|
|
var count = random.Next(gen.MinCount, gen.MaxCount + 1);
|
|
var npcs = _entManager.System<NPCSystem>();
|
|
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
while (availableTiles.Count > 0)
|
|
{
|
|
var tile = availableTiles.RemoveSwap(random.Next(availableTiles.Count));
|
|
|
|
if (!_anchorable.TileFree(_grid, tile, (int) CollisionGroup.MachineLayer,
|
|
(int) CollisionGroup.MachineLayer))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
foreach (var ent in entities)
|
|
{
|
|
var uid = _entManager.SpawnAtPosition(ent, _maps.GridTileToLocal(_gridUid, _grid, tile));
|
|
_entManager.RemoveComponent<GhostRoleComponent>(uid);
|
|
_entManager.RemoveComponent<GhostTakeoverAvailableComponent>(uid);
|
|
npcs.SleepNPC(uid);
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
await SuspendDungeon();
|
|
|
|
if (!ValidateResume())
|
|
return;
|
|
}
|
|
}
|
|
}
|