Add test that mob damage thresholds have alerts (#37307)

* Add test that mob damage thresholds have alerts

* Docs

* Add BorgDead state to MobSiliconBase
This commit is contained in:
Tayrtahn
2025-05-09 13:07:17 -04:00
committed by GitHub
parent 6517710356
commit b769ab0f7e
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using Content.Shared.Alert;
using Content.Shared.Mobs.Components;
namespace Content.IntegrationTests.Tests.Damageable;
public sealed class MobThresholdsTest
{
/// <summary>
/// Inspects every entity prototype with a <see cref="MobThresholdsComponent"/> and makes
/// sure that every possible mob state is mapped to an <see cref="AlertPrototype"/>.
/// </summary>
[Test]
public async Task ValidateMobThresholds()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var entMan = server.EntMan;
var protoMan = server.ProtoMan;
var protos = pair.GetPrototypesWithComponent<MobThresholdsComponent>();
Assert.Multiple(() =>
{
foreach (var (proto, comp) in protos)
{
// See which mob states are mapped to alerts
var alertStates = comp.StateAlertDict.Keys;
// Check each mob state that this mob can be in
foreach (var (_, state) in comp.Thresholds)
{
// Make sure that an alert exists for each possible mob state
Assert.That(alertStates, Does.Contain(state), $"{proto.ID} does not have an alert state for mob state {state}");
}
}
});
await pair.CleanReturnAsync();
}
}