Added ContainerSpawnPoint check for integration test (#25446)
* Added logic for ContainerSpawnPoint checks * Improved with template function * fixed nullable * hehe * hehe T? * added type check before cast * another nullable fix * and another one * return to old code (found typo) * Code cleanup --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -226,25 +226,13 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
if (entManager.HasComponent<StationJobsComponent>(station))
|
||||
{
|
||||
// Test that the map has valid latejoin spawn points
|
||||
// Test that the map has valid latejoin spawn points or container spawn points
|
||||
if (!NoSpawnMaps.Contains(mapProto))
|
||||
{
|
||||
var lateSpawns = 0;
|
||||
|
||||
var query = entManager.AllEntityQueryEnumerator<SpawnPointComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
if (comp.SpawnType != SpawnPointType.LateJoin
|
||||
|| !xformQuery.TryGetComponent(uid, out var xform)
|
||||
|| xform.GridUid == null
|
||||
|| !gridUids.Contains(xform.GridUid.Value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
lateSpawns++;
|
||||
break;
|
||||
}
|
||||
lateSpawns += GetCountLateSpawn<SpawnPointComponent>(gridUids, entManager);
|
||||
lateSpawns += GetCountLateSpawn<ContainerSpawnPointComponent>(gridUids, entManager);
|
||||
|
||||
Assert.That(lateSpawns, Is.GreaterThan(0), $"Found no latejoin spawn points on {mapProto}");
|
||||
}
|
||||
@@ -283,6 +271,32 @@ namespace Content.IntegrationTests.Tests
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static int GetCountLateSpawn<T>(List<EntityUid> gridUids, IEntityManager entManager)
|
||||
where T : ISpawnPoint, IComponent
|
||||
{
|
||||
var resultCount = 0;
|
||||
var queryPoint = entManager.AllEntityQueryEnumerator<T, TransformComponent>();
|
||||
#nullable enable
|
||||
while (queryPoint.MoveNext(out T? comp, out var xform))
|
||||
{
|
||||
var spawner = (ISpawnPoint) comp;
|
||||
|
||||
if (spawner.SpawnType is not SpawnPointType.LateJoin
|
||||
|| xform.GridUid == null
|
||||
|| !gridUids.Contains(xform.GridUid.Value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#nullable disable
|
||||
resultCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
return resultCount;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AllMapsTested()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user