Cuffable/Handcuff ECS (#14382)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Cuffs.Components;
|
||||
using Content.Server.Cuffs;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Cuffs.Components;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -56,6 +56,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
var coordinates = new MapCoordinates(Vector2.Zero, mapId);
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var cuffableSys = entityManager.System<CuffableSystem>();
|
||||
|
||||
// Spawn the entities
|
||||
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
@@ -75,19 +76,19 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
Assert.True(entityManager.TryGetComponent(secondCuffs, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
||||
|
||||
// Test to ensure cuffed players register the handcuffs
|
||||
cuffed.TryAddNewCuffs(human, cuffs);
|
||||
cuffableSys.TryAddNewCuffs(human, human, cuffs, cuffed);
|
||||
Assert.True(cuffed.CuffedHandCount > 0,
|
||||
"Handcuffing a player did not result in their hands being cuffed");
|
||||
|
||||
// Test to ensure a player with 4 hands will still only have 2 hands cuffed
|
||||
AddHand(cuffed.Owner);
|
||||
AddHand(cuffed.Owner);
|
||||
AddHand(human);
|
||||
AddHand(human);
|
||||
|
||||
Assert.That(cuffed.CuffedHandCount, Is.EqualTo(2));
|
||||
Assert.That(hands.SortedHands.Count(), Is.EqualTo(4));
|
||||
Assert.That(hands.SortedHands.Count, Is.EqualTo(4));
|
||||
|
||||
// Test to give a player with 4 hands 2 sets of cuffs
|
||||
cuffed.TryAddNewCuffs(human, secondCuffs);
|
||||
cuffableSys.TryAddNewCuffs(human, human, secondCuffs, cuffed);
|
||||
Assert.True(cuffed.CuffedHandCount == 4, "Player doesn't have correct amount of hands cuffed");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user