mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
d42adbf05d
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
200 lines
8.8 KiB
C#
200 lines
8.8 KiB
C#
using Content.IntegrationTests.Fixtures;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Damage.Components;
|
|
using Content.Shared.Damage.Prototypes;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Destructible.Thresholds.Triggers;
|
|
using Content.Shared.FixedPoint;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Prototypes;
|
|
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
|
|
|
namespace Content.IntegrationTests.Tests.Destructible
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(DamageGroupTrigger))]
|
|
[TestOf(typeof(AndTrigger))]
|
|
public sealed class DestructibleDamageGroupTest : GameTest
|
|
{
|
|
[Test]
|
|
public async Task AndTest()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
|
|
var testMap = await pair.CreateTestMap();
|
|
|
|
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
|
var sPrototypeManager = server.ResolveDependency<IPrototypeManager>();
|
|
var sEntitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
|
|
|
EntityUid sDestructibleEntity = default;
|
|
DamageableComponent sDamageableComponent = null;
|
|
TestDestructibleListenerSystem sTestThresholdListenerSystem = null;
|
|
DamageableSystem sDamageableSystem = null;
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
var coordinates = testMap.GridCoords;
|
|
|
|
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageGroupEntityId, coordinates);
|
|
sDamageableComponent = sEntityManager.GetComponent<DamageableComponent>(sDestructibleEntity);
|
|
|
|
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
|
|
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
|
|
|
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
|
|
});
|
|
|
|
await server.WaitRunTicks(5);
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>(TestBruteDamageGroupId);
|
|
var burnDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>(TestBurnDamageGroupId);
|
|
|
|
DamageSpecifier bruteDamage = new(bruteDamageGroup, FixedPoint2.New(5));
|
|
DamageSpecifier burnDamage = new(burnDamageGroup, FixedPoint2.New(5));
|
|
|
|
// Raise brute damage to 5
|
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage, true);
|
|
|
|
// No thresholds reached yet, the earliest one is at 10 damage
|
|
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.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, 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.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.Multiple(() =>
|
|
{
|
|
Assert.That(trigger.Triggers[0], Is.InstanceOf<DamageGroupTrigger>());
|
|
Assert.That(trigger.Triggers[1], Is.InstanceOf<DamageGroupTrigger>());
|
|
});
|
|
|
|
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
|
|
|
// Raise brute damage to 20
|
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
|
|
|
// No new thresholds reached
|
|
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
|
|
|
// Raise burn damage to 20
|
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);
|
|
|
|
// No new thresholds reached
|
|
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
|
|
|
// Lower brute damage to 0
|
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * -10);
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(sDamageableSystem.GetTotalDamage(sDestructibleEntity), Is.EqualTo(FixedPoint2.New(20)));
|
|
|
|
// 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, Has.Count.EqualTo(1));
|
|
|
|
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
|
|
|
// Heal both classes of damage to 0
|
|
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
|
|
|
// No new thresholds reached, healing should not trigger it
|
|
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
|
|
|
// Raise brute damage to 10
|
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
|
|
|
// No new thresholds reached
|
|
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, Has.Count.EqualTo(1));
|
|
|
|
// Threshold brute 10 + burn 10
|
|
msg = sTestThresholdListenerSystem.ThresholdsReached[0];
|
|
threshold = msg.Threshold;
|
|
|
|
// Check that it matches the YAML prototype
|
|
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.Multiple(() =>
|
|
{
|
|
Assert.That(trigger.Triggers[0], Is.InstanceOf<DamageGroupTrigger>());
|
|
Assert.That(trigger.Triggers[1], Is.InstanceOf<DamageGroupTrigger>());
|
|
});
|
|
|
|
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
|
|
|
// Change triggers once to true
|
|
threshold.TriggersOnce = true;
|
|
|
|
// Heal brute and burn back to 0
|
|
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
|
|
|
// No new thresholds reached from healing
|
|
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
|
|
|
// Raise brute damage to 10
|
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);
|
|
|
|
// No new thresholds reached
|
|
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.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
|
});
|
|
}
|
|
}
|
|
}
|