Validate ProtoIds in tests (#38745)
* Convert string literals to protoids in Content.Tests * Convert string literals to protoids or consts in Content.IntegrationTests * Fix linter failures Tricksy static using misled me
This commit is contained in:
@@ -7,10 +7,12 @@ namespace Content.IntegrationTests.Tests.Atmos
|
|||||||
[TestOf(typeof(AtmosAlarmThreshold))]
|
[TestOf(typeof(AtmosAlarmThreshold))]
|
||||||
public sealed class AlarmThresholdTest
|
public sealed class AlarmThresholdTest
|
||||||
{
|
{
|
||||||
|
private const string AlarmThresholdTestDummyId = "AlarmThresholdTestDummy";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string Prototypes = @"
|
private const string Prototypes = $@"
|
||||||
- type: alarmThreshold
|
- type: alarmThreshold
|
||||||
id: AlarmThresholdTestDummy
|
id: {AlarmThresholdTestDummyId}
|
||||||
upperBound: !type:AlarmThresholdSetting
|
upperBound: !type:AlarmThresholdSetting
|
||||||
threshold: 5
|
threshold: 5
|
||||||
lowerBound: !type:AlarmThresholdSetting
|
lowerBound: !type:AlarmThresholdSetting
|
||||||
@@ -30,7 +32,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
|||||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||||
AtmosAlarmThreshold threshold = default!;
|
AtmosAlarmThreshold threshold = default!;
|
||||||
|
|
||||||
var proto = prototypeManager.Index<AtmosAlarmThresholdPrototype>("AlarmThresholdTestDummy");
|
var proto = prototypeManager.Index<AtmosAlarmThresholdPrototype>(AlarmThresholdTestDummyId);
|
||||||
threshold = new(proto);
|
threshold = new(proto);
|
||||||
|
|
||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace Content.IntegrationTests.Tests.Commands
|
|||||||
[TestOf(typeof(RejuvenateSystem))]
|
[TestOf(typeof(RejuvenateSystem))]
|
||||||
public sealed class RejuvenateTest
|
public sealed class RejuvenateTest
|
||||||
{
|
{
|
||||||
|
private static readonly ProtoId<DamageGroupPrototype> TestDamageGroup = "Toxin";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string Prototypes = @"
|
private const string Prototypes = @"
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -62,7 +64,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Kill the entity
|
// Kill the entity
|
||||||
DamageSpecifier damage = new(prototypeManager.Index<DamageGroupPrototype>("Toxin"), FixedPoint2.New(10000000));
|
DamageSpecifier damage = new(prototypeManager.Index(TestDamageGroup), FixedPoint2.New(10000000));
|
||||||
|
|
||||||
damSystem.TryChangeDamage(human, damage, true);
|
damSystem.TryChangeDamage(human, damage, true);
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public sealed class SuicideCommandTests
|
|||||||
components:
|
components:
|
||||||
- type: MaterialReclaimer";
|
- type: MaterialReclaimer";
|
||||||
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
|
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> DamageType = "Slash";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Run the suicide command in the console
|
/// Run the suicide command in the console
|
||||||
/// Should successfully kill the player and ghost them
|
/// Should successfully kill the player and ghost them
|
||||||
@@ -144,7 +146,7 @@ public sealed class SuicideCommandTests
|
|||||||
mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(player);
|
mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(player);
|
||||||
damageableComp = entManager.GetComponent<DamageableComponent>(player);
|
damageableComp = entManager.GetComponent<DamageableComponent>(player);
|
||||||
|
|
||||||
if (protoMan.TryIndex<DamageTypePrototype>("Slash", out var slashProto))
|
if (protoMan.TryIndex(DamageType, out var slashProto))
|
||||||
damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
|
damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace Content.IntegrationTests.Tests.Construction.Interaction;
|
|||||||
|
|
||||||
public sealed class WindowRepair : InteractionTest
|
public sealed class WindowRepair : InteractionTest
|
||||||
{
|
{
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> BluntDamageType = "Blunt";
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task RepairReinforcedWindow()
|
public async Task RepairReinforcedWindow()
|
||||||
{
|
{
|
||||||
@@ -16,7 +18,7 @@ public sealed class WindowRepair : InteractionTest
|
|||||||
// Damage the entity.
|
// Damage the entity.
|
||||||
var sys = SEntMan.System<DamageableSystem>();
|
var sys = SEntMan.System<DamageableSystem>();
|
||||||
var comp = Comp<DamageableComponent>();
|
var comp = Comp<DamageableComponent>();
|
||||||
var damageType = Server.ResolveDependency<IPrototypeManager>().Index<DamageTypePrototype>("Blunt");
|
var damageType = Server.ProtoMan.Index(BluntDamageType);
|
||||||
var damage = new DamageSpecifier(damageType, FixedPoint2.New(10));
|
var damage = new DamageSpecifier(damageType, FixedPoint2.New(10));
|
||||||
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));
|
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), damage, ignoreResistances: true));
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage.Prototypes;
|
using Content.Shared.Damage.Prototypes;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
@@ -14,66 +12,79 @@ namespace Content.IntegrationTests.Tests.Damageable
|
|||||||
[TestOf(typeof(DamageableSystem))]
|
[TestOf(typeof(DamageableSystem))]
|
||||||
public sealed class DamageableTest
|
public sealed class DamageableTest
|
||||||
{
|
{
|
||||||
|
private const string TestDamageableEntityId = "TestDamageableEntityId";
|
||||||
|
private const string TestGroup1 = "TestGroup1";
|
||||||
|
private const string TestGroup2 = "TestGroup2";
|
||||||
|
private const string TestGroup3 = "TestGroup3";
|
||||||
|
private const string TestDamage1 = "TestDamage1";
|
||||||
|
private const string TestDamage2a = "TestDamage2a";
|
||||||
|
private const string TestDamage2b = "TestDamage2b";
|
||||||
|
|
||||||
|
private const string TestDamage3a = "TestDamage3a";
|
||||||
|
|
||||||
|
private const string TestDamage3b = "TestDamage3b";
|
||||||
|
private const string TestDamage3c = "TestDamage3c";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string Prototypes = @"
|
private const string Prototypes = $@"
|
||||||
# Define some damage groups
|
# Define some damage groups
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestDamage1
|
id: {TestDamage1}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestDamage2a
|
id: {TestDamage2a}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestDamage2b
|
id: {TestDamage2b}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestDamage3a
|
id: {TestDamage3a}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestDamage3b
|
id: {TestDamage3b}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestDamage3c
|
id: {TestDamage3c}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
# Define damage Groups with 1,2,3 damage types
|
# Define damage Groups with 1,2,3 damage types
|
||||||
- type: damageGroup
|
- type: damageGroup
|
||||||
id: TestGroup1
|
id: {TestGroup1}
|
||||||
name: damage-group-brute
|
name: damage-group-brute
|
||||||
damageTypes:
|
damageTypes:
|
||||||
- TestDamage1
|
- {TestDamage1}
|
||||||
|
|
||||||
- type: damageGroup
|
- type: damageGroup
|
||||||
id: TestGroup2
|
id: {TestGroup2}
|
||||||
name: damage-group-brute
|
name: damage-group-brute
|
||||||
damageTypes:
|
damageTypes:
|
||||||
- TestDamage2a
|
- {TestDamage2a}
|
||||||
- TestDamage2b
|
- {TestDamage2b}
|
||||||
|
|
||||||
- type: damageGroup
|
- type: damageGroup
|
||||||
id: TestGroup3
|
id: {TestGroup3}
|
||||||
name: damage-group-brute
|
name: damage-group-brute
|
||||||
damageTypes:
|
damageTypes:
|
||||||
- TestDamage3a
|
- {TestDamage3a}
|
||||||
- TestDamage3b
|
- {TestDamage3b}
|
||||||
- TestDamage3c
|
- {TestDamage3c}
|
||||||
|
|
||||||
# This container should not support TestDamage1 or TestDamage2b
|
# This container should not support TestDamage1 or TestDamage2b
|
||||||
- type: damageContainer
|
- type: damageContainer
|
||||||
id: testDamageContainer
|
id: testDamageContainer
|
||||||
supportedGroups:
|
supportedGroups:
|
||||||
- TestGroup3
|
- {TestGroup3}
|
||||||
supportedTypes:
|
supportedTypes:
|
||||||
- TestDamage2a
|
- {TestDamage2a}
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: TestDamageableEntityId
|
id: {TestDamageableEntityId}
|
||||||
name: TestDamageableEntityId
|
name: {TestDamageableEntityId}
|
||||||
components:
|
components:
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
damageContainer: testDamageContainer
|
damageContainer: testDamageContainer
|
||||||
@@ -113,20 +124,20 @@ namespace Content.IntegrationTests.Tests.Damageable
|
|||||||
{
|
{
|
||||||
var coordinates = map.MapCoords;
|
var coordinates = map.MapCoords;
|
||||||
|
|
||||||
sDamageableEntity = sEntityManager.SpawnEntity("TestDamageableEntityId", coordinates);
|
sDamageableEntity = sEntityManager.SpawnEntity(TestDamageableEntityId, coordinates);
|
||||||
sDamageableComponent = sEntityManager.GetComponent<DamageableComponent>(sDamageableEntity);
|
sDamageableComponent = sEntityManager.GetComponent<DamageableComponent>(sDamageableEntity);
|
||||||
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
|
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
|
||||||
|
|
||||||
group1 = sPrototypeManager.Index<DamageGroupPrototype>("TestGroup1");
|
group1 = sPrototypeManager.Index<DamageGroupPrototype>(TestGroup1);
|
||||||
group2 = sPrototypeManager.Index<DamageGroupPrototype>("TestGroup2");
|
group2 = sPrototypeManager.Index<DamageGroupPrototype>(TestGroup2);
|
||||||
group3 = sPrototypeManager.Index<DamageGroupPrototype>("TestGroup3");
|
group3 = sPrototypeManager.Index<DamageGroupPrototype>(TestGroup3);
|
||||||
|
|
||||||
type1 = sPrototypeManager.Index<DamageTypePrototype>("TestDamage1");
|
type1 = sPrototypeManager.Index<DamageTypePrototype>(TestDamage1);
|
||||||
type2a = sPrototypeManager.Index<DamageTypePrototype>("TestDamage2a");
|
type2a = sPrototypeManager.Index<DamageTypePrototype>(TestDamage2a);
|
||||||
type2b = sPrototypeManager.Index<DamageTypePrototype>("TestDamage2b");
|
type2b = sPrototypeManager.Index<DamageTypePrototype>(TestDamage2b);
|
||||||
type3a = sPrototypeManager.Index<DamageTypePrototype>("TestDamage3a");
|
type3a = sPrototypeManager.Index<DamageTypePrototype>(TestDamage3a);
|
||||||
type3b = sPrototypeManager.Index<DamageTypePrototype>("TestDamage3b");
|
type3b = sPrototypeManager.Index<DamageTypePrototype>(TestDamage3b);
|
||||||
type3c = sPrototypeManager.Index<DamageTypePrototype>("TestDamage3c");
|
type3c = sPrototypeManager.Index<DamageTypePrototype>(TestDamage3c);
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.WaitRunTicks(5);
|
await server.WaitRunTicks(5);
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
|
|
||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
|
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>(TestBruteDamageGroupId);
|
||||||
var burnDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBurn");
|
var burnDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>(TestBurnDamageGroupId);
|
||||||
|
|
||||||
DamageSpecifier bruteDamage = new(bruteDamageGroup, FixedPoint2.New(5));
|
DamageSpecifier bruteDamage = new(bruteDamageGroup, FixedPoint2.New(5));
|
||||||
DamageSpecifier burnDamage = new(burnDamageGroup, FixedPoint2.New(5));
|
DamageSpecifier burnDamage = new(burnDamageGroup, FixedPoint2.New(5));
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
|
|
||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
var bluntDamageType = protoManager.Index<DamageTypePrototype>("TestBlunt");
|
var bluntDamageType = protoManager.Index<DamageTypePrototype>(TestBluntDamageTypeId);
|
||||||
var slashDamageType = protoManager.Index<DamageTypePrototype>("TestSlash");
|
var slashDamageType = protoManager.Index<DamageTypePrototype>(TestSlashDamageTypeId);
|
||||||
|
|
||||||
var bluntDamage = new DamageSpecifier(bluntDamageType, 5);
|
var bluntDamage = new DamageSpecifier(bluntDamageType, 5);
|
||||||
var slashDamage = new DamageSpecifier(slashDamageType, 5);
|
var slashDamage = new DamageSpecifier(slashDamageType, 5);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
var coordinates = sEntityManager.GetComponent<TransformComponent>(sDestructibleEntity).Coordinates;
|
var coordinates = sEntityManager.GetComponent<TransformComponent>(sDestructibleEntity).Coordinates;
|
||||||
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
|
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>(TestBruteDamageGroupId);
|
||||||
DamageSpecifier bruteDamage = new(bruteDamageGroup, 50);
|
DamageSpecifier bruteDamage = new(bruteDamageGroup, 50);
|
||||||
|
|
||||||
#pragma warning disable NUnit2045 // Interdependent assertions.
|
#pragma warning disable NUnit2045 // Interdependent assertions.
|
||||||
|
|||||||
@@ -7,48 +7,56 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
public const string DestructibleDestructionEntityId = "DestructibleTestsDestructibleDestructionEntity";
|
public const string DestructibleDestructionEntityId = "DestructibleTestsDestructibleDestructionEntity";
|
||||||
public const string DestructibleDamageTypeEntityId = "DestructibleTestsDestructibleDamageTypeEntity";
|
public const string DestructibleDamageTypeEntityId = "DestructibleTestsDestructibleDamageTypeEntity";
|
||||||
public const string DestructibleDamageGroupEntityId = "DestructibleTestsDestructibleDamageGroupEntity";
|
public const string DestructibleDamageGroupEntityId = "DestructibleTestsDestructibleDamageGroupEntity";
|
||||||
|
public const string TestBruteDamageGroupId = "TestBrute";
|
||||||
|
public const string TestBurnDamageGroupId = "TestBurn";
|
||||||
|
public const string TestBluntDamageTypeId = "TestBlunt";
|
||||||
|
public const string TestSlashDamageTypeId = "TestSlash";
|
||||||
|
public const string TestPiercingDamageTypeId = "TestPiercing";
|
||||||
|
public const string TestHeatDamageTypeId = "TestHeat";
|
||||||
|
public const string TestShockDamageTypeId = "TestShock";
|
||||||
|
public const string TestColdDamageTypeId = "TestCold";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
public const string DamagePrototypes = $@"
|
public const string DamagePrototypes = $@"
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestBlunt
|
id: {TestBluntDamageTypeId}
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestSlash
|
id: {TestSlashDamageTypeId}
|
||||||
name: damage-type-slash
|
name: damage-type-slash
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestPiercing
|
id: {TestPiercingDamageTypeId}
|
||||||
name: damage-type-piercing
|
name: damage-type-piercing
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestHeat
|
id: {TestHeatDamageTypeId}
|
||||||
name: damage-type-heat
|
name: damage-type-heat
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestShock
|
id: {TestShockDamageTypeId}
|
||||||
name: damage-type-shock
|
name: damage-type-shock
|
||||||
|
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: TestCold
|
id: {TestColdDamageTypeId}
|
||||||
name: damage-type-cold
|
name: damage-type-cold
|
||||||
|
|
||||||
- type: damageGroup
|
- type: damageGroup
|
||||||
id: TestBrute
|
id: {TestBruteDamageGroupId}
|
||||||
name: damage-group-brute
|
name: damage-group-brute
|
||||||
damageTypes:
|
damageTypes:
|
||||||
- TestBlunt
|
- {TestBluntDamageTypeId}
|
||||||
- TestSlash
|
- {TestSlashDamageTypeId}
|
||||||
- TestPiercing
|
- {TestPiercingDamageTypeId}
|
||||||
|
|
||||||
- type: damageGroup
|
- type: damageGroup
|
||||||
id: TestBurn
|
id: {TestBurnDamageGroupId}
|
||||||
name: damage-group-burn
|
name: damage-group-burn
|
||||||
damageTypes:
|
damageTypes:
|
||||||
- TestHeat
|
- {TestHeatDamageTypeId}
|
||||||
- TestShock
|
- {TestShockDamageTypeId}
|
||||||
- TestCold
|
- {TestColdDamageTypeId}
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: {SpawnedEntityId}
|
id: {SpawnedEntityId}
|
||||||
@@ -114,10 +122,10 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
!type:AndTrigger
|
!type:AndTrigger
|
||||||
triggers:
|
triggers:
|
||||||
- !type:DamageTypeTrigger
|
- !type:DamageTypeTrigger
|
||||||
damageType: TestBlunt
|
damageType: {TestBluntDamageTypeId}
|
||||||
damage: 10
|
damage: 10
|
||||||
- !type:DamageTypeTrigger
|
- !type:DamageTypeTrigger
|
||||||
damageType: TestSlash
|
damageType: {TestSlashDamageTypeId}
|
||||||
damage: 10
|
damage: 10
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -131,10 +139,10 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
!type:AndTrigger
|
!type:AndTrigger
|
||||||
triggers:
|
triggers:
|
||||||
- !type:DamageGroupTrigger
|
- !type:DamageGroupTrigger
|
||||||
damageGroup: TestBrute
|
damageGroup: {TestBruteDamageGroupId}
|
||||||
damage: 10
|
damage: 10
|
||||||
- !type:DamageGroupTrigger
|
- !type:DamageGroupTrigger
|
||||||
damageGroup: TestBurn
|
damageGroup: {TestBurnDamageGroupId}
|
||||||
damage: 10";
|
damage: 10";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
|||||||
|
|
||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
var bluntDamage = new DamageSpecifier(sPrototypeManager.Index<DamageTypePrototype>("TestBlunt"), 10);
|
var bluntDamage = new DamageSpecifier(sPrototypeManager.Index<DamageTypePrototype>(TestBluntDamageTypeId), 10);
|
||||||
|
|
||||||
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage, true);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace Content.IntegrationTests.Tests.Minds;
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public sealed partial class MindTests
|
public sealed partial class MindTests
|
||||||
{
|
{
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> BluntDamageType = "Blunt";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string Prototypes = @"
|
private const string Prototypes = @"
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -144,7 +146,7 @@ public sealed partial class MindTests
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
var damageable = entMan.GetComponent<DamageableComponent>(entity);
|
var damageable = entMan.GetComponent<DamageableComponent>(entity);
|
||||||
if (!protoMan.TryIndex<DamageTypePrototype>("Blunt", out var prototype))
|
if (!protoMan.TryIndex(BluntDamageType, out var prototype))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ namespace Content.IntegrationTests.Tests
|
|||||||
"Exo",
|
"Exo",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static readonly ProtoId<EntityCategoryPrototype> DoNotMapCategory = "DoNotMap";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asserts that specific files have been saved as grids and not maps.
|
/// Asserts that specific files have been saved as grids and not maps.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -254,7 +256,7 @@ namespace Content.IntegrationTests.Tests
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var yamlEntities = node["entities"];
|
var yamlEntities = node["entities"];
|
||||||
if (!protoManager.TryIndex<EntityCategoryPrototype>("DoNotMap", out var dnmCategory))
|
if (!protoManager.TryIndex(DoNotMapCategory, out var dnmCategory))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ namespace Content.IntegrationTests.Tests.Station;
|
|||||||
[TestOf(typeof(StationJobsSystem))]
|
[TestOf(typeof(StationJobsSystem))]
|
||||||
public sealed class StationJobsTest
|
public sealed class StationJobsTest
|
||||||
{
|
{
|
||||||
|
private const string StationMapId = "FooStation";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string Prototypes = @"
|
private const string Prototypes = $@"
|
||||||
- type: playTimeTracker
|
- type: playTimeTracker
|
||||||
id: PlayTimeDummyAssistant
|
id: PlayTimeDummyAssistant
|
||||||
|
|
||||||
@@ -35,13 +37,13 @@ public sealed class StationJobsTest
|
|||||||
id: PlayTimeDummyChaplain
|
id: PlayTimeDummyChaplain
|
||||||
|
|
||||||
- type: gameMap
|
- type: gameMap
|
||||||
id: FooStation
|
id: {StationMapId}
|
||||||
minPlayers: 0
|
minPlayers: 0
|
||||||
mapName: FooStation
|
mapName: {StationMapId}
|
||||||
mapPath: /Maps/Test/empty.yml
|
mapPath: /Maps/Test/empty.yml
|
||||||
stations:
|
stations:
|
||||||
Station:
|
Station:
|
||||||
mapNameTemplate: FooStation
|
mapNameTemplate: {StationMapId}
|
||||||
stationProto: StandardNanotrasenStation
|
stationProto: StandardNanotrasenStation
|
||||||
components:
|
components:
|
||||||
- type: StationJobs
|
- type: StationJobs
|
||||||
@@ -87,7 +89,7 @@ public sealed class StationJobsTest
|
|||||||
var server = pair.Server;
|
var server = pair.Server;
|
||||||
|
|
||||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||||
var fooStationProto = prototypeManager.Index<GameMapPrototype>("FooStation");
|
var fooStationProto = prototypeManager.Index<GameMapPrototype>(StationMapId);
|
||||||
var entSysMan = server.ResolveDependency<IEntityManager>().EntitySysManager;
|
var entSysMan = server.ResolveDependency<IEntityManager>().EntitySysManager;
|
||||||
var stationJobs = entSysMan.GetEntitySystem<StationJobsSystem>();
|
var stationJobs = entSysMan.GetEntitySystem<StationJobsSystem>();
|
||||||
var stationSystem = entSysMan.GetEntitySystem<StationSystem>();
|
var stationSystem = entSysMan.GetEntitySystem<StationSystem>();
|
||||||
@@ -161,7 +163,7 @@ public sealed class StationJobsTest
|
|||||||
var server = pair.Server;
|
var server = pair.Server;
|
||||||
|
|
||||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||||
var fooStationProto = prototypeManager.Index<GameMapPrototype>("FooStation");
|
var fooStationProto = prototypeManager.Index<GameMapPrototype>(StationMapId);
|
||||||
var entSysMan = server.ResolveDependency<IEntityManager>().EntitySysManager;
|
var entSysMan = server.ResolveDependency<IEntityManager>().EntitySysManager;
|
||||||
var stationJobs = entSysMan.GetEntitySystem<StationJobsSystem>();
|
var stationJobs = entSysMan.GetEntitySystem<StationJobsSystem>();
|
||||||
var stationSystem = entSysMan.GetEntitySystem<StationSystem>();
|
var stationSystem = entSysMan.GetEntitySystem<StationSystem>();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Shared.Damage;
|
|||||||
using Content.Shared.Damage.Prototypes;
|
using Content.Shared.Damage.Prototypes;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.VendingMachines;
|
using Content.Shared.VendingMachines;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests.Vending;
|
namespace Content.IntegrationTests.Tests.Vending;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ public sealed class VendingInteractionTest : InteractionTest
|
|||||||
private const string RestockBoxProtoId = "InteractionTestRestockBox";
|
private const string RestockBoxProtoId = "InteractionTestRestockBox";
|
||||||
|
|
||||||
private const string RestockBoxOtherProtoId = "InteractionTestRestockBoxOther";
|
private const string RestockBoxOtherProtoId = "InteractionTestRestockBoxOther";
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> TestDamageType = "Blunt";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string TestPrototypes = $@"
|
private const string TestPrototypes = $@"
|
||||||
@@ -196,7 +198,7 @@ public sealed class VendingInteractionTest : InteractionTest
|
|||||||
Assert.That(damageableComp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero), $"{VendingMachineProtoId} started with unexpected damage.");
|
Assert.That(damageableComp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero), $"{VendingMachineProtoId} started with unexpected damage.");
|
||||||
|
|
||||||
// Damage the vending machine to the point that it breaks
|
// Damage the vending machine to the point that it breaks
|
||||||
var damageType = ProtoMan.Index<DamageTypePrototype>("Blunt");
|
var damageType = ProtoMan.Index(TestDamageType);
|
||||||
var damage = new DamageSpecifier(damageType, FixedPoint2.New(100));
|
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), damage, ignoreResistances: true));
|
||||||
await RunTicks(5);
|
await RunTicks(5);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace Content.IntegrationTests.Tests
|
|||||||
[TestOf(typeof(VendingMachineSystem))]
|
[TestOf(typeof(VendingMachineSystem))]
|
||||||
public sealed class VendingMachineRestockTest : EntitySystem
|
public sealed class VendingMachineRestockTest : EntitySystem
|
||||||
{
|
{
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> TestDamageType = "Blunt";
|
||||||
|
|
||||||
[TestPrototypes]
|
[TestPrototypes]
|
||||||
private const string Prototypes = @"
|
private const string Prototypes = @"
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -293,7 +295,7 @@ namespace Content.IntegrationTests.Tests
|
|||||||
"Did not start with zero ramen.");
|
"Did not start with zero ramen.");
|
||||||
|
|
||||||
restock = entityManager.SpawnEntity("TestRestockExplode", coordinates);
|
restock = entityManager.SpawnEntity("TestRestockExplode", coordinates);
|
||||||
var damageSpec = new DamageSpecifier(prototypeManager.Index<DamageTypePrototype>("Blunt"), 100);
|
var damageSpec = new DamageSpecifier(prototypeManager.Index(TestDamageType), 100);
|
||||||
var damageResult = damageableSystem.TryChangeDamage(restock, damageSpec);
|
var damageResult = damageableSystem.TryChangeDamage(restock, damageSpec);
|
||||||
|
|
||||||
#pragma warning disable NUnit2045
|
#pragma warning disable NUnit2045
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ namespace Content.Tests.Shared
|
|||||||
[TestOf(typeof(DamageGroupPrototype))]
|
[TestOf(typeof(DamageGroupPrototype))]
|
||||||
public sealed class DamageTest : ContentUnitTest
|
public sealed class DamageTest : ContentUnitTest
|
||||||
{
|
{
|
||||||
|
private static readonly ProtoId<DamageGroupPrototype> BruteDamageGroup = "Brute";
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> RadiationDamageType = "Radiation";
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> SlashDamageType = "Slash";
|
||||||
|
private static readonly ProtoId<DamageTypePrototype> PiercingDamageType = "Piercing";
|
||||||
|
|
||||||
private IPrototypeManager _prototypeManager;
|
private IPrototypeManager _prototypeManager;
|
||||||
|
|
||||||
private DamageSpecifier _damageSpec;
|
private DamageSpecifier _damageSpec;
|
||||||
@@ -29,9 +34,9 @@ namespace Content.Tests.Shared
|
|||||||
_prototypeManager.ResolveResults();
|
_prototypeManager.ResolveResults();
|
||||||
|
|
||||||
// Create a damage data set
|
// Create a damage data set
|
||||||
_damageSpec = new(_prototypeManager.Index<DamageGroupPrototype>("Brute"), 6);
|
_damageSpec = new(_prototypeManager.Index(BruteDamageGroup), 6);
|
||||||
_damageSpec += new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Radiation"), 3);
|
_damageSpec += new DamageSpecifier(_prototypeManager.Index(RadiationDamageType), 3);
|
||||||
_damageSpec += new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Slash"), -1); // already exists in brute
|
_damageSpec += new DamageSpecifier(_prototypeManager.Index(SlashDamageType), -1); // already exists in brute
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check that DamageSpecifier will split groups and can do arithmetic operations
|
//Check that DamageSpecifier will split groups and can do arithmetic operations
|
||||||
@@ -100,7 +105,7 @@ namespace Content.Tests.Shared
|
|||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(3)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(3)));
|
||||||
|
|
||||||
// Lets also test the constructor with damage types and damage groups works properly.
|
// Lets also test the constructor with damage types and damage groups works properly.
|
||||||
damageSpec = new(_prototypeManager.Index<DamageGroupPrototype>("Brute"), 4);
|
damageSpec = new(_prototypeManager.Index(BruteDamageGroup), 4);
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Blunt", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Blunt", out damage));
|
||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(1.33)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(1.33)));
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Slash", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Slash", out damage));
|
||||||
@@ -108,7 +113,7 @@ namespace Content.Tests.Shared
|
|||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(1.34))); // doesn't divide evenly, so the 0.01 goes to the last one
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(1.34))); // doesn't divide evenly, so the 0.01 goes to the last one
|
||||||
|
|
||||||
damageSpec = new(_prototypeManager.Index<DamageTypePrototype>("Piercing"), 4);
|
damageSpec = new(_prototypeManager.Index(PiercingDamageType), 4);
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4)));
|
||||||
}
|
}
|
||||||
@@ -121,7 +126,7 @@ namespace Content.Tests.Shared
|
|||||||
DamageSpecifier damageSpec = 10 * new DamageSpecifier(_damageSpec);
|
DamageSpecifier damageSpec = 10 * new DamageSpecifier(_damageSpec);
|
||||||
|
|
||||||
// Create a modifier set
|
// Create a modifier set
|
||||||
var modifierSet = _prototypeManager.Index<DamageModifierSetPrototype>("ModifierTestSet");
|
var modifierSet = _prototypeManager.Index<DamageModifierSetPrototype>(ModifierTestSetId);
|
||||||
|
|
||||||
//damage is initially 20 / 20 / 10 / 30
|
//damage is initially 20 / 20 / 10 / 30
|
||||||
//Each time we subtract -5 / 0 / 8 / 0.5
|
//Each time we subtract -5 / 0 / 8 / 0.5
|
||||||
@@ -142,8 +147,10 @@ namespace Content.Tests.Shared
|
|||||||
Assert.That(damageSpec.DamageDict["Radiation"], Is.EqualTo(FixedPoint2.New(65.62)));
|
Assert.That(damageSpec.DamageDict["Radiation"], Is.EqualTo(FixedPoint2.New(65.62)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const string ModifierTestSetId = "ModifierTestSet";
|
||||||
|
|
||||||
// Default damage Yaml
|
// Default damage Yaml
|
||||||
private string _damagePrototypes = @"
|
private readonly string _damagePrototypes = $@"
|
||||||
- type: damageType
|
- type: damageType
|
||||||
id: Blunt
|
id: Blunt
|
||||||
name: damage-type-blunt
|
name: damage-type-blunt
|
||||||
@@ -268,7 +275,7 @@ namespace Content.Tests.Shared
|
|||||||
Blunt: 5
|
Blunt: 5
|
||||||
|
|
||||||
- type: damageModifierSet
|
- type: damageModifierSet
|
||||||
id: ModifierTestSet
|
id: {ModifierTestSetId}
|
||||||
coefficients:
|
coefficients:
|
||||||
Piercing: -2
|
Piercing: -2
|
||||||
Slash: 3
|
Slash: 3
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace Content.Tests.Shared;
|
|||||||
[TestOf(typeof(LocalizedDatasetPrototype))]
|
[TestOf(typeof(LocalizedDatasetPrototype))]
|
||||||
public sealed class LocalizedDatasetPrototypeTest : ContentUnitTest
|
public sealed class LocalizedDatasetPrototypeTest : ContentUnitTest
|
||||||
{
|
{
|
||||||
|
private const string TestDatasetId = "Test";
|
||||||
|
|
||||||
private IPrototypeManager _prototypeManager;
|
private IPrototypeManager _prototypeManager;
|
||||||
|
|
||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
@@ -24,9 +26,9 @@ public sealed class LocalizedDatasetPrototypeTest : ContentUnitTest
|
|||||||
_prototypeManager.ResolveResults();
|
_prototypeManager.ResolveResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string TestPrototypes = @"
|
private const string TestPrototypes = $@"
|
||||||
- type: localizedDataset
|
- type: localizedDataset
|
||||||
id: Test
|
id: {TestDatasetId}
|
||||||
values:
|
values:
|
||||||
prefix: test-dataset-
|
prefix: test-dataset-
|
||||||
count: 4
|
count: 4
|
||||||
@@ -35,7 +37,7 @@ public sealed class LocalizedDatasetPrototypeTest : ContentUnitTest
|
|||||||
[Test]
|
[Test]
|
||||||
public void LocalizedDatasetTest()
|
public void LocalizedDatasetTest()
|
||||||
{
|
{
|
||||||
var testPrototype = _prototypeManager.Index<LocalizedDatasetPrototype>("Test");
|
var testPrototype = _prototypeManager.Index<LocalizedDatasetPrototype>(TestDatasetId);
|
||||||
var values = new ValueList<string>();
|
var values = new ValueList<string>();
|
||||||
foreach (var value in testPrototype.Values)
|
foreach (var value in testPrototype.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user