Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Zekins3366
2025-11-22 17:13:39 +03:00
487 changed files with 147662 additions and 161615 deletions

View File

@@ -4,8 +4,13 @@ using System.Linq;
using Content.Server.Preferences.Managers;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Shared.EntitySerialization;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.IntegrationTests.Pair;
@@ -15,13 +20,49 @@ public sealed partial class TestPair
public Task<TestMapData> CreateTestMap(bool initialized = true)
=> CreateTestMap(initialized, "Plating");
/// <summary>
/// Loads a test map and returns a <see cref="TestMapData"/> representing it.
/// </summary>
/// <param name="testMapPath">The <see cref="ResPath"/> to the test map to load.</param>
/// <param name="initialized">Whether to initialize the map on load.</param>
/// <returns>A <see cref="TestMapData"/> representing the loaded map.</returns>
public async Task<TestMapData> LoadTestMap(ResPath testMapPath, bool initialized = true)
{
TestMapData mapData = new();
var deserializationOptions = DeserializationOptions.Default with { InitializeMaps = initialized };
var mapLoaderSys = Server.EntMan.System<MapLoaderSystem>();
var mapSys = Server.System<SharedMapSystem>();
// Load our test map in and assert that it exists.
await Server.WaitAssertion(() =>
{
Assert.That(mapLoaderSys.TryLoadMap(testMapPath, out var map, out var gridSet, deserializationOptions),
$"Failed to load map {testMapPath}.");
Assert.That(gridSet, Is.Not.Empty, "There were no grids loaded from the map!");
mapData.MapUid = map!.Value.Owner;
mapData.MapId = map!.Value.Comp.MapId;
mapData.Grid = gridSet!.First();
mapData.GridCoords = new EntityCoordinates(mapData.Grid, 0, 0);
mapData.MapCoords = new MapCoordinates(0, 0, mapData.MapId);
mapData.Tile = mapSys.GetAllTiles(mapData.Grid.Owner, mapData.Grid.Comp).First();
});
await RunTicksSync(10);
mapData.CMapUid = ToClientUid(mapData.MapUid);
mapData.CGridUid = ToClientUid(mapData.Grid);
mapData.CGridCoords = new EntityCoordinates(mapData.CGridUid, 0, 0);
return mapData;
}
/// <summary>
/// Set a user's antag preferences. Modified preferences are automatically reset at the end of the test.
/// </summary>
public async Task SetAntagPreference(ProtoId<AntagPrototype> id, bool value, NetUserId? user = null)
{
user ??= Client.User!.Value;
if (user is not {} userId)
if (user is not { } userId)
return;
var prefMan = Server.ResolveDependency<IServerPreferencesManager>();
@@ -30,7 +71,7 @@ public sealed partial class TestPair
// Automatic preference resetting only resets slot 0.
Assert.That(prefs.SelectedCharacterIndex, Is.EqualTo(0));
var profile = (HumanoidCharacterProfile) prefs.Characters[0];
var profile = (HumanoidCharacterProfile)prefs.Characters[0];
var newProfile = profile.WithAntagPreference(id, value);
_modifiedProfiles.Add(userId);
await Server.WaitPost(() => prefMan.SetProfile(userId, 0, newProfile).Wait());
@@ -58,7 +99,7 @@ public sealed partial class TestPair
var prefMan = Server.ResolveDependency<IServerPreferencesManager>();
var prefs = prefMan.GetPreferences(user);
var profile = (HumanoidCharacterProfile) prefs.Characters[0];
var profile = (HumanoidCharacterProfile)prefs.Characters[0];
var dictionary = new Dictionary<ProtoId<JobPrototype>, JobPriority>(profile.JobPriorities);
// Automatic preference resetting only resets slot 0.

View File

@@ -4,6 +4,7 @@ using Content.Server.Atmos;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Robust.Shared.EntitySerialization;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;

View File

@@ -64,6 +64,11 @@ public sealed class SolutionRoundingTest
SolutionRoundingTestReagentD: 1
";
private const string SolutionRoundingTestReagentA = "SolutionRoundingTestReagentA";
private const string SolutionRoundingTestReagentB = "SolutionRoundingTestReagentB";
private const string SolutionRoundingTestReagentC = "SolutionRoundingTestReagentC";
private const string SolutionRoundingTestReagentD = "SolutionRoundingTestReagentD";
[Test]
public async Task Test()
{
@@ -84,12 +89,12 @@ public sealed class SolutionRoundingTest
solutionEnt = newSolutionEnt!.Value;
solution = newSolution!;
system.TryAddSolution(solutionEnt, new Solution("SolutionRoundingTestReagentC", 50));
system.TryAddSolution(solutionEnt, new Solution("SolutionRoundingTestReagentB", 30));
system.TryAddSolution(solutionEnt, new Solution(SolutionRoundingTestReagentC, 50));
system.TryAddSolution(solutionEnt, new Solution(SolutionRoundingTestReagentB, 30));
for (var i = 0; i < 9; i++)
{
system.TryAddSolution(solutionEnt, new Solution("SolutionRoundingTestReagentA", 10));
system.TryAddSolution(solutionEnt, new Solution(SolutionRoundingTestReagentA, 10));
}
});
@@ -98,21 +103,21 @@ public sealed class SolutionRoundingTest
Assert.Multiple(() =>
{
Assert.That(
solution.ContainsReagent("SolutionRoundingTestReagentA", null),
solution.ContainsReagent(SolutionRoundingTestReagentA, null),
Is.False,
"Solution should not contain reagent A");
Assert.That(
solution.ContainsReagent("SolutionRoundingTestReagentB", null),
solution.ContainsReagent(SolutionRoundingTestReagentB, null),
Is.False,
"Solution should not contain reagent B");
Assert.That(
solution![new ReagentId("SolutionRoundingTestReagentC", null)].Quantity,
solution![new ReagentId(SolutionRoundingTestReagentC, null)].Quantity,
Is.EqualTo((FixedPoint2) 20));
Assert.That(
solution![new ReagentId("SolutionRoundingTestReagentD", null)].Quantity,
solution![new ReagentId(SolutionRoundingTestReagentD, null)].Quantity,
Is.EqualTo((FixedPoint2) 30));
});
});

View File

@@ -43,6 +43,13 @@ public sealed class SolutionSystemTests
desc: reagent-desc-nothing
physicalDesc: reagent-physical-desc-nothing
";
private const string TestReagentA = "TestReagentA";
private const string TestReagentB = "TestReagentB";
private const string TestReagentC = "TestReagentC";
private const string Water = "Water";
private const string Oil = "Oil";
[Test]
public async Task TryAddTwoNonReactiveReagent()
{
@@ -62,8 +69,8 @@ public sealed class SolutionSystemTests
var oilQuantity = FixedPoint2.New(15);
var waterQuantity = FixedPoint2.New(10);
var oilAdded = new Solution("Oil", oilQuantity);
var originalWater = new Solution("Water", waterQuantity);
var oilAdded = new Solution(Oil, oilQuantity);
var originalWater = new Solution(Water, waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
@@ -73,8 +80,8 @@ public sealed class SolutionSystemTests
Assert.That(containerSystem
.TryAddSolution(solutionEnt.Value, oilAdded));
var water = solution.GetTotalPrototypeQuantity("Water");
var oil = solution.GetTotalPrototypeQuantity("Oil");
var water = solution.GetTotalPrototypeQuantity(Water);
var oil = solution.GetTotalPrototypeQuantity(Oil);
Assert.Multiple(() =>
{
Assert.That(water, Is.EqualTo(waterQuantity));
@@ -107,8 +114,8 @@ public sealed class SolutionSystemTests
var oilQuantity = FixedPoint2.New(1500);
var waterQuantity = FixedPoint2.New(10);
var oilAdded = new Solution("Oil", oilQuantity);
var originalWater = new Solution("Water", waterQuantity);
var oilAdded = new Solution(Oil, oilQuantity);
var originalWater = new Solution(Water, waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
@@ -118,8 +125,8 @@ public sealed class SolutionSystemTests
Assert.That(containerSystem
.TryAddSolution(solutionEnt.Value, oilAdded), Is.False);
var water = solution.GetTotalPrototypeQuantity("Water");
var oil = solution.GetTotalPrototypeQuantity("Oil");
var water = solution.GetTotalPrototypeQuantity(Water);
var oil = solution.GetTotalPrototypeQuantity(Oil);
Assert.Multiple(() =>
{
Assert.That(water, Is.EqualTo(waterQuantity));
@@ -153,8 +160,8 @@ public sealed class SolutionSystemTests
var waterQuantity = FixedPoint2.New(10);
var oilQuantity = FixedPoint2.New(ratio * waterQuantity.Int());
var oilAdded = new Solution("Oil", oilQuantity);
var originalWater = new Solution("Water", waterQuantity);
var oilAdded = new Solution(Oil, oilQuantity);
var originalWater = new Solution(Water, waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
@@ -168,15 +175,15 @@ public sealed class SolutionSystemTests
{
Assert.That(solution.Volume, Is.EqualTo(FixedPoint2.New(threshold)));
var waterMix = solution.GetTotalPrototypeQuantity("Water");
var oilMix = solution.GetTotalPrototypeQuantity("Oil");
var waterMix = solution.GetTotalPrototypeQuantity(Water);
var oilMix = solution.GetTotalPrototypeQuantity(Oil);
Assert.That(waterMix, Is.EqualTo(FixedPoint2.New(threshold / (ratio + 1))));
Assert.That(oilMix, Is.EqualTo(FixedPoint2.New(threshold / (ratio + 1) * ratio)));
Assert.That(overflowingSolution.Volume, Is.EqualTo(FixedPoint2.New(80)));
var waterOverflow = overflowingSolution.GetTotalPrototypeQuantity("Water");
var oilOverFlow = overflowingSolution.GetTotalPrototypeQuantity("Oil");
var waterOverflow = overflowingSolution.GetTotalPrototypeQuantity(Water);
var oilOverFlow = overflowingSolution.GetTotalPrototypeQuantity(Oil);
Assert.That(waterOverflow, Is.EqualTo(waterQuantity - waterMix));
Assert.That(oilOverFlow, Is.EqualTo(oilQuantity - oilMix));
});
@@ -207,8 +214,8 @@ public sealed class SolutionSystemTests
var waterQuantity = FixedPoint2.New(10);
var oilQuantity = FixedPoint2.New(ratio * waterQuantity.Int());
var oilAdded = new Solution("Oil", oilQuantity);
var originalWater = new Solution("Water", waterQuantity);
var oilAdded = new Solution(Oil, oilQuantity);
var originalWater = new Solution(Water, waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(containerSystem
@@ -234,24 +241,23 @@ public sealed class SolutionSystemTests
// Adding reagent with adjusts temperature
await server.WaitAssertion(() =>
{
var solution = new Solution("TestReagentA", FixedPoint2.New(100)) { Temperature = temp };
var solution = new Solution(TestReagentA, FixedPoint2.New(100)) { Temperature = temp };
Assert.That(solution.Temperature, Is.EqualTo(temp * 1));
solution.AddSolution(new Solution("TestReagentA", FixedPoint2.New(100)) { Temperature = temp * 3 }, protoMan);
solution.AddSolution(new Solution(TestReagentA, FixedPoint2.New(100)) { Temperature = temp * 3 }, protoMan);
Assert.That(solution.Temperature, Is.EqualTo(temp * 2));
solution.AddSolution(new Solution("TestReagentB", FixedPoint2.New(100)) { Temperature = temp * 5 }, protoMan);
solution.AddSolution(new Solution(TestReagentB, FixedPoint2.New(100)) { Temperature = temp * 5 }, protoMan);
Assert.That(solution.Temperature, Is.EqualTo(temp * 3));
});
// adding solutions combines thermal energy
await server.WaitAssertion(() =>
{
var solutionOne = new Solution("TestReagentA", FixedPoint2.New(100)) { Temperature = temp };
var solutionOne = new Solution(TestReagentA, FixedPoint2.New(100)) { Temperature = temp };
var solutionTwo = new Solution("TestReagentB", FixedPoint2.New(100)) { Temperature = temp };
solutionTwo.AddReagent("TestReagentC", FixedPoint2.New(100));
var solutionTwo = new Solution(TestReagentB, FixedPoint2.New(100)) { Temperature = temp };
solutionTwo.AddReagent(TestReagentC, FixedPoint2.New(100));
var thermalEnergyOne = solutionOne.GetHeatCapacity(protoMan) * solutionOne.Temperature;
var thermalEnergyTwo = solutionTwo.GetHeatCapacity(protoMan) * solutionTwo.Temperature;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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));

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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));

View File

@@ -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;

View File

@@ -24,6 +24,7 @@ using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.UnitTesting;
namespace Content.IntegrationTests.Tests.Interaction;
@@ -39,10 +40,20 @@ namespace Content.IntegrationTests.Tests.Interaction;
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
public abstract partial class InteractionTest
{
/// <summary>
/// The prototype that will be spawned for the player entity at <see cref="PlayerCoords"/>.
/// This is not a full humanoid and only has one hand by default.
/// </summary>
protected virtual string PlayerPrototype => "InteractionTestMob";
/// <summary>
/// The map path to load for the integration test.
/// If null an empty map with a single 1x1 plating grid will be generated.
/// </summary>
protected virtual ResPath? TestMapPath => null;
protected TestPair Pair = default!;
protected TestMapData MapData => Pair.TestMap!;
protected TestMapData MapData = default!;
protected RobustIntegrationTest.ServerIntegrationInstance Server => Pair.Server;
protected RobustIntegrationTest.ClientIntegrationInstance Client => Pair.Client;
@@ -199,7 +210,10 @@ public abstract partial class InteractionTest
CUiSys = CEntMan.System<SharedUserInterfaceSystem>();
// Setup map.
await Pair.CreateTestMap();
if (TestMapPath == null)
MapData = await Pair.CreateTestMap();
else
MapData = await Pair.LoadTestMap(TestMapPath.Value);
PlayerCoords = SEntMan.GetNetCoordinates(Transform.WithEntityId(MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)), MapData.MapUid));
TargetCoords = SEntMan.GetNetCoordinates(Transform.WithEntityId(MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)), MapData.MapUid));
@@ -214,14 +228,14 @@ public abstract partial class InteractionTest
ServerSession = sPlayerMan.GetSessionById(ClientSession.UserId);
// Spawn player entity & attach
EntityUid? old = default;
NetEntity? old = default;
await Server.WaitPost(() =>
{
// Fuck you mind system I want an hour of my life back
// Mind system is a time vampire
SEntMan.System<SharedMindSystem>().WipeMind(ServerSession.ContentData()?.Mind);
old = cPlayerMan.LocalEntity;
CEntMan.TryGetNetEntity(cPlayerMan.LocalEntity, out old);
SPlayer = SEntMan.SpawnEntity(PlayerPrototype, SEntMan.GetCoordinates(PlayerCoords));
Player = SEntMan.GetNetEntity(SPlayer);
Server.PlayerMan.SetAttachedEntity(ServerSession, SPlayer);
@@ -237,8 +251,8 @@ public abstract partial class InteractionTest
// Delete old player entity.
await Server.WaitPost(() =>
{
if (old != null)
SEntMan.DeleteEntity(old.Value);
if (SEntMan.TryGetEntity(old, out var uid))
SEntMan.DeleteEntity(uid);
});
// Change UI state to in-game.

View File

@@ -0,0 +1,31 @@
using System.Linq;
using Robust.Shared.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Utility;
namespace Content.IntegrationTests.Tests.Interaction;
/// <summary>
/// Makes sure that interaction test helper methods are working as intended.
/// </summary>
public sealed class InteractionTestTests : InteractionTest
{
protected override ResPath? TestMapPath => new("Maps/Test/empty.yml");
/// <summary>
/// Tests that map loading is working correctly.
/// </summary>
[Test]
public void MapLoadingTest()
{
// Make sure that there is only one grid.
var grids = SEntMan.AllEntities<MapGridComponent>().ToList();
Assert.That(grids, Has.Count.EqualTo(1), "Test map did not have exactly one grid.");
Assert.That(grids, Does.Contain(MapData.Grid), "MapData did not contain the loaded grid.");
// Make sure we loaded the right map.
// This name is defined in empty.yml
Assert.That(SEntMan.GetComponent<MetaDataComponent>(MapData.MapUid).EntityName, Is.EqualTo("Empty Debug Map"));
}
}

View File

@@ -1,114 +1,122 @@
using Content.Client.Lobby;
using Content.Server.Preferences.Managers;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
using Robust.Client.State;
using Robust.Shared.Network;
namespace Content.IntegrationTests.Tests.Lobby
namespace Content.IntegrationTests.Tests.Lobby;
[TestFixture]
[TestOf(typeof(ClientPreferencesManager))]
[TestOf(typeof(ServerPreferencesManager))]
public sealed class CharacterCreationTest
{
[TestFixture]
[TestOf(typeof(ClientPreferencesManager))]
[TestOf(typeof(ServerPreferencesManager))]
public sealed class CharacterCreationTest
[Test]
public async Task CreateDeleteCreateTest()
{
[Test]
public async Task CreateDeleteCreateTest()
await using var pair = await PoolManager.GetServerClient(new PoolSettings { InLobby = true });
var server = pair.Server;
var client = pair.Client;
var user = pair.Client.User!.Value;
var clientPrefManager = client.Resolve<IClientPreferencesManager>();
var serverPrefManager = server.Resolve<IServerPreferencesManager>();
Assert.That(client.Resolve<IStateManager>().CurrentState, Is.TypeOf<LobbyState>());
await client.WaitPost(() => clientPrefManager.SelectCharacter(0));
await pair.RunTicksSync(5);
var clientCharacters = clientPrefManager.Preferences?.Characters;
Assert.That(clientCharacters, Is.Not.Null);
Assert.That(clientCharacters, Has.Count.EqualTo(1));
HumanoidCharacterProfile profile = null;
await client.WaitPost(() =>
{
await using var pair = await PoolManager.GetServerClient(new PoolSettings { InLobby = true });
var server = pair.Server;
var client = pair.Client;
profile = HumanoidCharacterProfile.Random();
clientPrefManager.CreateCharacter(profile);
});
await pair.RunTicksSync(5);
var clientNetManager = client.ResolveDependency<IClientNetManager>();
var clientStateManager = client.ResolveDependency<IStateManager>();
var clientPrefManager = client.ResolveDependency<IClientPreferencesManager>();
clientCharacters = clientPrefManager.Preferences?.Characters;
Assert.That(clientCharacters, Is.Not.Null);
Assert.That(clientCharacters, Has.Count.EqualTo(2));
AssertEqual(clientCharacters[1], profile);
var serverPrefManager = server.ResolveDependency<IServerPreferencesManager>();
await PoolManager.WaitUntil(server, () => serverPrefManager.GetPreferences(user).Characters.Count == 2, maxTicks: 60);
var serverCharacters = serverPrefManager.GetPreferences(user).Characters;
Assert.That(serverCharacters, Has.Count.EqualTo(2));
AssertEqual(serverCharacters[1], profile);
// Need to run them in sync to receive the messages.
await pair.RunTicksSync(1);
await client.WaitAssertion(() => clientPrefManager.DeleteCharacter(1));
await pair.RunTicksSync(5);
Assert.That(clientPrefManager.Preferences?.Characters.Count, Is.EqualTo(1));
await PoolManager.WaitUntil(server, () => serverPrefManager.GetPreferences(user).Characters.Count == 1, maxTicks: 60);
Assert.That(serverPrefManager.GetPreferences(user).Characters.Count, Is.EqualTo(1));
await PoolManager.WaitUntil(client, () => clientStateManager.CurrentState is LobbyState, 600);
await client.WaitIdleAsync();
Assert.That(clientNetManager.ServerChannel, Is.Not.Null);
await client.WaitAssertion(() =>
{
profile = HumanoidCharacterProfile.Random();
clientPrefManager.CreateCharacter(profile);
});
await pair.RunTicksSync(5);
var clientNetId = clientNetManager.ServerChannel.UserId;
HumanoidCharacterProfile profile = null;
clientCharacters = clientPrefManager.Preferences?.Characters;
Assert.That(clientCharacters, Is.Not.Null);
Assert.That(clientCharacters, Has.Count.EqualTo(2));
AssertEqual(clientCharacters[1], profile);
await client.WaitAssertion(() =>
{
clientPrefManager.SelectCharacter(0);
await PoolManager.WaitUntil(server, () => serverPrefManager.GetPreferences(user).Characters.Count == 2, maxTicks: 60);
serverCharacters = serverPrefManager.GetPreferences(user).Characters;
Assert.That(serverCharacters, Has.Count.EqualTo(2));
AssertEqual(serverCharacters[1], profile);
await pair.CleanReturnAsync();
}
var clientCharacters = clientPrefManager.Preferences?.Characters;
Assert.That(clientCharacters, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(clientCharacters, Has.Count.EqualTo(1));
private void AssertEqual(ICharacterProfile clientCharacter, HumanoidCharacterProfile b)
{
if (clientCharacter.MemberwiseEquals(b))
return;
Assert.That(clientStateManager.CurrentState, Is.TypeOf<LobbyState>());
});
profile = HumanoidCharacterProfile.Random();
clientPrefManager.CreateCharacter(profile);
clientCharacters = clientPrefManager.Preferences?.Characters;
Assert.That(clientCharacters, Is.Not.Null);
Assert.That(clientCharacters, Has.Count.EqualTo(2));
Assert.That(clientCharacters[1].MemberwiseEquals(profile));
});
await PoolManager.WaitUntil(server, () => serverPrefManager.GetPreferences(clientNetId).Characters.Count == 2, maxTicks: 60);
await server.WaitAssertion(() =>
{
var serverCharacters = serverPrefManager.GetPreferences(clientNetId).Characters;
Assert.That(serverCharacters, Has.Count.EqualTo(2));
Assert.That(serverCharacters[1].MemberwiseEquals(profile));
});
await client.WaitAssertion(() =>
{
clientPrefManager.DeleteCharacter(1);
var clientCharacters = clientPrefManager.Preferences?.Characters.Count;
Assert.That(clientCharacters, Is.EqualTo(1));
});
await PoolManager.WaitUntil(server, () => serverPrefManager.GetPreferences(clientNetId).Characters.Count == 1, maxTicks: 60);
await server.WaitAssertion(() =>
{
var serverCharacters = serverPrefManager.GetPreferences(clientNetId).Characters.Count;
Assert.That(serverCharacters, Is.EqualTo(1));
});
await client.WaitIdleAsync();
await client.WaitAssertion(() =>
{
profile = HumanoidCharacterProfile.Random();
clientPrefManager.CreateCharacter(profile);
var clientCharacters = clientPrefManager.Preferences?.Characters;
Assert.That(clientCharacters, Is.Not.Null);
Assert.That(clientCharacters, Has.Count.EqualTo(2));
Assert.That(clientCharacters[1].MemberwiseEquals(profile));
});
await PoolManager.WaitUntil(server, () => serverPrefManager.GetPreferences(clientNetId).Characters.Count == 2, maxTicks: 60);
await server.WaitAssertion(() =>
{
var serverCharacters = serverPrefManager.GetPreferences(clientNetId).Characters;
Assert.That(serverCharacters, Has.Count.EqualTo(2));
Assert.That(serverCharacters[1].MemberwiseEquals(profile));
});
await pair.CleanReturnAsync();
if (clientCharacter is not HumanoidCharacterProfile a)
{
Assert.Fail($"Not a {nameof(HumanoidCharacterProfile)}");
return;
}
Assert.Multiple(() =>
{
Assert.That(a.Name, Is.EqualTo(b.Name));
Assert.That(a.Age, Is.EqualTo(b.Age));
Assert.That(a.Sex, Is.EqualTo(b.Sex));
Assert.That(a.Gender, Is.EqualTo(b.Gender));
Assert.That(a.Species, Is.EqualTo(b.Species));
Assert.That(a.PreferenceUnavailable, Is.EqualTo(b.PreferenceUnavailable));
Assert.That(a.SpawnPriority, Is.EqualTo(b.SpawnPriority));
Assert.That(a.FlavorText, Is.EqualTo(b.FlavorText));
Assert.That(a.JobPriorities, Is.EquivalentTo(b.JobPriorities));
Assert.That(a.AntagPreferences, Is.EquivalentTo(b.AntagPreferences));
Assert.That(a.TraitPreferences, Is.EquivalentTo(b.TraitPreferences));
Assert.That(a.Loadouts, Is.EquivalentTo(b.Loadouts));
AssertEqual(a.Appearance, b.Appearance);
Assert.Fail("Profile not equal");
});
}
private void AssertEqual(HumanoidCharacterAppearance a, HumanoidCharacterAppearance b)
{
if (a.MemberwiseEquals(b))
return;
Assert.That(a.HairStyleId, Is.EqualTo(b.HairStyleId));
Assert.That(a.HairColor, Is.EqualTo(b.HairColor));
Assert.That(a.FacialHairStyleId, Is.EqualTo(b.FacialHairStyleId));
Assert.That(a.FacialHairColor, Is.EqualTo(b.FacialHairColor));
Assert.That(a.EyeColor, Is.EqualTo(b.EyeColor));
Assert.That(a.SkinColor, Is.EqualTo(b.SkinColor));
Assert.That(a.Markings, Is.EquivalentTo(b.Markings));
Assert.Fail("Appearance not equal");
}
}

View File

@@ -28,20 +28,10 @@ namespace Content.IntegrationTests.Tests;
[TestFixture]
public sealed class MaterialArbitrageTest
{
// These recipes are currently broken and need fixing. You should not be adding to these sets.
private readonly HashSet<string> _destructionArbitrageIgnore =
[
"BaseChemistryEmptyVial", "DrinkShotGlass", "SodiumLightTube", "DrinkGlassCoupeShaped",
"LedLightBulb", "ExteriorLightTube", "LightTube", "DrinkGlass", "DimLightBulb", "LightBulb", "LedLightTube",
"ChemistryEmptyBottle01", "WarmLightBulb",
];
private readonly HashSet<string> _compositionArbitrageIgnore =
[
"FoodPlateSmall", "AirTank", "FoodPlateTin", "FoodPlateMuffinTin", "WeaponCapacitorRechargerCircuitboard",
"WeaponCapacitorRechargerCircuitboard", "BorgChargerCircuitboard", "BorgChargerCircuitboard", "FoodPlate",
"CellRechargerCircuitboard", "CellRechargerCircuitboard",
];
// These sets are for selectively excluding recipes from arbitrage.
// You should NOT be adding to these. They exist here for downstreams and potential future issues.
private readonly HashSet<string> _destructionArbitrageIgnore = [];
private readonly HashSet<string> _compositionArbitrageIgnore = [];
[Test]
public async Task NoMaterialArbitrage()

View File

@@ -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));
});

View File

@@ -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;

View File

@@ -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;

View File

@@ -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.");
}

View File

@@ -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);

View File

@@ -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;