anchoring deletion

This commit is contained in:
Ed
2024-11-03 11:50:45 +03:00
parent 79eeef713a
commit 22e5b58db0
2 changed files with 49 additions and 27 deletions

View File

@@ -13,7 +13,6 @@ namespace Content.Server.Procedural;
public sealed partial class DungeonSystem
{
// Temporary caches.
private readonly HashSet<EntityUid> _entitySet = new();
private readonly List<DungeonRoomPrototype> _availableRooms = new();
/// <summary>
@@ -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<MapGridComponent>(templateMapUid);
var roomDimensions = room.Size;
var entitySet = new HashSet<EntityUid>();
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;

View File

@@ -67,7 +67,7 @@ public sealed class CP14SpawnRandomDemiplaneJob : Job<bool>
protected override async Task<bool> 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<bool>
//Add map components
_entManager.AddComponents(DemiplaneMapUid, expeditionConfig.Components);
//Apply modifiers
foreach (var modifier in _modifiers)
{
@@ -104,6 +103,11 @@ public sealed class CP14SpawnRandomDemiplaneJob : Job<bool>
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,