]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add test that mob damage thresholds have alerts (#37307)
authorTayrtahn <tayrtahn@gmail.com>
Fri, 9 May 2025 17:07:17 +0000 (13:07 -0400)
committerGitHub <noreply@github.com>
Fri, 9 May 2025 17:07:17 +0000 (13:07 -0400)
* Add test that mob damage thresholds have alerts

* Docs

* Add BorgDead state to MobSiliconBase

Content.IntegrationTests/Tests/Damageable/MobThresholdsTest.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml

diff --git a/Content.IntegrationTests/Tests/Damageable/MobThresholdsTest.cs b/Content.IntegrationTests/Tests/Damageable/MobThresholdsTest.cs
new file mode 100644 (file)
index 0000000..e2f841f
--- /dev/null
@@ -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();
+    }
+}
index ceb9e67330500f307929b2bff1dcd9e2480486de..8cf66765bd63a5bca95e834c5f03e4179238aaa7 100644 (file)
@@ -62,6 +62,7 @@
       120: Dead
     stateAlertDict:
       Alive: BorgHealth
+      Dead: BorgDead
     showOverlays: false
   - type: Stamina
     critThreshold: 120