-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mirror: haunted dungeon template (#321)
## Mirror of PR #23768: [haunted dungeon template](space-wizards/space-station-14#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 space-wizards/RobustToolbox#4980 </details> Co-authored-by: SimpleStation14 <Unknown>
- Loading branch information
1 parent
d19e5bb
commit 3b635f1
Showing
17 changed files
with
4,009 additions
and
67 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Content.Server/Procedural/DungeonJob.CorridorClutterPost.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.