mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* Refactor DeviceNetwork * Singleton * NetworkPayloads refactor * Reorganize DeviceNetworkSystem * Surveillance cameras * Fix code * Fix build * Fix test fail by rewriting entire singleton logic * Properly predict examine * Update DeviceNetworkSystem.API.cs * Update EntityTest.cs * Update DeviceNetworkSystem.cs * Alright I'll do this expensive check fine * Fix disposals debug assert * Implement device network static events support * Use frozen dictionaries for performance * Update SharedDeviceNetworkSystem.Payloads.cs * Parallel payload handling support * Fix some spagetti-code * Optimize NetworkPayload cancellation * Parallel payloads are now cancellable * Fix screens * Fix robotics console * Allow new methods for shared * Mail fix * Turret fix * Fix network system method usage + signal and borg fix * finally fix atmos devices OH MY GOOOD * Remove stupid parallelism from fax * Fix surveiollance cameras * Working on a single thing for 2 days straight award * Fix the test? * Update units.yml * Add IDevice interface because why not * Add more device network suffixes * Fix camera router failing test * yaml linter peak * Improve docs for DeviceNetworkHandlers * fix build * Update CartridgeLoaderSystem.Relay.cs * Remove parallel system and EntitySystem post init * Add more docs and also events * Remove unnecessary caching * Update DevicePayloadComponentSystem.cs * Back to entity events * Implement DeviceData * Remove serializable from payloads * Update DeviceData.cs * Add a prototype for a singleton * Fix tests * Fix air alarms * Update DeviceNetworkSystem.cs * Fix cameras * Make camera router event-less * Fix atmos sync payloads, add more docs * Remove singleton + instant packets * oops remove public access * Fix tests? * Why the hell overload effect makes puddle sparks * Apparently it was redundant * Update gates.yml * Finish documentation * Review * Mark relay properties as obsolete * Struct payloads support (#blazinglyfastmemorysafe) * Update DeviceNetworkTest.cs * Make device structs stuff better * Move address prefix to DeviceNetworkComponent * Locale fixes * Fix tests * Doesn't know boolean logic award * Update AtmosAlarmableSystem.cs * Fix address predicted examine * Partial fix to air alarmables * Fix deployable turrets UI * Fix firelocks, maybe * Apparently Activatable UI was enough lol * Fix surveillance cameras * Rename `QueuePacket` into `SendPacket` * Simplify DeviceData as much as possible * Update DeviceData.cs * Update FaxMachineComponent.cs * Remove DeviceData because its stupid * Update ScreenSystem.cs * Fix build (camera map broken still) * Fix map * fix usings * Review changes * Build fix
81 lines
3.2 KiB
C#
81 lines
3.2 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 mapSys = server.System<SharedMapSystem>();
|
|
var deviceLinkSys = server.System<DeviceLinkSystem>();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
var proto = protoMan.Index(protoKey);
|
|
Assert.That(proto.TryComp<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 = mapSys.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, sourceComp), "Output"); },
|
|
$"Exception thrown while triggering port {port.Id} of the sink device.");
|
|
|
|
mapSys.DeleteMap(mapId);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|