Update DamageableSystem to modern standards (#39417)
* Update DamageableSystem to modern standards * DamageContainerId -> DamageContainerID with lint flag * Replace strings with protoids * Make CVar subscription declarations all consistently whitespaced * ChangeDamage -> TryChangeDamage, cope with C# jank * Revert event signature changes * Restore a comment * Re-add two queries * Init the queries * Use appearanceQuery in DamageChanged * Use damageableQuery in TryChangeDamage * Use damageableQuery in SetDamageModifierSetId * Final cleanup, fix sandboxing * Rectify ExplosionSystem:::ProcessEntity's call to TryChangeDamage * Re-organize DamageableSystem * first big fuck you breaking change. * THATS A LOT OF DAMAGE!!! * Fix test fails * test fixes 2 * push it --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
cf66dd7b35
commit
cdbe92d37d
@@ -1,6 +1,8 @@
|
||||
using Content.Shared.Administration.Systems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Execution;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Ghost;
|
||||
@@ -280,7 +282,7 @@ public sealed class SuicideCommandTests
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
// Heal all damage first (possible low pressure damage taken)
|
||||
damageableSystem.SetAllDamage(player, damageableComp, 0);
|
||||
damageableSystem.ClearAllDamage((player, damageableComp));
|
||||
consoleHost.GetSessionShell(playerMan.Sessions.First()).ExecuteCommand("suicide");
|
||||
var lethalDamageThreshold = mobThresholdsComp.Thresholds.Keys.Last();
|
||||
|
||||
@@ -355,7 +357,7 @@ public sealed class SuicideCommandTests
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
// Heal all damage first (possible low pressure damage taken)
|
||||
damageableSystem.SetAllDamage(player, damageableComp, 0);
|
||||
damageableSystem.ClearAllDamage((player, damageableComp));
|
||||
consoleHost.GetSessionShell(playerMan.Sessions.First()).ExecuteCommand("suicide");
|
||||
var lethalDamageThreshold = mobThresholdsComp.Thresholds.Keys.Last();
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -21,7 +23,7 @@ public sealed class WindowRepair : InteractionTest
|
||||
var damageType = Server.ProtoMan.Index(BluntDamageType);
|
||||
var damage = new DamageSpecifier(damageType, FixedPoint2.New(10));
|
||||
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));
|
||||
await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
|
||||
await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target).Value, damage, ignoreResistances: true));
|
||||
await RunTicks(5);
|
||||
Assert.That(comp.Damage.GetTotal(), Is.GreaterThan(FixedPoint2.Zero));
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
@@ -232,10 +234,14 @@ namespace Content.IntegrationTests.Tests.Damageable
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
});
|
||||
|
||||
// Test SetAll function
|
||||
sDamageableSystem.SetAllDamage(sDamageableEntity, sDamageableComponent, 10);
|
||||
// Test SetAll and ClearAll function
|
||||
sDamageableSystem.SetAllDamage((sDamageableEntity, sDamageableComponent), 10);
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(10 * sDamageableComponent.Damage.DamageDict.Count)));
|
||||
sDamageableSystem.SetAllDamage(sDamageableEntity, sDamageableComponent, 0);
|
||||
sDamageableSystem.SetAllDamage((sDamageableEntity, sDamageableComponent), 0);
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
sDamageableSystem.SetAllDamage((sDamageableEntity, sDamageableComponent), 10);
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(10 * sDamageableComponent.Damage.DamageDict.Count)));
|
||||
sDamageableSystem.ClearAllDamage((sDamageableEntity, sDamageableComponent));
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
|
||||
// Test 'wasted' healing
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -130,7 +132,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
// Heal both classes of damage to 0
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
||||
|
||||
// No new thresholds reached, healing should not trigger it
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
@@ -174,7 +176,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
threshold.TriggersOnce = true;
|
||||
|
||||
// Heal brute and burn back to 0
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
||||
|
||||
// No new thresholds reached from healing
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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 Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Server.Destructible.Thresholds.Behaviors;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Destructible.Thresholds;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -3,7 +3,9 @@ using Content.Server.Destructible;
|
||||
using Content.Server.Destructible.Thresholds;
|
||||
using Content.Server.Destructible.Thresholds.Behaviors;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Content.Shared.Destructible;
|
||||
@@ -124,7 +126,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
|
||||
|
||||
// Set damage to 0
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
||||
|
||||
// Damage for 100, up to 100
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 10, true);
|
||||
@@ -185,7 +187,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
// Heal all damage
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
||||
|
||||
// Damage up to 50
|
||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage * 5, true);
|
||||
@@ -247,7 +249,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
// Heal the entity completely
|
||||
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
|
||||
sDamageableSystem.ClearAllDamage((sDestructibleEntity, sDamageableComponent));
|
||||
|
||||
// Check that the entity has 0 damage
|
||||
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
|
||||
@@ -10,7 +10,7 @@ using Content.Server.Roles;
|
||||
using Content.Server.RoundEnd;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Hands.Components;
|
||||
|
||||
@@ -4,7 +4,9 @@ using Content.Server.Ghost.Roles;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Mind.Components;
|
||||
@@ -147,7 +149,7 @@ public sealed partial class MindTests
|
||||
var damageable = entMan.GetComponent<DamageableComponent>(entity);
|
||||
var prototype = protoMan.Index(BluntDamageType);
|
||||
|
||||
damageableSystem.SetDamage(entity, damageable, new DamageSpecifier(prototype, FixedPoint2.New(401)));
|
||||
damageableSystem.SetDamage((entity, damageable), new DamageSpecifier(prototype, FixedPoint2.New(401)));
|
||||
Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mindId));
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.IntegrationTests.Tests.Movement;
|
||||
using Content.Server.NPC.HTN;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Item.ItemToggle;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Mobs;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ using System.Linq;
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Server.VendingMachines;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.VendingMachines;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -200,7 +202,7 @@ public sealed class VendingInteractionTest : InteractionTest
|
||||
// Damage the vending machine to the point that it breaks
|
||||
var damageType = ProtoMan.Index(TestDamageType);
|
||||
var damage = new DamageSpecifier(damageType, FixedPoint2.New(100));
|
||||
await Server.WaitPost(() => damageableSys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
|
||||
await Server.WaitPost(() => damageableSys.TryChangeDamage(SEntMan.GetEntity(Target).Value, damage, ignoreResistances: true));
|
||||
await RunTicks(5);
|
||||
Assert.That(damageableComp.Damage.GetTotal(), Is.GreaterThan(FixedPoint2.Zero), $"{VendingMachineProtoId} did not take damage.");
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.Wires;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Prototypes;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.VendingMachines;
|
||||
@@ -296,14 +297,12 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
restock = entityManager.SpawnEntity("TestRestockExplode", coordinates);
|
||||
var damageSpec = new DamageSpecifier(prototypeManager.Index(TestDamageType), 100);
|
||||
var damageResult = damageableSystem.TryChangeDamage(restock, damageSpec);
|
||||
var damageResult = damageableSystem.ChangeDamage(restock, damageSpec);
|
||||
|
||||
#pragma warning disable NUnit2045
|
||||
Assert.That(damageResult, Is.Not.Null,
|
||||
"Received null damageResult when attempting to damage restock box.");
|
||||
Assert.That(!damageResult.Empty, "Received empty damageResult when attempting to damage restock box.");
|
||||
|
||||
Assert.That((int) damageResult!.GetTotal(), Is.GreaterThan(0),
|
||||
"Box damage result was not greater than 0.");
|
||||
Assert.That((int) damageResult.GetTotal(), Is.GreaterThan(0), "Box damage result was not greater than 0.");
|
||||
#pragma warning restore NUnit2045
|
||||
});
|
||||
await server.WaitRunTicks(15);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Wieldable.Components;
|
||||
|
||||
Reference in New Issue
Block a user