@@ -1,12 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Content.IntegrationTests;
|
||||
|
||||
/// <summary>
|
||||
/// Generic implementation of <see cref="ITestContextLike"/> for usage outside of actual tests.
|
||||
/// </summary>
|
||||
public sealed class ExternalTestContext(string name, TextWriter writer) : ITestContextLike
|
||||
{
|
||||
public string FullName => name;
|
||||
public TextWriter Out => writer;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Content.IntegrationTests;
|
||||
|
||||
/// <summary>
|
||||
/// Something that looks like a <see cref="TestContext"/>, for passing to integration tests.
|
||||
/// </summary>
|
||||
public interface ITestContextLike
|
||||
{
|
||||
string FullName { get; }
|
||||
TextWriter Out { get; }
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Content.IntegrationTests;
|
||||
|
||||
/// <summary>
|
||||
/// Canonical implementation of <see cref="ITestContextLike"/> for usage in actual NUnit tests.
|
||||
/// </summary>
|
||||
public sealed class NUnitTestContextWrap(TestContext context, TextWriter writer) : ITestContextLike
|
||||
{
|
||||
public string FullName => context.Test.FullName;
|
||||
public TextWriter Out => writer;
|
||||
}
|
||||
@@ -13,7 +13,6 @@ using Robust.Server.Player;
|
||||
using Robust.Shared.Exceptions;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.IntegrationTests.Pair;
|
||||
|
||||
@@ -85,7 +84,6 @@ public sealed partial class TestPair : IAsyncDisposable
|
||||
|
||||
var returnTime = Watch.Elapsed;
|
||||
await _testOut.WriteLineAsync($"{nameof(CleanReturnAsync)}: PoolManager took {returnTime.TotalMilliseconds} ms to put pair {Id} back into the pool");
|
||||
State = PairState.Ready;
|
||||
}
|
||||
|
||||
private async Task ResetModifiedPreferences()
|
||||
@@ -106,7 +104,7 @@ public sealed partial class TestPair : IAsyncDisposable
|
||||
await _testOut.WriteLineAsync($"{nameof(CleanReturnAsync)}: Return of pair {Id} started");
|
||||
State = PairState.CleanDisposed;
|
||||
await OnCleanDispose();
|
||||
DebugTools.Assert(State is PairState.Dead or PairState.Ready);
|
||||
State = PairState.Ready;
|
||||
PoolManager.NoCheckReturn(this);
|
||||
ClearContext();
|
||||
}
|
||||
|
||||
@@ -182,29 +182,24 @@ public static partial class PoolManager
|
||||
/// </summary>
|
||||
/// <param name="poolSettings">See <see cref="PoolSettings"/></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<TestPair> GetServerClient(
|
||||
PoolSettings? poolSettings = null,
|
||||
ITestContextLike? testContext = null)
|
||||
public static async Task<TestPair> GetServerClient(PoolSettings? poolSettings = null)
|
||||
{
|
||||
return await GetServerClientPair(
|
||||
poolSettings ?? new PoolSettings(),
|
||||
testContext ?? new NUnitTestContextWrap(TestContext.CurrentContext, TestContext.Out));
|
||||
return await GetServerClientPair(poolSettings ?? new PoolSettings());
|
||||
}
|
||||
|
||||
private static string GetDefaultTestName(ITestContextLike testContext)
|
||||
private static string GetDefaultTestName(TestContext testContext)
|
||||
{
|
||||
return testContext.FullName.Replace("Content.IntegrationTests.Tests.", "");
|
||||
return testContext.Test.FullName.Replace("Content.IntegrationTests.Tests.", "");
|
||||
}
|
||||
|
||||
private static async Task<TestPair> GetServerClientPair(
|
||||
PoolSettings poolSettings,
|
||||
ITestContextLike testContext)
|
||||
private static async Task<TestPair> GetServerClientPair(PoolSettings poolSettings)
|
||||
{
|
||||
if (!_initialized)
|
||||
throw new InvalidOperationException($"Pool manager has not been initialized");
|
||||
|
||||
// Trust issues with the AsyncLocal that backs this.
|
||||
var testOut = testContext.Out;
|
||||
var testContext = TestContext.CurrentContext;
|
||||
var testOut = TestContext.Out;
|
||||
|
||||
DieIfPoolFailure();
|
||||
var currentTestName = poolSettings.TestName ?? GetDefaultTestName(testContext);
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#nullable enable
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.RetractableItemAction;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Actions;
|
||||
|
||||
public sealed class RetractableItemActionTest : InteractionTest
|
||||
{
|
||||
private static readonly EntProtoId ArmBladeActionProtoId = "ActionRetractableItemArmBlade";
|
||||
|
||||
/// <summary>
|
||||
/// Gives the player the arm blade action, then activates it and makes sure they are given the blade.
|
||||
/// Afterwards, uses the action again to retract the blade and makes sure their hand is empty.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ArmBladeActivateDeactivateTest()
|
||||
{
|
||||
var actionsSystem = Server.System<SharedActionsSystem>();
|
||||
var handsSystem = Server.System<SharedHandsSystem>();
|
||||
var playerUid = SEntMan.GetEntity(Player);
|
||||
|
||||
await Server.WaitAssertion(() =>
|
||||
{
|
||||
// Make sure the player's hand starts empty
|
||||
var heldItem = handsSystem.GetActiveItem((playerUid, Hands));
|
||||
Assert.That(heldItem, Is.Null, $"Player is holding an item ({SEntMan.ToPrettyString(heldItem)}) at start of test.");
|
||||
|
||||
// Inspect the action prototype to find the item it spawns
|
||||
var armBladeActionProto = ProtoMan.Index(ArmBladeActionProtoId);
|
||||
|
||||
// Find the component
|
||||
Assert.That(armBladeActionProto.TryGetComponent<RetractableItemActionComponent>(out var actionComp, SEntMan.ComponentFactory));
|
||||
// Get the item protoId from the component
|
||||
var spawnedProtoId = actionComp!.SpawnedPrototype;
|
||||
|
||||
// Add the action to the player
|
||||
var actionUid = actionsSystem.AddAction(playerUid, ArmBladeActionProtoId);
|
||||
// Make sure the player has the action now
|
||||
Assert.That(actionUid, Is.Not.Null, "Failed to add action to player.");
|
||||
var actionEnt = actionsSystem.GetAction(actionUid);
|
||||
|
||||
// Make sure the player's hand is still empty
|
||||
heldItem = handsSystem.GetActiveItem((playerUid, Hands));
|
||||
Assert.That(heldItem, Is.Null, $"Player is holding an item ({SEntMan.ToPrettyString(heldItem)}) after adding action.");
|
||||
|
||||
// Activate the arm blade
|
||||
actionsSystem.PerformAction(ToServer(Player), actionEnt!.Value);
|
||||
|
||||
// Make sure the player is now holding the expected item
|
||||
heldItem = handsSystem.GetActiveItem((playerUid, Hands));
|
||||
Assert.That(heldItem, Is.Not.Null, $"Expected player to be holding {spawnedProtoId} but was holding nothing.");
|
||||
AssertPrototype(spawnedProtoId, SEntMan.GetNetEntity(heldItem));
|
||||
|
||||
// Use the action again to retract the arm blade
|
||||
actionsSystem.PerformAction(ToServer(Player), actionEnt.Value);
|
||||
|
||||
// Make sure the player's hand is empty again
|
||||
heldItem = handsSystem.GetActiveItem((playerUid, Hands));
|
||||
Assert.That(heldItem, Is.Null, $"Player is still holding an item ({SEntMan.ToPrettyString(heldItem)}) after second use.");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -293,9 +293,9 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
Assert.That(buckle.Buckled);
|
||||
|
||||
// With items in all hands
|
||||
foreach (var hand in hands.Hands.Keys)
|
||||
foreach (var hand in hands.Hands.Values)
|
||||
{
|
||||
Assert.That(handsSys.GetHeldItem((human, hands), hand), Is.Not.Null);
|
||||
Assert.That(hand.HeldEntity, Is.Not.Null);
|
||||
}
|
||||
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
@@ -316,9 +316,9 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
Assert.That(buckle.Buckled);
|
||||
|
||||
// Now with no item in any hand
|
||||
foreach (var hand in hands.Hands.Keys)
|
||||
foreach (var hand in hands.Hands.Values)
|
||||
{
|
||||
Assert.That(handsSys.GetHeldItem((human, hands), hand), Is.Null);
|
||||
Assert.That(hand.HeldEntity, Is.Null);
|
||||
}
|
||||
|
||||
buckleSystem.Unbuckle(human, human);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Client.Chemistry.UI;
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Chemistry;
|
||||
@@ -18,7 +19,7 @@ public sealed class DispenserTest : InteractionTest
|
||||
|
||||
// Insert beaker
|
||||
await InteractUsing("Beaker");
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
|
||||
// Open BUI
|
||||
await Interact();
|
||||
@@ -28,18 +29,18 @@ public sealed class DispenserTest : InteractionTest
|
||||
await SendBui(ReagentDispenserUiKey.Key, ev);
|
||||
|
||||
// Beaker is back in the player's hands
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Not.Null);
|
||||
AssertPrototype("Beaker", SEntMan.GetNetEntity(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands))));
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Not.Null);
|
||||
AssertPrototype("Beaker", SEntMan.GetNetEntity(Hands.ActiveHandEntity));
|
||||
|
||||
// Re-insert the beaker
|
||||
await Interact();
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
|
||||
// Re-eject using the button directly instead of sending a BUI event. This test is really just a test of the
|
||||
// bui/window helper methods.
|
||||
await ClickControl<ReagentDispenserWindow>(nameof(ReagentDispenserWindow.EjectButton));
|
||||
await RunTicks(5);
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Not.Null);
|
||||
AssertPrototype("Beaker", SEntMan.GetNetEntity(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands))));
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Not.Null);
|
||||
AssertPrototype("Beaker", SEntMan.GetNetEntity(Hands.ActiveHandEntity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
using Content.Shared.Cloning;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Cloning;
|
||||
|
||||
public sealed class CloningSettingsPrototypeTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks that the components named in every <see cref="CloningSettingsPrototype"/> are valid components known to the server.
|
||||
/// This is used instead of <see cref="ComponentNameSerializer"/> because we only care if the components are registered with the server,
|
||||
/// and instead of a <see cref="ComponentRegistry"/> because we only need component names.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ValidatePrototypes()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
var protoMan = server.ProtoMan;
|
||||
var compFactory = server.EntMan.ComponentFactory;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
var protos = protoMan.EnumeratePrototypes<CloningSettingsPrototype>();
|
||||
foreach (var proto in protos)
|
||||
{
|
||||
foreach (var compName in proto.Components)
|
||||
{
|
||||
Assert.That(compFactory.TryGetRegistration(compName, out _),
|
||||
$"Failed to find a component named {compName} for {nameof(CloningSettingsPrototype)} \"{proto.ID}\""
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var eventCompName in proto.EventComponents)
|
||||
{
|
||||
Assert.That(compFactory.TryGetRegistration(eventCompName, out _),
|
||||
$"Failed to find a component named {eventCompName} for {nameof(CloningSettingsPrototype)} \"{proto.ID}\""
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using Content.Server.Objectives;
|
||||
using Content.Shared.Mind;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Commands;
|
||||
|
||||
public sealed class ObjectiveCommandsTest
|
||||
{
|
||||
|
||||
private const string ObjectiveProtoId = "MindCommandsTestObjective";
|
||||
private const string DummyUsername = "MindCommandsTestUser";
|
||||
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = $"""
|
||||
- type: entity
|
||||
id: {ObjectiveProtoId}
|
||||
components:
|
||||
- type: Objective
|
||||
difficulty: 1
|
||||
issuer: objective-issuer-syndicate
|
||||
icon:
|
||||
sprite: error.rsi
|
||||
state: error
|
||||
- type: DieCondition
|
||||
""";
|
||||
|
||||
/// <summary>
|
||||
/// Creates a dummy session, and assigns it a mind, then
|
||||
/// tests using <c>addobjective</c>, <c>lsobjectives</c>,
|
||||
/// and <c>rmobjective</c> on it.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task AddListRemoveObjectiveTest()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
var entMan = server.EntMan;
|
||||
var playerMan = server.ResolveDependency<ISharedPlayerManager>();
|
||||
var mindSys = server.System<SharedMindSystem>();
|
||||
var objectivesSystem = server.System<ObjectivesSystem>();
|
||||
|
||||
await server.AddDummySession(DummyUsername);
|
||||
await server.WaitRunTicks(5);
|
||||
|
||||
var playerSession = playerMan.Sessions.Single();
|
||||
|
||||
Entity<MindComponent>? mindEnt = null;
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
mindEnt = mindSys.CreateMind(playerSession.UserId);
|
||||
});
|
||||
|
||||
Assert.That(mindEnt, Is.Not.Null);
|
||||
var mindComp = mindEnt.Value.Comp;
|
||||
Assert.That(mindComp.Objectives, Is.Empty, "Dummy player started with objectives.");
|
||||
|
||||
await pair.WaitCommand($"addobjective {playerSession.Name} {ObjectiveProtoId}");
|
||||
|
||||
Assert.That(mindComp.Objectives, Has.Count.EqualTo(1), "addobjective failed to increase Objectives count.");
|
||||
|
||||
await pair.WaitCommand($"lsobjectives {playerSession.Name}");
|
||||
|
||||
await pair.WaitCommand($"rmobjective {playerSession.Name} 0");
|
||||
|
||||
Assert.That(mindComp.Objectives, Is.Empty, "rmobjective failed to remove objective");
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public sealed class SuicideCommandTests
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var item = entManager.SpawnEntity("SharpTestObject", transformSystem.GetMapCoordinates(player));
|
||||
Assert.That(handsSystem.TryPickup(player, item, handsComponent.ActiveHandId!));
|
||||
Assert.That(handsSystem.TryPickup(player, item, handsComponent.ActiveHand!));
|
||||
entManager.TryGetComponent<ExecutionComponent>(item, out var executionComponent);
|
||||
Assert.That(executionComponent, Is.Not.EqualTo(null));
|
||||
});
|
||||
@@ -338,7 +338,7 @@ public sealed class SuicideCommandTests
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var item = entManager.SpawnEntity("MixedDamageTestObject", transformSystem.GetMapCoordinates(player));
|
||||
Assert.That(handsSystem.TryPickup(player, item, handsComponent.ActiveHandId!));
|
||||
Assert.That(handsSystem.TryPickup(player, item, handsComponent.ActiveHand!));
|
||||
entManager.TryGetComponent<ExecutionComponent>(item, out var executionComponent);
|
||||
Assert.That(executionComponent, Is.Not.EqualTo(null));
|
||||
});
|
||||
|
||||
@@ -13,10 +13,10 @@ public sealed class WallConstruction : InteractionTest
|
||||
{
|
||||
await StartConstruction(Wall);
|
||||
await InteractUsing(Steel, 2);
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
ClientAssertPrototype(Girder, Target);
|
||||
await InteractUsing(Steel, 2);
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
AssertPrototype(WallSolid);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Content.IntegrationTests.Tests.Disposal
|
||||
SubscribeLocalEvent<DoInsertDisposalUnitEvent>(ev =>
|
||||
{
|
||||
var (_, toInsert, unit) = ev;
|
||||
var insertTransform = Comp<TransformComponent>(toInsert);
|
||||
var insertTransform = EntityManager.GetComponent<TransformComponent>(toInsert);
|
||||
// Not in a tube yet
|
||||
Assert.That(insertTransform.ParentUid, Is.EqualTo(unit));
|
||||
}, after: new[] { typeof(SharedDisposalUnitSystem) });
|
||||
|
||||
@@ -53,20 +53,20 @@ public sealed class HandTests
|
||||
var xform = entMan.GetComponent<TransformComponent>(player);
|
||||
item = entMan.SpawnEntity("Crowbar", tSys.GetMapCoordinates(player, xform: xform));
|
||||
hands = entMan.GetComponent<HandsComponent>(player);
|
||||
sys.TryPickup(player, item, hands.ActiveHandId!);
|
||||
sys.TryPickup(player, item, hands.ActiveHand!);
|
||||
});
|
||||
|
||||
// run ticks here is important, as errors may happen within the container system's frame update methods.
|
||||
await pair.RunTicksSync(5);
|
||||
Assert.That(sys.GetActiveItem((player, hands)), Is.EqualTo(item));
|
||||
Assert.That(hands.ActiveHandEntity, Is.EqualTo(item));
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
sys.TryDrop(player, item);
|
||||
sys.TryDrop(player, item, null!);
|
||||
});
|
||||
|
||||
await pair.RunTicksSync(5);
|
||||
Assert.That(sys.GetActiveItem((player, hands)), Is.Null);
|
||||
Assert.That(hands.ActiveHandEntity, Is.Null);
|
||||
|
||||
await server.WaitPost(() => mapSystem.DeleteMap(data.MapId));
|
||||
await pair.CleanReturnAsync();
|
||||
@@ -105,10 +105,10 @@ public sealed class HandTests
|
||||
player = playerMan.Sessions.First().AttachedEntity!.Value;
|
||||
tSys.PlaceNextTo(player, item);
|
||||
hands = entMan.GetComponent<HandsComponent>(player);
|
||||
sys.TryPickup(player, item, hands.ActiveHandId!);
|
||||
sys.TryPickup(player, item, hands.ActiveHand!);
|
||||
});
|
||||
await pair.RunTicksSync(5);
|
||||
Assert.That(sys.GetActiveItem((player, hands)), Is.EqualTo(item));
|
||||
Assert.That(hands.ActiveHandEntity, Is.EqualTo(item));
|
||||
|
||||
// Open then close the box to place the player, who is holding the crowbar, inside of it
|
||||
var storage = server.System<EntityStorageSystem>();
|
||||
@@ -125,12 +125,12 @@ public sealed class HandTests
|
||||
// with the item not being in the player's hands
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
sys.TryDrop(player, item);
|
||||
sys.TryDrop(player, item, null!);
|
||||
});
|
||||
await pair.RunTicksSync(5);
|
||||
var xform = entMan.GetComponent<TransformComponent>(player);
|
||||
var itemXform = entMan.GetComponent<TransformComponent>(item);
|
||||
Assert.That(sys.GetActiveItem((player, hands)), Is.Not.EqualTo(item));
|
||||
Assert.That(hands.ActiveHandEntity, Is.Not.EqualTo(item));
|
||||
Assert.That(containerSystem.IsInSameOrNoContainer((player, xform), (item, itemXform)));
|
||||
|
||||
await server.WaitPost(() => mapSystem.DeleteMap(map.MapId));
|
||||
|
||||
@@ -120,18 +120,18 @@ public abstract partial class InteractionTest
|
||||
/// </summary>
|
||||
protected async Task DeleteHeldEntity()
|
||||
{
|
||||
if (HandSys.GetActiveItem((ToServer(Player), Hands)) is { } held)
|
||||
if (Hands.ActiveHandEntity is { } held)
|
||||
{
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
Assert.That(HandSys.TryDrop((SEntMan.GetEntity(Player), Hands), null, false, true));
|
||||
Assert.That(HandSys.TryDrop(SEntMan.GetEntity(Player), null, false, true, Hands));
|
||||
SEntMan.DeleteEntity(held);
|
||||
SLogger.Debug($"Deleting held entity");
|
||||
});
|
||||
}
|
||||
|
||||
await RunTicks(1);
|
||||
Assert.That(HandSys.GetActiveItem((ToServer(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -152,7 +152,7 @@ public abstract partial class InteractionTest
|
||||
/// <param name="enableToggleable">Whether or not to automatically enable any toggleable items</param>
|
||||
protected async Task<NetEntity> PlaceInHands(EntitySpecifier entity, bool enableToggleable = true)
|
||||
{
|
||||
if (Hands.ActiveHandId == null)
|
||||
if (Hands.ActiveHand == null)
|
||||
{
|
||||
Assert.Fail("No active hand");
|
||||
return default;
|
||||
@@ -169,7 +169,7 @@ public abstract partial class InteractionTest
|
||||
{
|
||||
var playerEnt = SEntMan.GetEntity(Player);
|
||||
|
||||
Assert.That(HandSys.TryPickup(playerEnt, item, Hands.ActiveHandId, false, false, false, Hands));
|
||||
Assert.That(HandSys.TryPickup(playerEnt, item, Hands.ActiveHand, false, false, Hands));
|
||||
|
||||
// turn on welders
|
||||
if (enableToggleable && SEntMan.TryGetComponent(item, out itemToggle) && !itemToggle.Activated)
|
||||
@@ -179,7 +179,7 @@ public abstract partial class InteractionTest
|
||||
});
|
||||
|
||||
await RunTicks(1);
|
||||
Assert.That(HandSys.GetActiveItem((ToServer(Player), Hands)), Is.EqualTo(item));
|
||||
Assert.That(Hands.ActiveHandEntity, Is.EqualTo(item));
|
||||
if (enableToggleable && itemToggle != null)
|
||||
Assert.That(itemToggle.Activated);
|
||||
|
||||
@@ -193,7 +193,7 @@ public abstract partial class InteractionTest
|
||||
{
|
||||
entity ??= Target;
|
||||
|
||||
if (Hands.ActiveHandId == null)
|
||||
if (Hands.ActiveHand == null)
|
||||
{
|
||||
Assert.Fail("No active hand");
|
||||
return;
|
||||
@@ -212,11 +212,11 @@ public abstract partial class InteractionTest
|
||||
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
Assert.That(HandSys.TryPickup(ToServer(Player), uid.Value, Hands.ActiveHandId, false, false, false, Hands, item));
|
||||
Assert.That(HandSys.TryPickup(SEntMan.GetEntity(Player), uid.Value, Hands.ActiveHand, false, false, Hands, item));
|
||||
});
|
||||
|
||||
await RunTicks(1);
|
||||
Assert.That(HandSys.GetActiveItem((ToServer(Player), Hands)), Is.EqualTo(uid));
|
||||
Assert.That(Hands.ActiveHandEntity, Is.EqualTo(uid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -224,7 +224,7 @@ public abstract partial class InteractionTest
|
||||
/// </summary>
|
||||
protected async Task Drop()
|
||||
{
|
||||
if (HandSys.GetActiveItem((ToServer(Player), Hands)) == null)
|
||||
if (Hands.ActiveHandEntity == null)
|
||||
{
|
||||
Assert.Fail("Not holding any entity to drop");
|
||||
return;
|
||||
@@ -232,11 +232,11 @@ public abstract partial class InteractionTest
|
||||
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
Assert.That(HandSys.TryDrop((ToServer(Player), Hands)));
|
||||
Assert.That(HandSys.TryDrop(SEntMan.GetEntity(Player), handsComp: Hands));
|
||||
});
|
||||
|
||||
await RunTicks(1);
|
||||
Assert.That(HandSys.GetActiveItem((ToServer(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
}
|
||||
|
||||
#region Interact
|
||||
@@ -246,7 +246,7 @@ public abstract partial class InteractionTest
|
||||
/// </summary>
|
||||
protected async Task UseInHand()
|
||||
{
|
||||
if (HandSys.GetActiveItem((ToServer(Player), Hands)) is not { } target)
|
||||
if (Hands.ActiveHandEntity is not { } target)
|
||||
{
|
||||
Assert.Fail("Not holding any entity");
|
||||
return;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Client.Construction;
|
||||
using Content.Client.Examine;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.IntegrationTests.Pair;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Tools;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -132,13 +135,10 @@ public abstract partial class InteractionTest
|
||||
- type: entity
|
||||
id: InteractionTestMob
|
||||
components:
|
||||
- type: Body
|
||||
prototype: Aghost
|
||||
- type: DoAfter
|
||||
- type: Hands
|
||||
hands:
|
||||
hand_right: # only one hand, so that they do not accidentally pick up deconstruction products
|
||||
location: Right
|
||||
sortedHands:
|
||||
- hand_right
|
||||
- type: ComplexInteraction
|
||||
- type: MindContainer
|
||||
- type: Stripping
|
||||
@@ -230,6 +230,20 @@ public abstract partial class InteractionTest
|
||||
SEntMan.DeleteEntity(old.Value);
|
||||
});
|
||||
|
||||
// Ensure that the player only has one hand, so that they do not accidentally pick up deconstruction products
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
// I lost an hour of my life trying to track down how the hell interaction tests were breaking
|
||||
// so greatz to this. Just make your own body prototype!
|
||||
var bodySystem = SEntMan.System<BodySystem>();
|
||||
var hands = bodySystem.GetBodyChildrenOfType(SEntMan.GetEntity(Player), BodyPartType.Hand).ToArray();
|
||||
|
||||
for (var i = 1; i < hands.Length; i++)
|
||||
{
|
||||
SEntMan.DeleteEntity(hands[i].Id);
|
||||
}
|
||||
});
|
||||
|
||||
// Change UI state to in-game.
|
||||
var state = Client.ResolveDependency<IStateManager>();
|
||||
await Client.WaitPost(() => state.RequestStateChange<GameplayState>());
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace Content.IntegrationTests.Tests.Networking
|
||||
{
|
||||
var uid = GetEntity(message.Uid);
|
||||
|
||||
var component = Comp<PredictionTestComponent>(uid);
|
||||
var component = EntityManager.GetComponent<PredictionTestComponent>(uid);
|
||||
var old = component.Foo;
|
||||
if (Allow)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public sealed class TileConstructionTests : InteractionTest
|
||||
await SetTile(null);
|
||||
await InteractUsing(Rod);
|
||||
await AssertTile(Lattice);
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
await InteractUsing(Cut);
|
||||
await AssertTile(null);
|
||||
await AssertEntityLookup((Rod, 1));
|
||||
@@ -49,7 +49,7 @@ public sealed class TileConstructionTests : InteractionTest
|
||||
AssertGridCount(1);
|
||||
|
||||
// Cut lattice
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
await InteractUsing(Cut);
|
||||
await AssertTile(null);
|
||||
AssertGridCount(0);
|
||||
@@ -83,13 +83,13 @@ public sealed class TileConstructionTests : InteractionTest
|
||||
|
||||
// Lattice -> Plating
|
||||
await InteractUsing(FloorItem);
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
await AssertTile(Plating);
|
||||
AssertGridCount(1);
|
||||
|
||||
// Plating -> Tile
|
||||
await InteractUsing(FloorItem);
|
||||
Assert.That(HandSys.GetActiveItem((SEntMan.GetEntity(Player), Hands)), Is.Null);
|
||||
Assert.That(Hands.ActiveHandEntity, Is.Null);
|
||||
await AssertTile(Floor);
|
||||
AssertGridCount(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user