mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21: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
129 lines
4.7 KiB
C#
129 lines
4.7 KiB
C#
using Content.Server.DeviceLinking.Components;
|
|
using Content.Server.Doors.Systems;
|
|
using Content.Shared.DeviceLinking;
|
|
using Content.Shared.DeviceLinking.Events;
|
|
using Content.Shared.Doors.Components;
|
|
using Content.Shared.Doors;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.DeviceLinking.Systems
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed partial class DoorSignalControlSystem : EntitySystem
|
|
{
|
|
[Dependency] private DoorSystem _doorSystem = default!;
|
|
[Dependency] private DeviceLinkSystem _signalSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<DoorSignalControlComponent, ComponentInit>(OnInit);
|
|
SubscribeLocalEvent<DoorSignalControlComponent, SignalReceivedEvent>(OnSignalReceived);
|
|
SubscribeLocalEvent<DoorSignalControlComponent, DoorStateChangedEvent>(OnStateChanged);
|
|
}
|
|
|
|
private void OnInit(EntityUid uid, DoorSignalControlComponent component, ComponentInit args)
|
|
{
|
|
|
|
_signalSystem.EnsureSinkPorts(uid, component.OpenPort, component.ClosePort, component.TogglePort);
|
|
_signalSystem.EnsureSourcePorts(uid, component.OutOpen);
|
|
}
|
|
|
|
private void OnSignalReceived(EntityUid uid, DoorSignalControlComponent component, ref SignalReceivedEvent args)
|
|
{
|
|
if (!TryComp(uid, out DoorComponent? door))
|
|
return;
|
|
|
|
if (args.Port == component.OpenPort)
|
|
{
|
|
if (door.State == DoorState.Closed)
|
|
_doorSystem.TryOpen(uid, door);
|
|
}
|
|
else if (args.Port == component.ClosePort)
|
|
{
|
|
if (door.State == DoorState.Open)
|
|
_doorSystem.TryClose(uid, door);
|
|
}
|
|
else if (args.Port == component.TogglePort)
|
|
{
|
|
_doorSystem.TryToggleDoor(uid, door);
|
|
}
|
|
else if (args.Port == component.InBolt)
|
|
{
|
|
if (!TryComp<DoorBoltComponent>(uid, out var bolts))
|
|
return;
|
|
|
|
// if its a pulse toggle, otherwise set bolts to high/low
|
|
var bolt = !bolts.BoltsDown;
|
|
_doorSystem.SetBoltsDown((uid, bolts), bolt);
|
|
}
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnSignalReceived(EntityUid uid, DoorSignalControlComponent component, ref SignalReceivedEvent<LogicStatePayload> args)
|
|
{
|
|
if (!TryComp(uid, out DoorComponent? door))
|
|
return;
|
|
|
|
var state = args.Data.State;
|
|
if (args.Port == component.OpenPort)
|
|
{
|
|
if (state == SignalState.High || state == SignalState.Momentary)
|
|
{
|
|
if (door.State == DoorState.Closed)
|
|
_doorSystem.TryOpen(uid, door);
|
|
}
|
|
}
|
|
else if (args.Port == component.ClosePort)
|
|
{
|
|
if (state == SignalState.High || state == SignalState.Momentary)
|
|
{
|
|
if (door.State == DoorState.Open)
|
|
_doorSystem.TryClose(uid, door);
|
|
}
|
|
}
|
|
else if (args.Port == component.TogglePort)
|
|
{
|
|
if (state == SignalState.High || state == SignalState.Momentary)
|
|
{
|
|
_doorSystem.TryToggleDoor(uid, door);
|
|
}
|
|
}
|
|
else if (args.Port == component.InBolt)
|
|
{
|
|
if (!TryComp<DoorBoltComponent>(uid, out var bolts))
|
|
return;
|
|
|
|
// if its a pulse toggle, otherwise set bolts to high/low
|
|
bool bolt;
|
|
if (state == SignalState.Momentary)
|
|
{
|
|
bolt = !bolts.BoltsDown;
|
|
}
|
|
else
|
|
{
|
|
bolt = state == SignalState.High;
|
|
}
|
|
|
|
_doorSystem.SetBoltsDown((uid, bolts), bolt);
|
|
}
|
|
}
|
|
|
|
private void OnStateChanged(EntityUid uid, DoorSignalControlComponent door, DoorStateChangedEvent args)
|
|
{
|
|
if (args.State == DoorState.Closed)
|
|
{
|
|
// only ever say the door is closed when it is completely airtight
|
|
_signalSystem.SendSignal(uid, door.OutOpen, false);
|
|
}
|
|
else if (args.State == DoorState.Open
|
|
|| args.State == DoorState.Opening
|
|
|| args.State == DoorState.Closing
|
|
|| args.State == DoorState.Emagging)
|
|
{
|
|
// say the door is open whenever it would be letting air pass
|
|
_signalSystem.SendSignal(uid, door.OutOpen, true);
|
|
}
|
|
}
|
|
}
|
|
}
|