Test to ensure all maps have needed job spawnPoints (#11849)

This commit is contained in:
corentt
2022-10-15 22:18:48 +02:00
committed by GitHub
parent 434da2df36
commit 56a8dac3fc
3 changed files with 39 additions and 0 deletions

View File

@@ -8,7 +8,10 @@ using Content.Client.Shuttles.Systems;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Maps; using Content.Server.Maps;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using Content.Server.Spawners.Components;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.Roles;
using NUnit.Framework; using NUnit.Framework;
using Robust.Server.Maps; using Robust.Server.Maps;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
@@ -127,6 +130,7 @@ namespace Content.IntegrationTests.Tests
var protoManager = server.ResolveDependency<IPrototypeManager>(); var protoManager = server.ResolveDependency<IPrototypeManager>();
var ticker = entManager.EntitySysManager.GetEntitySystem<GameTicker>(); var ticker = entManager.EntitySysManager.GetEntitySystem<GameTicker>();
var shuttleSystem = entManager.EntitySysManager.GetEntitySystem<ShuttleSystem>(); var shuttleSystem = entManager.EntitySysManager.GetEntitySystem<ShuttleSystem>();
var stationJobsSystem = entManager.EntitySysManager.GetEntitySystem<StationJobsSystem>();
await server.WaitPost(() => await server.WaitPost(() =>
{ {
@@ -171,6 +175,23 @@ namespace Content.IntegrationTests.Tests
mapManager.DeleteMap(shuttleMap); mapManager.DeleteMap(shuttleMap);
// Test all availableJobs have spawnPoints
// This is done inside gamemap test because loading the map takes ages and we already have it.
var jobList = entManager.GetComponent<StationJobsComponent>(station).RoundStartJobList
.Where(x => x.Value != 0)
.Select(x => x.Key);
var spawnPoints = entManager.EntityQuery<SpawnPointComponent>()
.Where(spawnpoint => spawnpoint.SpawnType == SpawnPointType.Job)
.Select(spawnpoint => spawnpoint.Job.ID)
.Distinct();
List<string> missingSpawnPoints = new() { };
foreach (var spawnpoint in jobList.Except(spawnPoints))
{
if (protoManager.Index<JobPrototype>(spawnpoint).SetPreference)
missingSpawnPoints.Add(spawnpoint);
}
Assert.That(missingSpawnPoints.Count() == 0, $"There is no spawnpoint for {String.Join(", ", missingSpawnPoints)} on {mapProto}.");
try try
{ {
mapManager.DeleteMap(mapId); mapManager.DeleteMap(mapId);

View File

@@ -230788,4 +230788,16 @@ entities:
- pos: -42.5,1.5 - pos: -42.5,1.5
parent: 8364 parent: 8364
type: Transform type: Transform
- uid: 25949
type: SpawnPointServiceWorker
components:
- pos: 37.5,-7.5
parent: 8364
type: Transform
- uid: 25950
type: SpawnPointServiceWorker
components:
- pos: 31.5,0.5
parent: 8364
type: Transform
... ...

View File

@@ -97270,4 +97270,10 @@ entities:
- pos: -20.5,10.5 - pos: -20.5,10.5
parent: 0 parent: 0
type: Transform type: Transform
- uid: 12386
type: SpawnPointServiceWorker
components:
- pos: 4.5,-0.5
parent: 0
type: Transform
... ...