CatStation/Content.Shared/Fax/Components/FaxMachineComponent.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

195 lines
5.7 KiB
C#

using Content.Shared.Containers.ItemSlots;
using Content.Shared.Paper;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Fax.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class FaxMachineComponent : Component
{
/// <summary>
/// Name with which the fax will be visible to others on the network
/// </summary>
[DataField("name")]
public string FaxName { get; set; } = "Unknown";
/// <summary>
/// Sprite to use when inserting an object.
/// </summary>
[DataField, AutoNetworkedField]
public string InsertingState = "inserting";
/// <summary>
/// Device address of fax in network to which data will be send
/// </summary>
[DataField("destinationAddress")]
public string? DestinationFaxAddress { get; set; }
/// <summary>
/// Name of fax in network to which data will be send
/// </summary>
[DataField("destinationName")]
public string? DestinationFaxName { get; set; }
/// <summary>
/// Contains the item to be sent, assumes it's paper...
/// </summary>
[DataField(required: true)]
public ItemSlot PaperSlot = new();
/// <summary>
/// Is fax machine should respond to pings in network
/// This will make it visible to others on the network
/// </summary>
[DataField]
public bool ResponsePings { get; set; } = true;
/// <summary>
/// Should admins be notified on message receive
/// </summary>
[DataField]
public bool NotifyAdmins { get; set; } = false;
/// <summary>
/// Should that fax receive nuke codes send by admins. Probably should be captain fax only
/// </summary>
[DataField]
public bool ReceiveNukeCodes { get; set; } = false;
/// <summary>
/// Sound to play when fax printing new message
/// </summary>
[DataField]
public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/printer.ogg");
/// <summary>
/// Sound to play when fax successfully send message
/// </summary>
[DataField]
public SoundSpecifier SendSound = new SoundPathSpecifier("/Audio/Machines/high_tech_confirm.ogg");
/// <summary>
/// Known faxes in network by address with fax names
/// </summary>
[ViewVariables]
public Dictionary<string, string> KnownFaxes { get; } = new();
/// <summary>
/// Print queue of the incoming message
/// </summary>
[ViewVariables]
[DataField]
public Queue<FaxPrintout> PrintingQueue { get; private set; } = new();
/// <summary>
/// Message sending timeout
/// </summary>
[ViewVariables]
[DataField]
public float SendTimeoutRemaining;
/// <summary>
/// Message sending timeout
/// </summary>
[ViewVariables]
[DataField]
public float SendTimeout = 5f;
/// <summary>
/// Remaining time of inserting animation
/// </summary>
[DataField]
public float InsertingTimeRemaining;
/// <summary>
/// How long the inserting animation will play
/// </summary>
[ViewVariables]
public float InsertionTime = 1.88f; // 0.02 off for correct animation
/// <summary>
/// Remaining time of printing animation
/// </summary>
[DataField]
public float PrintingTimeRemaining;
/// <summary>
/// How long the printing animation will play
/// </summary>
[ViewVariables]
public float PrintingTime = 2.3f;
/// <summary>
/// The prototype ID to use for faxed or copied entities if we can't get one from
/// the paper entity for whatever reason.
/// </summary>
[DataField]
public EntProtoId PrintPaperId = "Paper";
/// <summary>
/// The prototype ID to use for faxed or copied entities if we can't get one from
/// the paper entity for whatever reason of the Office type.
/// </summary>
[DataField]
public EntProtoId PrintOfficePaperId = "PaperOffice";
/// <summary>
/// If the fax machine should add a bit of text in the end of the fax that specifies from where and to where the fax is for
/// </summary>
[DataField]
public bool AddSenderInfo = true;
/// <summary>
/// The text that is sent along with the paper's content if <see cref="AddSenderInfo"/> is true
/// </summary>
[DataField]
public LocId SenderInfo = "fax-machine-sender-info";
}
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class FaxPrintout
{
[DataField(required: true)]
public string Name { get; private set; } = default!;
[DataField]
public string? Label { get; private set; }
[DataField(required: true)]
public string Content { get; private set; } = default!;
[DataField(required: true)]
public EntProtoId PrototypeId { get; private set; } = default!;
[DataField]
public string? StampState { get; private set; }
[DataField]
public List<StampDisplayInfo> StampedBy { get; private set; } = new();
[DataField]
public bool Locked { get; private set; }
[DataField]
public string? SenderFaxName { get; private set; } = default!;
private FaxPrintout()
{
}
public FaxPrintout(string content, string name, string? label = null, string? prototypeId = null, string? stampState = null, List<StampDisplayInfo>? stampedBy = null, bool locked = false, string? senderFaxName = null)
{
Content = content;
Name = name;
Label = label;
PrototypeId = prototypeId ?? "";
StampState = stampState;
StampedBy = stampedBy ?? new List<StampDisplayInfo>();
Locked = locked;
SenderFaxName = senderFaxName;
}
}