diff --git a/Content.Server/Procedural/DungeonSystem.Rooms.cs b/Content.Server/Procedural/DungeonSystem.Rooms.cs index a990edd715..e218c7312e 100644 --- a/Content.Server/Procedural/DungeonSystem.Rooms.cs +++ b/Content.Server/Procedural/DungeonSystem.Rooms.cs @@ -13,7 +13,6 @@ namespace Content.Server.Procedural; public sealed partial class DungeonSystem { // Temporary caches. - private readonly HashSet _entitySet = new(); private readonly List _availableRooms = new(); /// @@ -99,6 +98,20 @@ public sealed partial class DungeonSystem return roomRotation; } + private static Box2 GetRotatedBox(Vector2 point1, Vector2 point2, double angle) + { + if (angle == 0) + return new Box2(point1, point2); + if (Math.Abs(angle - Math.PI / 2) < 1E-5) + return new Box2(point2.X, point1.Y, point1.X, point2.Y); + if (Math.Abs(angle - Math.PI) < 1E-5) + return new Box2(point2, point1); + if (Math.Abs(angle + Math.PI / 2) < 1E-5) + return new Box2(point1.X, point2.Y, point2.X, point1.Y); + + throw new NotImplementedException(); + } + public void SpawnRoom( EntityUid gridUid, MapGridComponent grid, @@ -113,32 +126,37 @@ public sealed partial class DungeonSystem var templateGrid = Comp(templateMapUid); var roomDimensions = room.Size; + var entitySet = new HashSet(); + var finalRoomRotation = roomTransform.Rotation(); - //CP14 bandage it - int dont work - // go BRRNNTTT on existing stuff - //if (clearExisting) - //{ - // var gridBounds = new Box2(Vector2.Transform(-room.Size/2, roomTransform), Vector2.Transform(room.Size/2, roomTransform)); - // _entitySet.Clear(); - // // Polygon skin moment - // gridBounds = gridBounds.Enlarged(-0.05f); - // _lookup.GetLocalEntitiesIntersecting(gridUid, gridBounds, _entitySet, LookupFlags.Uncontained); -// - // foreach (var templateEnt in _entitySet) - // { - // Del(templateEnt); - // } -// - // if (TryComp(gridUid, out DecalGridComponent? decalGrid)) - // { - // foreach (var decal in _decals.GetDecalsIntersecting(gridUid, gridBounds, decalGrid)) - // { - // _decals.RemoveDecal(gridUid, decal.Index, decalGrid); - // } - // } - //} - //CP14 end + /* + if (clearExisting) + { + var point1 = Vector2.Transform(-room.Size / 2, roomTransform); + var point2 = Vector2.Transform(room.Size / 2, roomTransform); + + var gridBounds = GetRotatedBox(point1, point2, finalRoomRotation); + + entitySet.Clear(); + // Polygon skin moment + gridBounds = gridBounds.Enlarged(-0.05f); + _lookup.GetLocalEntitiesIntersecting(gridUid, gridBounds, entitySet, LookupFlags.Uncontained); + + foreach (var templateEnt in entitySet) + { + Del(templateEnt); + } + + if (TryComp(gridUid, out DecalGridComponent? decalGrid)) + { + foreach (var decal in _decals.GetDecalsIntersecting(gridUid, gridBounds, decalGrid)) + { + _decals.RemoveDecal(gridUid, decal.Index, decalGrid); + } + } + } + */ var roomCenter = (room.Offset + room.Size / 2f) * grid.TileSize; var tileOffset = -roomCenter + grid.TileSizeHalfVector; diff --git a/Content.Server/_CP14/Demiplane/Jobs/CP14SpawnRandomDemiplaneJob.cs b/Content.Server/_CP14/Demiplane/Jobs/CP14SpawnRandomDemiplaneJob.cs index 46d910bfde..dc20f857ba 100644 --- a/Content.Server/_CP14/Demiplane/Jobs/CP14SpawnRandomDemiplaneJob.cs +++ b/Content.Server/_CP14/Demiplane/Jobs/CP14SpawnRandomDemiplaneJob.cs @@ -67,7 +67,7 @@ public sealed class CP14SpawnRandomDemiplaneJob : Job protected override async Task Process() { - _sawmill.Debug("cp14_expedition", $"Spawning expedition mission with seed {0}"); + _sawmill.Debug("cp14_expedition", $"Spawning expedition mission with seed {_seed}"); var grid = _mapManager.CreateGridEntity(DemiplaneMapUid); MetaDataComponent? metadata = null; @@ -87,7 +87,6 @@ public sealed class CP14SpawnRandomDemiplaneJob : Job //Add map components _entManager.AddComponents(DemiplaneMapUid, expeditionConfig.Components); - //Apply modifiers foreach (var modifier in _modifiers) { @@ -104,6 +103,11 @@ public sealed class CP14SpawnRandomDemiplaneJob : Job dungeonConfig.Layers.AddRange(indexedConnections.Layers); } + foreach (var layer in dungeonConfig.Layers) + { + _sawmill.Debug("cp14_expedition", $"Added layer: {_seed} - {layer}"); + } + //Spawn modified config _dungeon.GenerateDungeon(dungeonConfig, grid,