CatStation/Content.Shared/DeviceNetwork/Components/DeviceNetworkComponent.cs
Rouden cc2c14f8e4
Device Network refactor part 1: API improvements (#44346)
* 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
2026-08-31 19:42:56 +00:00

107 lines
3.3 KiB
C#

using Content.Shared.DeviceNetwork.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.DeviceNetwork.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedDeviceNetworkSystem), typeof(DeviceNet))]
public sealed partial class DeviceNetworkComponent : Component
{
/// <summary>
/// Default device network ID to connect to.
/// </summary>
[DataField("deviceNetId")]
public DeviceNetIdDefaults NetIdEnum { get; set; }
public int DeviceNetId => (int) NetIdEnum;
/// <summary>
/// The frequency that this device is listening on.
/// </summary>
[DataField]
public uint? ReceiveFrequency;
/// <summary>
/// The address ID of the device, either on the network it is currently connected to or whatever address it
/// most recently used.
/// </summary>
[DataField]
public string Address = string.Empty;
/// <summary>
/// Whether the device should listen for all device messages, regardless of the intended recipient.
/// </summary>
[DataField]
public bool ReceiveAll;
/// <summary>
/// The frequency that this device going to try to transmit on.
/// </summary>
[DataField]
public uint? TransmitFrequency;
/// <summary>
/// Frequency prototype, used to select a default frequency to listen to on.
/// </summary>
[DataField]
public ProtoId<DeviceFrequencyPrototype>? ReceiveFrequencyId;
/// <summary>
/// Frequency prototype, used to select a default frequency to transmit on.
/// </summary>
[DataField]
public ProtoId<DeviceFrequencyPrototype>? TransmitFrequencyId;
/// <summary>
/// Whether to send the broadcast recipients list to the sender so it can be filtered.
/// </summary>
[DataField]
public bool SendBroadcastAttemptEvent;
/// <summary>
/// If the device should show its address upon an examine.
/// Useful for devices that do not have a visible UI.
/// </summary>
[DataField, AutoNetworkedField]
public bool ExaminableAddress;
/// <summary>
/// Prefix to prepend to any automatically generated addresses. Helps players to identify devices.
/// </summary>
[DataField]
public LocId? Prefix;
/// <summary>
/// Whether the device should attempt to join the network on map init.
/// </summary>
[DataField]
public bool AutoConnect = true;
/// <summary>
/// Whether this device's address can be saved to device-lists
/// </summary>
[DataField]
public bool SavableAddress = true;
/// <summary>
/// If true, the address was customized and should be preserved across networks. If false, a randomly
/// generated address will be created whenever this device connects to a network.
/// </summary>
[DataField]
public bool CustomAddress;
/// <summary>
/// A list of device-lists that this device is on.
/// </summary>
[DataField]
[Access(typeof(SharedDeviceListSystem))]
public HashSet<EntityUid> DeviceLists = new();
/// <summary>
/// A list of configurators that this device is on.
/// </summary>
[DataField]
[Access(typeof(SharedNetworkConfiguratorSystem))]
public HashSet<EntityUid> Configurators = new();
}