From 02568c6c7743a92f750b58ae5228f92aaa94a478 Mon Sep 17 00:00:00 2001 From: Gnomeev Date: Fri, 28 Feb 2025 19:37:19 +0300 Subject: [PATCH] map fax communcation --- Content.Server/Fax/FaxSystem.cs | 4 ++-- .../GameTicking/Rules/NukeopsRuleSystem.cs | 19 +++++++++++++++---- .../Fax/Components/FaxMachineComponent.cs | 17 +++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Content.Server/Fax/FaxSystem.cs b/Content.Server/Fax/FaxSystem.cs index 11bb944940f9..3d5e54d1ee6e 100644 --- a/Content.Server/Fax/FaxSystem.cs +++ b/Content.Server/Fax/FaxSystem.cs @@ -422,7 +422,7 @@ public void Send(EntityUid uid, FaxMachineComponent? component, FaxSendMessage a //ss220 autogamma update var faxEvent = new FaxSendAttemptEvent(uid, component.DestinationFaxAddress, component.FaxName); - RaiseLocalEvent(ref faxEvent); + RaiseLocalEvent(faxEvent); if (faxEvent.Cancelled) { _popupSystem.PopupEntity(Loc.GetString("fax-machine-popup-copy-error"), uid, PopupType.SmallCaution); @@ -430,7 +430,7 @@ public void Send(EntityUid uid, FaxMachineComponent? component, FaxSendMessage a } //ss220 autogamma update - TryComp(sendEntity, out var nameMod); + TryComp(sendEntity, out var nameMod); //ss220 autogamma update TryComp(sendEntity, out var labelComponent); var payload = new NetworkPayload() diff --git a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs index 698998f390c4..b45faa4bda6f 100644 --- a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs @@ -31,6 +31,7 @@ using Content.Server.Maps; using Content.Server.Station.Systems; using Content.Shared.Fax.Components; +using Content.Server.DeviceNetwork.Components; namespace Content.Server.GameTicking.Rules; @@ -292,19 +293,29 @@ private void OnRuleLoadedGrids(Entity ent, ref RuleLoadedG } //ss220 autogamma update - private void OnFaxSendAttemptEvent(ref FaxSendAttemptEvent ev) + private void OnFaxSendAttemptEvent(FaxSendAttemptEvent ev) { - var query = EntityQueryEnumerator(); - while (query.MoveNext(out _, out _, out var nukeops)) + var faxQuery = EntityQueryEnumerator(); + while (faxQuery.MoveNext(out var uid, out _, out var deviceNetwork)) + { + //we still want to to communicate by fax within the map + if (ev.DestinationFaxAddress == deviceNetwork.Address && + Transform(uid).MapUid == Transform(ev.FaxEnt).MapUid) + return; + } + + var nukeQuery = EntityQueryEnumerator(); + while (nukeQuery.MoveNext(out _, out _, out var nukeops)) { if (nukeops is { WarDeclaredTime: not null }) { var warTime = Timing.CurTime.Subtract(nukeops.WarDeclaredTime.Value); if (warTime < nukeops.WarFaxDisabled) { + var nukeShuttle = Transform(ev.FaxEnt).GridUid; if (!HasComp(nukeShuttle)) // spam to captain from nukeops shuttle muhaha - ev.Cancelled = true; + ev.Cancel(); return; } diff --git a/Content.Shared/Fax/Components/FaxMachineComponent.cs b/Content.Shared/Fax/Components/FaxMachineComponent.cs index 299b70746bc0..2b01caac0d75 100644 --- a/Content.Shared/Fax/Components/FaxMachineComponent.cs +++ b/Content.Shared/Fax/Components/FaxMachineComponent.cs @@ -168,12 +168,17 @@ public FaxPrintout(Dictionary? dataToCopy, Phot } //ss220 autogamma update -[ByRefEvent] -public record struct FaxSendAttemptEvent(EntityUid FaxEnt, string DestinationFaxAddress, string SenderFaxAddress) +public sealed class FaxSendAttemptEvent : CancellableEntityEventArgs { - public bool Cancelled = false; - public EntityUid FaxEnt = FaxEnt; - public string DestinationFaxAddress = DestinationFaxAddress; - public string SenderFaxAddress = SenderFaxAddress; + public EntityUid FaxEnt; + public string DestinationFaxAddress; + public string SenderFaxAddress; + + public FaxSendAttemptEvent(EntityUid faxEnt, string destinationFaxAddress, string senderFaxAddress) + { + FaxEnt = faxEnt; + DestinationFaxAddress = destinationFaxAddress; + SenderFaxAddress = senderFaxAddress; + } } //ss220 autogamma update