mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-06-09 10:06:43 +02:00
d42adbf05d
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
110 lines
4.0 KiB
C#
110 lines
4.0 KiB
C#
#nullable enable
|
|
using Content.IntegrationTests.Fixtures;
|
|
using Content.Server.Cuffs;
|
|
using Content.Shared.Cuffs.Components;
|
|
using Content.Shared.Hands.Components;
|
|
using Robust.Server.Console;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(CuffableComponent))]
|
|
[TestOf(typeof(HandcuffComponent))]
|
|
public sealed class HandCuffTest : GameTest
|
|
{
|
|
[TestPrototypes]
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
name: HumanHandcuffDummy
|
|
id: HumanHandcuffDummy
|
|
components:
|
|
- type: Cuffable
|
|
- type: Hands
|
|
hands:
|
|
hand_right:
|
|
location: Right
|
|
hand_left:
|
|
location: Left
|
|
sortedHands:
|
|
- hand_right
|
|
- hand_left
|
|
- type: ComplexInteraction
|
|
|
|
- type: entity
|
|
name: HandcuffsDummy
|
|
id: HandcuffsDummy
|
|
components:
|
|
- type: Handcuff
|
|
";
|
|
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
|
|
EntityUid human;
|
|
EntityUid otherHuman;
|
|
EntityUid cuffs;
|
|
EntityUid secondCuffs;
|
|
CuffableComponent cuffed = default!;
|
|
HandsComponent hands = default!;
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
var host = server.ResolveDependency<IServerConsoleHost>();
|
|
|
|
var map = await pair.CreateTestMap();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var coordinates = map.MapCoords;
|
|
|
|
var cuffableSys = entityManager.System<CuffableSystem>();
|
|
var xformSys = entityManager.System<SharedTransformSystem>();
|
|
|
|
// Spawn the entities
|
|
human = entityManager.SpawnEntity("HumanHandcuffDummy", coordinates);
|
|
otherHuman = entityManager.SpawnEntity("HumanHandcuffDummy", coordinates);
|
|
cuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
|
|
secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
|
|
|
|
var coords = xformSys.GetWorldPosition(otherHuman);
|
|
xformSys.SetWorldPosition(human, coords);
|
|
|
|
// Test for components existing
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(entityManager.TryGetComponent(human, out cuffed!), $"Human has no {nameof(CuffableComponent)}");
|
|
Assert.That(entityManager.TryGetComponent(human, out hands!), $"Human has no {nameof(HandsComponent)}");
|
|
Assert.That(entityManager.TryGetComponent(cuffs, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
|
|
Assert.That(entityManager.TryGetComponent(secondCuffs, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
|
});
|
|
|
|
// Test to ensure cuffed players register the handcuffs
|
|
cuffableSys.TryAddNewCuffs(human, human, cuffs, cuffed);
|
|
Assert.That(cuffed.CuffedHandCount, Is.GreaterThan(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(entityManager.GetNetEntity(human), host);
|
|
AddHand(entityManager.GetNetEntity(human), host);
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(cuffed.CuffedHandCount, Is.EqualTo(2));
|
|
Assert.That(hands.SortedHands, Has.Count.EqualTo(4));
|
|
});
|
|
|
|
// Test to give a player with 4 hands 2 sets of cuffs
|
|
cuffableSys.TryAddNewCuffs(human, human, secondCuffs, cuffed);
|
|
Assert.That(cuffed.CuffedHandCount, Is.EqualTo(4), "Player doesn't have correct amount of hands cuffed");
|
|
});
|
|
}
|
|
|
|
private static void AddHand(NetEntity to, IServerConsoleHost host)
|
|
{
|
|
host.ExecuteCommand(null, $"addhand {to}");
|
|
}
|
|
}
|
|
}
|