Minor procedural fixes pack (#837)

* demiplanE

* Update EntityTest.cs

* Update DungeonSystem.Rooms.cs

* Update EntityTest.cs
This commit is contained in:
Ed
2025-02-03 17:09:09 +03:00
committed by GitHub
parent c0275238ac
commit 4aea4b853c
6 changed files with 69 additions and 77 deletions

View File

@@ -39,7 +39,7 @@ namespace Content.IntegrationTests.Tests
.Where(p => !p.Abstract)
.Where(p => !pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Where(p => !p.Components.ContainsKey("RoomFill")) // CP14 Boilerplate - TODO: Remove it after wizden fix
.Where(p => !p.Components.ContainsKey("RoomFill"))
.Select(p => p.ID)
.ToList();
@@ -102,7 +102,7 @@ namespace Content.IntegrationTests.Tests
.Where(p => !p.Abstract)
.Where(p => !pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Where(p => !p.Components.ContainsKey("RoomFill")) // CP14 Boilerplate - TODO: Remove it after wizden fix
.Where(p => !p.Components.ContainsKey("RoomFill"))
.Select(p => p.ID)
.ToList();
foreach (var protoId in protoIds)
@@ -163,7 +163,6 @@ namespace Content.IntegrationTests.Tests
.Where(p => !p.Abstract)
.Where(p => !pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Where(p => !p.Components.ContainsKey("RoomFill")) // CP14 Boilerplate - TODO: Remove it after wizden fix
.Select(p => p.ID)
.ToList();
@@ -238,7 +237,6 @@ namespace Content.IntegrationTests.Tests
var excluded = new[]
{
"MapGrid",
"RoomFill", // CP14 Boilerplate - TODO: Remove it after wizden fix
"StationEvent",
"TimedDespawn",
@@ -345,7 +343,7 @@ namespace Content.IntegrationTests.Tests
"DebugExceptionInitialize",
"DebugExceptionStartup",
"GridFill",
"RoomFill", // CP14 Boilerplate - TODO: Remove it after wizden fix
"RoomFill",
"Map", // We aren't testing a map entity in this test
"MapGrid",
"Broadphase",

View File

@@ -130,31 +130,31 @@ public sealed partial class DungeonSystem
var finalRoomRotation = roomTransform.Rotation();
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);
}
}
}
//if (clearExisting) //CP14 disable default 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;
@@ -183,14 +183,14 @@ public sealed partial class DungeonSystem
_tiles.Add((rounded, tileRef.Tile));
//CP14 clearExisting variant
//if (clearExisting)
//{
// var anchored = _maps.GetAnchoredEntities((gridUid, grid), rounded);
// foreach (var ent in anchored)
// {
// QueueDel(ent);
// }
//}
if (clearExisting)
{
var anchored = _maps.GetAnchoredEntities((gridUid, grid), rounded);
foreach (var ent in anchored)
{
QueueDel(ent);
}
}
//CP14 clearExisting variant end
}
}

View File

@@ -14,20 +14,20 @@ public sealed partial class CP14DemiplaneSystem
private void OnRiftInit(Entity<CP14DemiplaneRiftComponent> rift, ref MapInitEvent args)
{
var map = Transform(rift).MapUid;
if (TryComp<CP14DemiplaneComponent>(map, out var demiplan)) // In demiplan
if (TryComp<CP14DemiplaneComponent>(map, out var demiplane)) // In demiplane
{
if (rift.Comp.TryAutoLinkToMap)
rift.Comp.Demiplane = map.Value;
if (rift.Comp.ActiveTeleport)
AddDemiplanRandomEntryPoint((map.Value, demiplan), rift);
AddDemiplaneRandomEntryPoint((map.Value, demiplane), rift);
}
else if (rift.Comp.Demiplane is not null) //We out of demiplan
else if (rift.Comp.Demiplane is not null) //We out of demiplane
{
if (TryComp<CP14DemiplaneComponent>(rift.Comp.Demiplane, out var riftDemiplane))
{
if (rift.Comp.ActiveTeleport)
AddDemiplanRandomExitPoint((rift.Comp.Demiplane.Value, riftDemiplane), rift);
AddDemiplaneRandomExitPoint((rift.Comp.Demiplane.Value, riftDemiplane), rift);
}
}
}
@@ -40,35 +40,32 @@ public sealed partial class CP14DemiplaneSystem
if (!TryComp<CP14DemiplaneComponent>(rift.Comp.Demiplane, out var riftDemiplane))
return;
RemoveDemiplanRandomEntryPoint((rift.Comp.Demiplane.Value, riftDemiplane), rift);
RemoveDemiplaneRandomEntryPoint((rift.Comp.Demiplane.Value, riftDemiplane), rift);
RemoveDemiplanRandomExitPoint((rift.Comp.Demiplane.Value, riftDemiplane), rift);
}
/// <summary>
///Add a position in the real world where you can get out of this demiplan
///Add a position in the real world where you can get out of this demiplane
/// </summary>
private void AddDemiplanRandomExitPoint(Entity<CP14DemiplaneComponent> demiplan,
private void AddDemiplaneRandomExitPoint(Entity<CP14DemiplaneComponent> demiplane,
Entity<CP14DemiplaneRiftComponent> exitPoint)
{
if (demiplan.Comp.ExitPoints.Contains(exitPoint))
return;
demiplan.Comp.ExitPoints.Add(exitPoint);
exitPoint.Comp.Demiplane = demiplan;
demiplane.Comp.ExitPoints.Add(exitPoint);
exitPoint.Comp.Demiplane = demiplane;
}
/// <summary>
/// Removing the demiplan exit point, one of which the player can exit to
/// Removing the demiplane exit point, one of which the player can exit to
/// </summary>
private void RemoveDemiplanRandomExitPoint(Entity<CP14DemiplaneComponent>? demiplan,
private void RemoveDemiplanRandomExitPoint(Entity<CP14DemiplaneComponent>? demiplane,
EntityUid exitPoint)
{
if (!TryComp<CP14DemiplaneRiftComponent>(exitPoint, out var riftComp))
return;
if (demiplan is not null && demiplan.Value.Comp.ExitPoints.Contains(exitPoint))
if (demiplane is not null && demiplane.Value.Comp.ExitPoints.Contains(exitPoint))
{
demiplan.Value.Comp.ExitPoints.Remove(exitPoint);
demiplane.Value.Comp.ExitPoints.Remove(exitPoint);
riftComp.Demiplane = null;
}
@@ -77,27 +74,24 @@ public sealed partial class CP14DemiplaneSystem
}
/// <summary>
/// Add a position within the demiplan that can be entered into the demiplan
/// Add a position within the demiplane that can be entered into the demiplane
/// </summary>
private void AddDemiplanRandomEntryPoint(Entity<CP14DemiplaneComponent> demiplan,
private void AddDemiplaneRandomEntryPoint(Entity<CP14DemiplaneComponent> demiplane,
Entity<CP14DemiplaneRiftComponent> entryPoint)
{
if (demiplan.Comp.EntryPoints.Contains(entryPoint))
return;
demiplan.Comp.EntryPoints.Add(entryPoint);
entryPoint.Comp.Demiplane = demiplan;
demiplane.Comp.EntryPoints.Add(entryPoint);
entryPoint.Comp.Demiplane = demiplane;
}
private void RemoveDemiplanRandomEntryPoint(Entity<CP14DemiplaneComponent>? demiplan,
private void RemoveDemiplaneRandomEntryPoint(Entity<CP14DemiplaneComponent>? demiplane,
EntityUid entryPoint)
{
if (!TryComp<CP14DemiplaneRiftComponent>(entryPoint, out var riftComp))
return;
if (demiplan is not null && demiplan.Value.Comp.EntryPoints.Contains(entryPoint))
if (demiplane is not null && demiplane.Value.Comp.EntryPoints.Contains(entryPoint))
{
demiplan.Value.Comp.EntryPoints.Remove(entryPoint);
demiplane.Value.Comp.EntryPoints.Remove(entryPoint);
riftComp.Demiplane = null;
}
@@ -105,26 +99,26 @@ public sealed partial class CP14DemiplaneSystem
QueueDel(entryPoint);
}
public bool TryGetDemiplanEntryPoint(Entity<CP14DemiplaneComponent> demiplan, out EntityUid? entryPoint)
public bool TryGetDemiplaneEntryPoint(Entity<CP14DemiplaneComponent> demiplane, out EntityUid? entryPoint)
{
entryPoint = null;
if (demiplan.Comp.EntryPoints.Count == 0)
if (demiplane.Comp.EntryPoints.Count == 0)
return false;
entryPoint = _random.Pick(demiplan.Comp.EntryPoints);
entryPoint = _random.Pick(demiplane.Comp.EntryPoints);
return true;
}
public bool TryGetDemiplanExitPoint(Entity<CP14DemiplaneComponent> demiplan,
public bool TryGetDemiplaneExitPoint(Entity<CP14DemiplaneComponent> demiplane,
out EntityUid? exitPoint)
{
exitPoint = null;
if (demiplan.Comp.ExitPoints.Count == 0)
if (demiplane.Comp.ExitPoints.Count == 0)
return false;
exitPoint = _random.Pick(demiplan.Comp.ExitPoints);
exitPoint = _random.Pick(demiplane.Comp.ExitPoints);
return true;
}
}

View File

@@ -185,8 +185,8 @@ public sealed partial class CP14DemiplaneSystem
var connection = EnsureComp<CP14DemiplaneRiftComponent>(tempRift);
var connection2 = EnsureComp<CP14DemiplaneRiftComponent>(tempRift2);
AddDemiplanRandomExitPoint(demiplane.Value, (tempRift, connection));
AddDemiplanRandomExitPoint(demiplane.Value, (tempRift2, connection2));
AddDemiplaneRandomExitPoint(demiplane.Value, (tempRift, connection));
AddDemiplaneRandomExitPoint(demiplane.Value, (tempRift2, connection2));
#if !DEBUG
QueueDel(generator); //wtf its crash debug build!

View File

@@ -58,7 +58,7 @@ public sealed partial class CP14DemiplaneSystem : CP14SharedDemiplaneSystem
if (entity is null)
return false;
if (!TryGetDemiplanEntryPoint(demiplane, out var entryPoint) || entryPoint is null)
if (!TryGetDemiplaneEntryPoint(demiplane, out var entryPoint) || entryPoint is null)
{
Log.Error($"{entity} cant get in demiplane {demiplane}: no active entry points!");
return false;
@@ -86,7 +86,7 @@ public sealed partial class CP14DemiplaneSystem : CP14SharedDemiplaneSystem
if (Transform(entity.Value).MapUid != demiplane.Owner)
return false;
if (!TryGetDemiplanExitPoint(demiplane, out var connection) || connection is null)
if (!TryGetDemiplaneExitPoint(demiplane, out var connection) || connection is null)
{
Log.Error($"{entity} cant get out of demiplane {demiplane}: no active connections!");
return false;
@@ -119,7 +119,7 @@ public sealed partial class CP14DemiplaneSystem : CP14SharedDemiplaneSystem
foreach (var entry in demiplane.Comp.EntryPoints)
{
RemoveDemiplanRandomEntryPoint(demiplane, entry);
RemoveDemiplaneRandomEntryPoint(demiplane, entry);
}
}
}

View File

@@ -70,7 +70,7 @@ public sealed partial class CP14DemiplaneTravelingSystem : EntitySystem
var map = Transform(uid).MapUid;
if (TryComp<CP14DemiplaneComponent>(map, out var demiplan))
{
if (!_demiplan.TryGetDemiplanExitPoint((map.Value, demiplan), out _))
if (!_demiplan.TryGetDemiplaneExitPoint((map.Value, demiplan), out _))
break;
foreach (var ent in teleportedEnts) //We in demiplan, tp OUT
@@ -87,7 +87,7 @@ public sealed partial class CP14DemiplaneTravelingSystem : EntitySystem
if (rift.Demiplane is not null &&
TryComp<CP14DemiplaneComponent>(rift.Demiplane.Value, out var riftDemiplane))
{
if (!_demiplan.TryGetDemiplanEntryPoint((rift.Demiplane.Value, riftDemiplane), out _))
if (!_demiplan.TryGetDemiplaneEntryPoint((rift.Demiplane.Value, riftDemiplane), out _))
break;
foreach (var ent in teleportedEnts) //We out demiplan, tp IN