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
95 lines
3.7 KiB
C#
95 lines
3.7 KiB
C#
using Content.Shared.TextScreen;
|
|
using Content.Server.Screens.Components;
|
|
using Content.Shared.DeviceNetwork.Events;
|
|
using Content.Shared.RoundEnd;
|
|
using Content.Shared.Screens;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server.Screens.Systems;
|
|
|
|
/// <summary>
|
|
/// Controls the wallmounted screens on stations and shuttles displaying e.g. FTL duration, ETA
|
|
/// </summary>
|
|
public sealed partial class ScreenSystem : EntitySystem
|
|
{
|
|
[Dependency] private IGameTiming _gameTiming = default!;
|
|
[Dependency] private SharedAppearanceSystem _appearanceSystem = default!;
|
|
|
|
/// <summary>
|
|
/// Send a text update to every screen on the same MapUid as the originating comms console.
|
|
/// </summary>
|
|
[SubscribeLocalEvent]
|
|
private void OnScreenText(Entity<ScreenComponent> ent, ref DeviceNetworkPacketEvent<ScreenTextPayload> args)
|
|
{
|
|
var text = args.Data.Text;
|
|
// don't allow text updates if there's an active timer
|
|
// (and just check here so the server doesn't have to track them)
|
|
if (_appearanceSystem.TryGetData(ent, TextScreenVisuals.TargetTime, out TimeSpan target)
|
|
&& target > _gameTiming.CurTime)
|
|
return;
|
|
|
|
var screenMap = Transform(ent).MapUid;
|
|
var argsMap = Transform(args.Sender).MapUid;
|
|
|
|
if (screenMap == null
|
|
|| argsMap == null
|
|
|| screenMap != argsMap
|
|
|| text == null)
|
|
return;
|
|
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.DefaultText, text);
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.ScreenText, text);
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.ScreenTextTime, _gameTiming.CurTime);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines if/how a timer packet affects this screen.
|
|
/// Currently there are 2 broadcast domains: Arrivals, and every other screen.
|
|
/// Domain is determined by the <see cref="DeviceNetworkComponent.TransmitFrequencyId"/> on each timer.
|
|
/// Each broadcast domain is divided into subnets. Screen MapUid determines subnet.
|
|
/// Subnets are the shuttle, source, and dest. Source/dest change each jump.
|
|
/// This is required to send different timers to the shuttle/terminal/station.
|
|
/// </summary>
|
|
[SubscribeLocalEvent]
|
|
private void OnShuttleTimer(Entity<ScreenComponent> ent, ref DeviceNetworkPacketEvent<ScreenShuttlePayload> args)
|
|
{
|
|
var payload = args.Data;
|
|
var timerXform = Transform(ent);
|
|
|
|
// no false positives.
|
|
if (timerXform.MapUid == null)
|
|
return;
|
|
|
|
string? text = null;
|
|
TimeSpan time;
|
|
|
|
switch (timerXform.MapUid)
|
|
{
|
|
// sometimes the timer transforms on FTL shuttles have a hyperspace mapent, so matching by grid works as a fallback.
|
|
case var local when local == payload.Shuttle || timerXform.GridUid == payload.Shuttle:
|
|
time = payload.ShuttleTime;
|
|
break;
|
|
case var origin when origin == payload.SourceMap:
|
|
time = payload.SourceTime;
|
|
break;
|
|
case var remote when remote == payload.DestinationMap:
|
|
time = payload.DestinationTime;
|
|
text = ShuttleTimerMasks.ETA;
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
if (payload.OverrideText != null)
|
|
text = payload.OverrideText;
|
|
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.TargetTime, _gameTiming.CurTime + time);
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.ScreenTextTime, _gameTiming.CurTime);
|
|
|
|
if (text != null)
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.ScreenText, text);
|
|
|
|
if (payload.OverrideColor != null)
|
|
_appearanceSystem.SetData(ent, TextScreenVisuals.Color, payload.OverrideColor);
|
|
}
|
|
}
|