From c091acd1f5f85d1591ac78e72f353a675d8cc52f Mon Sep 17 00:00:00 2001 From: CaasGit <87243814+CaasGit@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:54:08 -0700 Subject: [PATCH] add(FaxComponent): Allows for setting defaults in the component. (#30484) * add(FaxComponent): Allows for setting defaults in the component. This wires up the Fax component to allow the default paper and office paper to be set. The defaults are what they were before, and it's an optional option. Now Fax machines can be set to print different paper when using Print File or other cases where the default paper style is used. * Requested change to EntProtoId. * Fix build failure. --- Content.Server/Fax/FaxSystem.cs | 38 +++++++------------ .../Fax/Components/FaxMachineComponent.cs | 14 +++++++ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Content.Server/Fax/FaxSystem.cs b/Content.Server/Fax/FaxSystem.cs index 3f10e180fe..18852ac755 100644 --- a/Content.Server/Fax/FaxSystem.cs +++ b/Content.Server/Fax/FaxSystem.cs @@ -52,16 +52,6 @@ public sealed class FaxSystem : EntitySystem private const string PaperSlotId = "Paper"; - /// - /// The prototype ID to use for faxed or copied entities if we can't get one from - /// the paper entity for whatever reason. - /// - [ValidatePrototypeId] - private const string DefaultPaperPrototypeId = "Paper"; - - [ValidatePrototypeId] - private const string OfficePaperPrototypeId = "PaperOffice"; - public override void Initialize() { base.Initialize(); @@ -242,7 +232,8 @@ public sealed class FaxSystem : EntitySystem return; } - _adminLogger.Add(LogType.Action, LogImpact.Low, + _adminLogger.Add(LogType.Action, + LogImpact.Low, $"{ToPrettyString(args.User):user} renamed {ToPrettyString(uid):tool} from \"{component.FaxName}\" to \"{newName}\""); component.FaxName = newName; _popupSystem.PopupEntity(Loc.GetString("fax-machine-popup-name-set"), uid); @@ -324,7 +315,7 @@ public sealed class FaxSystem : EntitySystem private void OnCopyButtonPressed(EntityUid uid, FaxMachineComponent component, FaxCopyMessage args) { if (HasComp(component.PaperSlot.Item)) - _faxecute.Faxecute(uid, component); /// when button pressed it will hurt the mob. + _faxecute.Faxecute(uid, component); // when button pressed it will hurt the mob. else Copy(uid, component, args); } @@ -332,7 +323,7 @@ public sealed class FaxSystem : EntitySystem private void OnSendButtonPressed(EntityUid uid, FaxMachineComponent component, FaxSendMessage args) { if (HasComp(component.PaperSlot.Item)) - _faxecute.Faxecute(uid, component); /// when button pressed it will hurt the mob. + _faxecute.Faxecute(uid, component); // when button pressed it will hurt the mob. else Send(uid, component, args); } @@ -425,11 +416,7 @@ public sealed class FaxSystem : EntitySystem /// public void PrintFile(EntityUid uid, FaxMachineComponent component, FaxFileMessage args) { - string prototype; - if (args.OfficePaper) - prototype = OfficePaperPrototypeId; - else - prototype = DefaultPaperPrototypeId; + var prototype = args.OfficePaper ? component.PrintOfficePaperId : component.PrintPaperId; var name = Loc.GetString("fax-machine-printed-paper-name"); @@ -441,7 +428,8 @@ public sealed class FaxSystem : EntitySystem // Unfortunately, since a paper entity does not yet exist, we have to emulate what LabelSystem will do. var nameWithLabel = (args.Label is { } label) ? $"{name} ({label})" : name; - _adminLogger.Add(LogType.Action, LogImpact.Low, + _adminLogger.Add(LogType.Action, + LogImpact.Low, $"{ToPrettyString(args.Actor):actor} " + $"added print job to \"{component.FaxName}\" {ToPrettyString(uid):tool} " + $"of {nameWithLabel}: {args.Content}"); @@ -471,7 +459,7 @@ public sealed class FaxSystem : EntitySystem var printout = new FaxPrintout(paper.Content, nameMod?.BaseName ?? metadata.EntityName, labelComponent?.CurrentLabel, - metadata.EntityPrototype?.ID ?? DefaultPaperPrototypeId, + metadata.EntityPrototype?.ID ?? component.PrintPaperId, paper.StampState, paper.StampedBy, paper.EditingDisabled); @@ -484,7 +472,8 @@ public sealed class FaxSystem : EntitySystem UpdateUserInterface(uid, component); - _adminLogger.Add(LogType.Action, LogImpact.Low, + _adminLogger.Add(LogType.Action, + LogImpact.Low, $"{ToPrettyString(args.Actor):actor} " + $"added copy job to \"{component.FaxName}\" {ToPrettyString(uid):tool} " + $"of {ToPrettyString(sendEntity):subject}: {printout.Content}"); @@ -531,7 +520,7 @@ public sealed class FaxSystem : EntitySystem // TODO: Ideally, we could just make a copy of the whole entity when it's // faxed, in order to preserve visuals, etc.. This functionality isn't // available yet, so we'll pass along the originating prototypeId and fall - // back to DefaultPaperPrototypeId in SpawnPaperFromQueue if we can't find one here. + // back to component.PrintPaperId in SpawnPaperFromQueue if we can't find one here. payload[FaxConstants.FaxPaperPrototypeData] = metadata.EntityPrototype.ID; } @@ -543,7 +532,8 @@ public sealed class FaxSystem : EntitySystem _deviceNetworkSystem.QueuePacket(uid, component.DestinationFaxAddress, payload); - _adminLogger.Add(LogType.Action, LogImpact.Low, + _adminLogger.Add(LogType.Action, + LogImpact.Low, $"{ToPrettyString(args.Actor):actor} " + $"sent fax from \"{component.FaxName}\" {ToPrettyString(uid):tool} " + $"to \"{faxName}\" ({component.DestinationFaxAddress}) " + @@ -585,7 +575,7 @@ public sealed class FaxSystem : EntitySystem var printout = component.PrintingQueue.Dequeue(); - var entityToSpawn = printout.PrototypeId.Length == 0 ? DefaultPaperPrototypeId : printout.PrototypeId; + var entityToSpawn = printout.PrototypeId.Length == 0 ? component.PrintPaperId.ToString() : printout.PrototypeId; var printed = EntityManager.SpawnEntity(entityToSpawn, Transform(uid).Coordinates); if (TryComp(printed, out var paper)) diff --git a/Content.Shared/Fax/Components/FaxMachineComponent.cs b/Content.Shared/Fax/Components/FaxMachineComponent.cs index 1c08986508..161c878e27 100644 --- a/Content.Shared/Fax/Components/FaxMachineComponent.cs +++ b/Content.Shared/Fax/Components/FaxMachineComponent.cs @@ -127,6 +127,20 @@ public sealed partial class FaxMachineComponent : Component /// [ViewVariables] public float PrintingTime = 2.3f; + + /// + /// The prototype ID to use for faxed or copied entities if we can't get one from + /// the paper entity for whatever reason. + /// + [DataField] + public EntProtoId PrintPaperId = "Paper"; + + /// + /// 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. + /// + [DataField] + public EntProtoId PrintOfficePaperId = "PaperOffice"; } [DataDefinition]