[TestOf(typeof(AtmosAlarmThreshold))]
public sealed class AlarmThresholdTest
{
+ private const string AlarmThresholdTestDummyId = "AlarmThresholdTestDummy";
+
[TestPrototypes]
- private const string Prototypes = @"
+ private const string Prototypes = $@"
- type: alarmThreshold
- id: AlarmThresholdTestDummy
+ id: {AlarmThresholdTestDummyId}
upperBound: !type:AlarmThresholdSetting
threshold: 5
lowerBound: !type:AlarmThresholdSetting
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
AtmosAlarmThreshold threshold = default!;
- var proto = prototypeManager.Index<AtmosAlarmThresholdPrototype>("AlarmThresholdTestDummy");
+ var proto = prototypeManager.Index<AtmosAlarmThresholdPrototype>(AlarmThresholdTestDummyId);
threshold = new(proto);
await server.WaitAssertion(() =>
[TestOf(typeof(RejuvenateSystem))]
public sealed class RejuvenateTest
{
+ private static readonly ProtoId<DamageGroupPrototype> TestDamageGroup = "Toxin";
+
[TestPrototypes]
private const string Prototypes = @"
- type: 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);
components:
- type: MaterialReclaimer";
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
+ private static readonly ProtoId<DamageTypePrototype> DamageType = "Slash";
+
/// <summary>
/// Run the suicide command in the console
/// Should successfully kill the player and ghost them
mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(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)));
});
public sealed class WindowRepair : InteractionTest
{
+ private static readonly ProtoId<DamageTypePrototype> BluntDamageType = "Blunt";
+
[Test]
public async Task RepairReinforcedWindow()
{
// Damage the entity.
var sys = SEntMan.System<DamageableSystem>();
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));
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));
await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
-using System.Linq;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
[TestOf(typeof(DamageableSystem))]
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]
- private const string Prototypes = @"
+ private const string Prototypes = $@"
# Define some damage groups
- type: damageType
- id: TestDamage1
+ id: {TestDamage1}
name: damage-type-blunt
- type: damageType
- id: TestDamage2a
+ id: {TestDamage2a}
name: damage-type-blunt
- type: damageType
- id: TestDamage2b
+ id: {TestDamage2b}
name: damage-type-blunt
- type: damageType
- id: TestDamage3a
+ id: {TestDamage3a}
name: damage-type-blunt
- type: damageType
- id: TestDamage3b
+ id: {TestDamage3b}
name: damage-type-blunt
- type: damageType
- id: TestDamage3c
+ id: {TestDamage3c}
name: damage-type-blunt
# Define damage Groups with 1,2,3 damage types
- type: damageGroup
- id: TestGroup1
+ id: {TestGroup1}
name: damage-group-brute
damageTypes:
- - TestDamage1
+ - {TestDamage1}
- type: damageGroup
- id: TestGroup2
+ id: {TestGroup2}
name: damage-group-brute
damageTypes:
- - TestDamage2a
- - TestDamage2b
+ - {TestDamage2a}
+ - {TestDamage2b}
- type: damageGroup
- id: TestGroup3
+ id: {TestGroup3}
name: damage-group-brute
damageTypes:
- - TestDamage3a
- - TestDamage3b
- - TestDamage3c
+ - {TestDamage3a}
+ - {TestDamage3b}
+ - {TestDamage3c}
# This container should not support TestDamage1 or TestDamage2b
- type: damageContainer
id: testDamageContainer
supportedGroups:
- - TestGroup3
+ - {TestGroup3}
supportedTypes:
- - TestDamage2a
+ - {TestDamage2a}
- type: entity
- id: TestDamageableEntityId
- name: TestDamageableEntityId
+ id: {TestDamageableEntityId}
+ name: {TestDamageableEntityId}
components:
- type: Damageable
damageContainer: testDamageContainer
{
var coordinates = map.MapCoords;
- sDamageableEntity = sEntityManager.SpawnEntity("TestDamageableEntityId", coordinates);
+ sDamageableEntity = sEntityManager.SpawnEntity(TestDamageableEntityId, coordinates);
sDamageableComponent = sEntityManager.GetComponent<DamageableComponent>(sDamageableEntity);
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
- group1 = sPrototypeManager.Index<DamageGroupPrototype>("TestGroup1");
- group2 = sPrototypeManager.Index<DamageGroupPrototype>("TestGroup2");
- group3 = sPrototypeManager.Index<DamageGroupPrototype>("TestGroup3");
+ group1 = sPrototypeManager.Index<DamageGroupPrototype>(TestGroup1);
+ group2 = sPrototypeManager.Index<DamageGroupPrototype>(TestGroup2);
+ group3 = sPrototypeManager.Index<DamageGroupPrototype>(TestGroup3);
- type1 = sPrototypeManager.Index<DamageTypePrototype>("TestDamage1");
- type2a = sPrototypeManager.Index<DamageTypePrototype>("TestDamage2a");
- type2b = sPrototypeManager.Index<DamageTypePrototype>("TestDamage2b");
- type3a = sPrototypeManager.Index<DamageTypePrototype>("TestDamage3a");
- type3b = sPrototypeManager.Index<DamageTypePrototype>("TestDamage3b");
- type3c = sPrototypeManager.Index<DamageTypePrototype>("TestDamage3c");
+ type1 = sPrototypeManager.Index<DamageTypePrototype>(TestDamage1);
+ type2a = sPrototypeManager.Index<DamageTypePrototype>(TestDamage2a);
+ type2b = sPrototypeManager.Index<DamageTypePrototype>(TestDamage2b);
+ type3a = sPrototypeManager.Index<DamageTypePrototype>(TestDamage3a);
+ type3b = sPrototypeManager.Index<DamageTypePrototype>(TestDamage3b);
+ type3c = sPrototypeManager.Index<DamageTypePrototype>(TestDamage3c);
});
await server.WaitRunTicks(5);
await server.WaitAssertion(() =>
{
- var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
- var burnDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBurn");
+ 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));
await server.WaitAssertion(() =>
{
- var bluntDamageType = protoManager.Index<DamageTypePrototype>("TestBlunt");
- var slashDamageType = protoManager.Index<DamageTypePrototype>("TestSlash");
+ var bluntDamageType = protoManager.Index<DamageTypePrototype>(TestBluntDamageTypeId);
+ var slashDamageType = protoManager.Index<DamageTypePrototype>(TestSlashDamageTypeId);
var bluntDamage = new DamageSpecifier(bluntDamageType, 5);
var slashDamage = new DamageSpecifier(slashDamageType, 5);
await server.WaitAssertion(() =>
{
var coordinates = sEntityManager.GetComponent<TransformComponent>(sDestructibleEntity).Coordinates;
- var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
+ var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>(TestBruteDamageGroupId);
DamageSpecifier bruteDamage = new(bruteDamageGroup, 50);
#pragma warning disable NUnit2045 // Interdependent assertions.
public const string DestructibleDestructionEntityId = "DestructibleTestsDestructibleDestructionEntity";
public const string DestructibleDamageTypeEntityId = "DestructibleTestsDestructibleDamageTypeEntity";
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]
public const string DamagePrototypes = $@"
- type: damageType
- id: TestBlunt
+ id: {TestBluntDamageTypeId}
name: damage-type-blunt
- type: damageType
- id: TestSlash
+ id: {TestSlashDamageTypeId}
name: damage-type-slash
- type: damageType
- id: TestPiercing
+ id: {TestPiercingDamageTypeId}
name: damage-type-piercing
- type: damageType
- id: TestHeat
+ id: {TestHeatDamageTypeId}
name: damage-type-heat
- type: damageType
- id: TestShock
+ id: {TestShockDamageTypeId}
name: damage-type-shock
- type: damageType
- id: TestCold
+ id: {TestColdDamageTypeId}
name: damage-type-cold
- type: damageGroup
- id: TestBrute
+ id: {TestBruteDamageGroupId}
name: damage-group-brute
damageTypes:
- - TestBlunt
- - TestSlash
- - TestPiercing
+ - {TestBluntDamageTypeId}
+ - {TestSlashDamageTypeId}
+ - {TestPiercingDamageTypeId}
- type: damageGroup
- id: TestBurn
+ id: {TestBurnDamageGroupId}
name: damage-group-burn
damageTypes:
- - TestHeat
- - TestShock
- - TestCold
+ - {TestHeatDamageTypeId}
+ - {TestShockDamageTypeId}
+ - {TestColdDamageTypeId}
- type: entity
id: {SpawnedEntityId}
!type:AndTrigger
triggers:
- !type:DamageTypeTrigger
- damageType: TestBlunt
+ damageType: {TestBluntDamageTypeId}
damage: 10
- !type:DamageTypeTrigger
- damageType: TestSlash
+ damageType: {TestSlashDamageTypeId}
damage: 10
- type: entity
!type:AndTrigger
triggers:
- !type:DamageGroupTrigger
- damageGroup: TestBrute
+ damageGroup: {TestBruteDamageGroupId}
damage: 10
- !type:DamageGroupTrigger
- damageGroup: TestBurn
+ damageGroup: {TestBurnDamageGroupId}
damage: 10";
}
}
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);
[TestFixture]
public sealed partial class MindTests
{
+ private static readonly ProtoId<DamageTypePrototype> BluntDamageType = "Blunt";
+
[TestPrototypes]
private const string Prototypes = @"
- type: entity
await server.WaitAssertion(() =>
{
var damageable = entMan.GetComponent<DamageableComponent>(entity);
- if (!protoMan.TryIndex<DamageTypePrototype>("Blunt", out var prototype))
+ if (!protoMan.TryIndex(BluntDamageType, out var prototype))
{
return;
}
"Exo",
};
+ private static readonly ProtoId<EntityCategoryPrototype> DoNotMapCategory = "DoNotMap";
+
/// <summary>
/// Asserts that specific files have been saved as grids and not maps.
/// </summary>
return;
var yamlEntities = node["entities"];
- if (!protoManager.TryIndex<EntityCategoryPrototype>("DoNotMap", out var dnmCategory))
+ if (!protoManager.TryIndex(DoNotMapCategory, out var dnmCategory))
return;
Assert.Multiple(() =>
[TestOf(typeof(StationJobsSystem))]
public sealed class StationJobsTest
{
+ private const string StationMapId = "FooStation";
+
[TestPrototypes]
- private const string Prototypes = @"
+ private const string Prototypes = $@"
- type: playTimeTracker
id: PlayTimeDummyAssistant
id: PlayTimeDummyChaplain
- type: gameMap
- id: FooStation
+ id: {StationMapId}
minPlayers: 0
- mapName: FooStation
+ mapName: {StationMapId}
mapPath: /Maps/Test/empty.yml
stations:
Station:
- mapNameTemplate: FooStation
+ mapNameTemplate: {StationMapId}
stationProto: StandardNanotrasenStation
components:
- type: StationJobs
var server = pair.Server;
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
- var fooStationProto = prototypeManager.Index<GameMapPrototype>("FooStation");
+ var fooStationProto = prototypeManager.Index<GameMapPrototype>(StationMapId);
var entSysMan = server.ResolveDependency<IEntityManager>().EntitySysManager;
var stationJobs = entSysMan.GetEntitySystem<StationJobsSystem>();
var stationSystem = entSysMan.GetEntitySystem<StationSystem>();
var server = pair.Server;
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
- var fooStationProto = prototypeManager.Index<GameMapPrototype>("FooStation");
+ var fooStationProto = prototypeManager.Index<GameMapPrototype>(StationMapId);
var entSysMan = server.ResolveDependency<IEntityManager>().EntitySysManager;
var stationJobs = entSysMan.GetEntitySystem<StationJobsSystem>();
var stationSystem = entSysMan.GetEntitySystem<StationSystem>();
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.VendingMachines;
+using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Vending;
private const string RestockBoxProtoId = "InteractionTestRestockBox";
private const string RestockBoxOtherProtoId = "InteractionTestRestockBoxOther";
+ private static readonly ProtoId<DamageTypePrototype> TestDamageType = "Blunt";
[TestPrototypes]
private const string TestPrototypes = $@"
Assert.That(damageableComp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero), $"{VendingMachineProtoId} started with unexpected damage.");
// 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));
await Server.WaitPost(() => damageableSys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
await RunTicks(5);
[TestOf(typeof(VendingMachineSystem))]
public sealed class VendingMachineRestockTest : EntitySystem
{
+ private static readonly ProtoId<DamageTypePrototype> TestDamageType = "Blunt";
+
[TestPrototypes]
private const string Prototypes = @"
- type: entity
"Did not start with zero ramen.");
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);
#pragma warning disable NUnit2045
[TestOf(typeof(DamageGroupPrototype))]
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 DamageSpecifier _damageSpec;
_prototypeManager.ResolveResults();
// Create a damage data set
- _damageSpec = new(_prototypeManager.Index<DamageGroupPrototype>("Brute"), 6);
- _damageSpec += new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Radiation"), 3);
- _damageSpec += new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Slash"), -1); // already exists in brute
+ _damageSpec = new(_prototypeManager.Index(BruteDamageGroup), 6);
+ _damageSpec += new DamageSpecifier(_prototypeManager.Index(RadiationDamageType), 3);
+ _damageSpec += new DamageSpecifier(_prototypeManager.Index(SlashDamageType), -1); // already exists in brute
}
//Check that DamageSpecifier will split groups and can do arithmetic operations
Assert.That(damage, Is.EqualTo(FixedPoint2.New(3)));
// 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(damage, Is.EqualTo(FixedPoint2.New(1.33)));
Assert.That(damageSpec.DamageDict.TryGetValue("Slash", 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
- damageSpec = new(_prototypeManager.Index<DamageTypePrototype>("Piercing"), 4);
+ damageSpec = new(_prototypeManager.Index(PiercingDamageType), 4);
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4)));
}
DamageSpecifier damageSpec = 10 * new DamageSpecifier(_damageSpec);
// Create a modifier set
- var modifierSet = _prototypeManager.Index<DamageModifierSetPrototype>("ModifierTestSet");
+ var modifierSet = _prototypeManager.Index<DamageModifierSetPrototype>(ModifierTestSetId);
//damage is initially 20 / 20 / 10 / 30
//Each time we subtract -5 / 0 / 8 / 0.5
Assert.That(damageSpec.DamageDict["Radiation"], Is.EqualTo(FixedPoint2.New(65.62)));
}
+ private const string ModifierTestSetId = "ModifierTestSet";
+
// Default damage Yaml
- private string _damagePrototypes = @"
+ private readonly string _damagePrototypes = $@"
- type: damageType
id: Blunt
name: damage-type-blunt
Blunt: 5
- type: damageModifierSet
- id: ModifierTestSet
+ id: {ModifierTestSetId}
coefficients:
Piercing: -2
Slash: 3
[TestOf(typeof(LocalizedDatasetPrototype))]
public sealed class LocalizedDatasetPrototypeTest : ContentUnitTest
{
+ private const string TestDatasetId = "Test";
+
private IPrototypeManager _prototypeManager;
[OneTimeSetUp]
_prototypeManager.ResolveResults();
}
- private const string TestPrototypes = @"
+ private const string TestPrototypes = $@"
- type: localizedDataset
- id: Test
+ id: {TestDatasetId}
values:
prefix: test-dataset-
count: 4
[Test]
public void LocalizedDatasetTest()
{
- var testPrototype = _prototypeManager.Index<LocalizedDatasetPrototype>("Test");
+ var testPrototype = _prototypeManager.Index<LocalizedDatasetPrototype>(TestDatasetId);
var values = new ValueList<string>();
foreach (var value in testPrototype.Values)
{