Fix content.integration tests warnings (#17817)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Destructible.Thresholds.Triggers;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -20,7 +18,11 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task AndTest()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
@@ -51,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
@@ -66,34 +68,40 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage, true);
|
||||
|
||||
// No thresholds reached yet, the earliest one is at 10 damage
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise brute damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage, true);
|
||||
|
||||
// No threshold reached, burn needs to be 10 as well
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise burn damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);
|
||||
|
||||
// One threshold reached, brute 10 + burn 10
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
// Threshold brute 10 + burn 10
|
||||
var msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
var threshold = msg.Threshold;
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.IsInstanceOf<AndTrigger>(threshold.Trigger);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.That(threshold.Trigger, Is.InstanceOf<AndTrigger>());
|
||||
});
|
||||
|
||||
var trigger = (AndTrigger) threshold.Trigger;
|
||||
|
||||
Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[0]);
|
||||
Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[1]);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(trigger.Triggers[0], Is.InstanceOf<DamageGroupTrigger>());
|
||||
Assert.That(trigger.Triggers[1], Is.InstanceOf<DamageGroupTrigger>());
|
||||
});
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
@@ -101,26 +109,29 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise burn damage to 20
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Lower brute damage to 0
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * -10);
|
||||
Assert.That(sDamageableComponent.TotalDamage,Is.EqualTo(FixedPoint2.New(20)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(20)));
|
||||
|
||||
// No new thresholds reached, healing should not trigger it
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
// No new thresholds reached, healing should not trigger it
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
|
||||
// Raise brute damage back up to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
||||
|
||||
// 10 brute + 10 burn threshold reached, brute was healed and brought back to its threshold amount and slash stayed the same
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
@@ -128,34 +139,40 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
|
||||
// No new thresholds reached, healing should not trigger it
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise brute damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise burn damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);
|
||||
|
||||
// Both classes of damage were healed and then raised again, the threshold should have been reached as triggers once is default false
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
// Threshold brute 10 + burn 10
|
||||
msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
threshold = msg.Threshold;
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.IsInstanceOf<AndTrigger>(threshold.Trigger);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.That(threshold.Trigger, Is.InstanceOf<AndTrigger>());
|
||||
});
|
||||
|
||||
trigger = (AndTrigger) threshold.Trigger;
|
||||
|
||||
Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[0]);
|
||||
Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[1]);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(trigger.Triggers[0], Is.InstanceOf<DamageGroupTrigger>());
|
||||
Assert.That(trigger.Triggers[1], Is.InstanceOf<DamageGroupTrigger>());
|
||||
});
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
@@ -166,19 +183,19 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
|
||||
// No new thresholds reached from healing
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise brute damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise burn damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);
|
||||
|
||||
// No new thresholds reached as triggers once is set to true and it already triggered before
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Destructible.Thresholds.Triggers;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
||||
|
||||
@@ -19,7 +15,11 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
@@ -48,7 +48,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
@@ -56,41 +56,47 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
var bluntDamageType = protoManager.Index<DamageTypePrototype>("TestBlunt");
|
||||
var slashDamageType = protoManager.Index<DamageTypePrototype>("TestSlash");
|
||||
|
||||
var bluntDamage = new DamageSpecifier(bluntDamageType,5);
|
||||
var slashDamage = new DamageSpecifier(slashDamageType,5);
|
||||
var bluntDamage = new DamageSpecifier(bluntDamageType, 5);
|
||||
var slashDamage = new DamageSpecifier(slashDamageType, 5);
|
||||
|
||||
// Raise blunt damage to 5
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
||||
|
||||
// No thresholds reached yet, the earliest one is at 10 damage
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise blunt damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
||||
|
||||
// No threshold reached, slash needs to be 10 as well
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise slash damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, slashDamage * 2, true);
|
||||
|
||||
// One threshold reached, blunt 10 + slash 10
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
// Threshold blunt 10 + slash 10
|
||||
var msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
var threshold = msg.Threshold;
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.IsInstanceOf<AndTrigger>(threshold.Trigger);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.That(threshold.Trigger, Is.InstanceOf<AndTrigger>());
|
||||
});
|
||||
|
||||
var trigger = (AndTrigger) threshold.Trigger;
|
||||
|
||||
Assert.IsInstanceOf<DamageTypeTrigger>(trigger.Triggers[0]);
|
||||
Assert.IsInstanceOf<DamageTypeTrigger>(trigger.Triggers[1]);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(trigger.Triggers[0], Is.InstanceOf<DamageTypeTrigger>());
|
||||
Assert.That(trigger.Triggers[1], Is.InstanceOf<DamageTypeTrigger>());
|
||||
});
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
@@ -98,25 +104,25 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise slash damage to 20
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, slashDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Lower blunt damage to 0
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * -4, true);
|
||||
|
||||
// No new thresholds reached, healing should not trigger it
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise blunt damage back up to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 2, true);
|
||||
|
||||
// 10 blunt + 10 slash threshold reached, blunt was healed and brought back to its threshold amount and slash stayed the same
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
@@ -125,34 +131,40 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, slashDamage * -4, true);
|
||||
|
||||
// No new thresholds reached, healing should not trigger it
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise blunt damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise slash damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, slashDamage * 2, true);
|
||||
|
||||
// Both types of damage were healed and then raised again, the threshold should have been reached as triggers once is default false
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
// Threshold blunt 10 + slash 10
|
||||
msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
threshold = msg.Threshold;
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.IsInstanceOf<AndTrigger>(threshold.Trigger);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.That(threshold.Trigger, Is.InstanceOf<AndTrigger>());
|
||||
});
|
||||
|
||||
trigger = (AndTrigger) threshold.Trigger;
|
||||
|
||||
Assert.IsInstanceOf<DamageTypeTrigger>(trigger.Triggers[0]);
|
||||
Assert.IsInstanceOf<DamageTypeTrigger>(trigger.Triggers[1]);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(trigger.Triggers[0], Is.InstanceOf<DamageTypeTrigger>());
|
||||
Assert.That(trigger.Triggers[1], Is.InstanceOf<DamageTypeTrigger>());
|
||||
});
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
@@ -164,19 +176,19 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, slashDamage * -2, true);
|
||||
|
||||
// No new thresholds reached from healing
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise blunt damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 2, true);
|
||||
|
||||
// No new thresholds reached
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Raise slash damage to 10
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, slashDamage * 2, true);
|
||||
|
||||
// No new thresholds reached as triggers once is set to true and it already triggered before
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Destructible.Thresholds;
|
||||
using Content.Server.Destructible.Thresholds.Behaviors;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
||||
|
||||
@@ -18,7 +14,11 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
@@ -43,27 +43,35 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
{
|
||||
var coordinates = sEntityManager.GetComponent<TransformComponent>(sDestructibleEntity).Coordinates;
|
||||
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
|
||||
DamageSpecifier bruteDamage = new(bruteDamageGroup,50);
|
||||
DamageSpecifier bruteDamage = new(bruteDamageGroup, 50);
|
||||
|
||||
#pragma warning disable NUnit2045 // Interdependent assertions.
|
||||
Assert.DoesNotThrow(() =>
|
||||
{
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(sDestructibleEntity, bruteDamage, true);
|
||||
sEntityManager.System<DamageableSystem>().TryChangeDamage(sDestructibleEntity, bruteDamage, true);
|
||||
});
|
||||
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
#pragma warning restore NUnit2045
|
||||
|
||||
var threshold = sTestThresholdListenerSystem.ThresholdsReached[0].Threshold;
|
||||
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.That(threshold.Behaviors.Count, Is.EqualTo(3));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.That(threshold.Behaviors, Has.Count.EqualTo(3));
|
||||
});
|
||||
|
||||
var spawnEntitiesBehavior = (SpawnEntitiesBehavior) threshold.Behaviors.Single(b => b is SpawnEntitiesBehavior);
|
||||
|
||||
Assert.That(spawnEntitiesBehavior.Spawn.Count, Is.EqualTo(1));
|
||||
Assert.That(spawnEntitiesBehavior.Spawn.Keys.Single(), Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnEntitiesBehavior.Spawn.Values.Single(), Is.EqualTo(new MinMax {Min = 1, Max = 1}));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(spawnEntitiesBehavior.Spawn, Has.Count.EqualTo(1));
|
||||
Assert.That(spawnEntitiesBehavior.Spawn.Keys.Single(), Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnEntitiesBehavior.Spawn.Values.Single(), Is.EqualTo(new MinMax { Min = 1, Max = 1 }));
|
||||
});
|
||||
|
||||
var entitiesInRange = EntitySystem.Get<EntityLookupSystem>().GetEntitiesInRange(coordinates, 2);
|
||||
var entitiesInRange = sEntityManager.System<EntityLookupSystem>().GetEntitiesInRange(coordinates, 2);
|
||||
var found = false;
|
||||
|
||||
foreach (var entity in entitiesInRange)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Destructible;
|
||||
using Content.Server.Destructible.Thresholds;
|
||||
using Content.Server.Destructible.Thresholds.Behaviors;
|
||||
@@ -7,10 +6,7 @@ using Content.Server.Destructible.Thresholds.Triggers;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
||||
|
||||
@@ -24,7 +20,11 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
||||
@@ -58,7 +58,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
@@ -68,28 +68,31 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
||||
|
||||
// No thresholds reached yet, the earliest one is at 20 damage
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
||||
|
||||
// Only one threshold reached, 20
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
// Threshold 20
|
||||
var msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
var threshold = msg.Threshold;
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(threshold.Behaviors, Is.Empty);
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
});
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*3, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 3, true);
|
||||
|
||||
// One threshold reached, 50, since 20 already triggered before and it has not been healed below that amount
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
// Threshold 50
|
||||
msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
@@ -102,37 +105,40 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
var spawnThreshold = (SpawnEntitiesBehavior) threshold.Behaviors[1];
|
||||
var actsThreshold = (DoActsBehavior) threshold.Behaviors[2];
|
||||
|
||||
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
|
||||
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
|
||||
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
|
||||
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
|
||||
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
|
||||
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
|
||||
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
});
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
// Damage for 50 again, up to 100 now
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*5, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 5, true);
|
||||
|
||||
// No thresholds reached as they weren't healed below the trigger amount
|
||||
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Set damage to 0
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
|
||||
// Damage for 100, up to 100
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*10, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 10, true);
|
||||
|
||||
// Two thresholds reached as damage increased past the previous, 20 and 50
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(2));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(2));
|
||||
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
// Heal the entity for 40 damage, down to 60
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*-4, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * -4, true);
|
||||
|
||||
// ThresholdsLookup don't work backwards
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
@@ -144,7 +150,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Heal by 30, down to 40
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*-3, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * -3, true);
|
||||
|
||||
// ThresholdsLookup don't work backwards
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
@@ -153,7 +159,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
||||
|
||||
// The 50 threshold should have triggered again, after being healed
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Count.EqualTo(1));
|
||||
|
||||
msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
threshold = msg.Threshold;
|
||||
@@ -166,15 +172,18 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
actsThreshold = (DoActsBehavior) threshold.Behaviors[2];
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
|
||||
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
|
||||
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
|
||||
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
|
||||
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
|
||||
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
|
||||
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
});
|
||||
|
||||
// Reset thresholds reached
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
@@ -183,19 +192,25 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
|
||||
// Damage up to 50
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*5, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 5, true);
|
||||
|
||||
// Check that the total damage matches
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(50)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Check that the total damage matches
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(50)));
|
||||
|
||||
// Both thresholds should have triggered
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Exactly(2).Items);
|
||||
// Both thresholds should have triggered
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Has.Exactly(2).Items);
|
||||
});
|
||||
|
||||
// Verify the first one, should be the lowest one (20)
|
||||
msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
||||
var trigger = (DamageTrigger) msg.Threshold.Trigger;
|
||||
Assert.NotNull(trigger);
|
||||
Assert.That(trigger.Damage, Is.EqualTo(20));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(trigger, Is.Not.Null);
|
||||
Assert.That(trigger.Damage, Is.EqualTo(20));
|
||||
});
|
||||
|
||||
threshold = msg.Threshold;
|
||||
|
||||
@@ -205,8 +220,11 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
// Verify the second one, should be the highest one (50)
|
||||
msg = sTestThresholdListenerSystem.ThresholdsReached[1];
|
||||
trigger = (DamageTrigger) msg.Threshold.Trigger;
|
||||
Assert.NotNull(trigger);
|
||||
Assert.That(trigger.Damage, Is.EqualTo(50));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(trigger, Is.Not.Null);
|
||||
Assert.That(trigger.Damage, Is.EqualTo(50));
|
||||
});
|
||||
|
||||
threshold = msg.Threshold;
|
||||
|
||||
@@ -217,15 +235,18 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
actsThreshold = (DoActsBehavior) threshold.Behaviors[2];
|
||||
|
||||
// Check that it matches the YAML prototype
|
||||
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
|
||||
Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
|
||||
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
|
||||
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
|
||||
Assert.NotNull(threshold.Trigger);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
|
||||
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
|
||||
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
|
||||
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
|
||||
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
|
||||
Assert.That(threshold.Trigger, Is.Not.Null);
|
||||
Assert.That(threshold.Triggered, Is.True);
|
||||
});
|
||||
|
||||
// Reset thresholds reached
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
@@ -239,31 +260,37 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
// Set both thresholds to only trigger once
|
||||
foreach (var destructibleThreshold in sDestructibleComponent.Thresholds)
|
||||
{
|
||||
Assert.NotNull(destructibleThreshold.Trigger);
|
||||
Assert.That(destructibleThreshold.Trigger, Is.Not.Null);
|
||||
destructibleThreshold.TriggersOnce = true;
|
||||
}
|
||||
|
||||
// Damage the entity up to 50 damage again
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*5, true);
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 5, true);
|
||||
|
||||
// Check that the total damage matches
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(50)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Check that the total damage matches
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(50)));
|
||||
|
||||
// No thresholds should have triggered as they were already triggered before, and they are set to only trigger once
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
// No thresholds should have triggered as they were already triggered before, and they are set to only trigger once
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
|
||||
// Set both thresholds to trigger multiple times
|
||||
foreach (var destructibleThreshold in sDestructibleComponent.Thresholds)
|
||||
{
|
||||
Assert.NotNull(destructibleThreshold.Trigger);
|
||||
Assert.That(destructibleThreshold.Trigger, Is.Not.Null);
|
||||
destructibleThreshold.TriggersOnce = false;
|
||||
}
|
||||
|
||||
// Check that the total damage matches
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(50)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// Check that the total damage matches
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(50)));
|
||||
|
||||
// They shouldn't have been triggered by changing TriggersOnce
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
// They shouldn't have been triggered by changing TriggersOnce
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
});
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user