mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-06-09 13:26:34 +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.
83 lines
3.3 KiB
C#
83 lines
3.3 KiB
C#
using Content.IntegrationTests.Fixtures;
|
|
using Content.IntegrationTests.Utility;
|
|
using Content.Server.DeviceLinking.Systems;
|
|
using Content.Shared.DeviceLinking;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Content.IntegrationTests.Tests.DeviceLinking;
|
|
|
|
public sealed class DeviceLinkingTest : GameTest
|
|
{
|
|
private const string PortTesterProtoId = "DeviceLinkingSinkPortTester";
|
|
|
|
[TestPrototypes]
|
|
private const string Prototypes = $@"
|
|
- type: entity
|
|
id: {PortTesterProtoId}
|
|
components:
|
|
- type: DeviceLinkSource
|
|
ports:
|
|
- Output
|
|
";
|
|
|
|
private static string[] _entitiesWithDeviceLinkSink = GameDataScrounger.EntitiesWithComponent("DeviceLinkSink");
|
|
|
|
[Test]
|
|
[TestOf(typeof(DeviceLinkSinkComponent))]
|
|
[TestCaseSource(nameof(_entitiesWithDeviceLinkSink))]
|
|
[Description("Ensures all devices that can sink signals will not cause exceptions when signaled.")]
|
|
public async Task DeviceLinkSinkAllPortsTest(string protoKey)
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
var protoMan = server.ProtoMan;
|
|
var compFact = server.ResolveDependency<IComponentFactory>();
|
|
var mapMan = server.ResolveDependency<IMapManager>();
|
|
var mapSys = server.System<SharedMapSystem>();
|
|
var deviceLinkSys = server.System<DeviceLinkSystem>();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
var proto = protoMan.Index(protoKey);
|
|
Assert.That(proto.TryGetComponent<DeviceLinkSinkComponent>(out var protoSinkComp, compFact));
|
|
|
|
foreach (var port in protoSinkComp!.Ports)
|
|
{
|
|
// Create a map for each entity/port combo so they can't interfere
|
|
mapSys.CreateMap(out var mapId);
|
|
var grid = mapMan.CreateGridEntity(mapId);
|
|
mapSys.SetTile(grid.Owner, grid.Comp, Vector2i.Zero, new Tile(1));
|
|
var coord = new EntityCoordinates(grid.Owner, 0, 0);
|
|
|
|
// Spawn the sink entity
|
|
var sinkEnt = server.EntMan.SpawnEntity(proto.ID, coord);
|
|
// Get the actual sink component, since the one we got from the prototype isn't initialized.
|
|
var sinkComp = server.EntMan.GetComponent<DeviceLinkSinkComponent>(sinkEnt);
|
|
|
|
// Spawn the tester
|
|
var sourceEnt = server.EntMan.SpawnEntity(PortTesterProtoId, coord);
|
|
var sourceComp = server.EntMan.GetComponent<DeviceLinkSourceComponent>(sourceEnt);
|
|
|
|
// Create a link from the tester's output to the target port on the sink
|
|
deviceLinkSys.SaveLinks(null,
|
|
sourceEnt,
|
|
sinkEnt,
|
|
[("Output", port.Id)],
|
|
sourceComp,
|
|
sinkComp);
|
|
|
|
// Send a signal to the port
|
|
Assert.DoesNotThrow(() => { deviceLinkSys.InvokePort(sourceEnt, "Output", null, sourceComp); },
|
|
$"Exception thrown while triggering port {port.Id} of the sink device.");
|
|
|
|
mapSys.DeleteMap(mapId);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|