diff --git a/Content.Server/Corvax/StationGoal/StationGoalCommand.cs b/Content.Server/Corvax/StationGoal/StationGoalCommand.cs index 6c0a3c58ab2..6b7fe70ee9d 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalCommand.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalCommand.cs @@ -11,6 +11,7 @@ namespace Content.Server.Corvax.StationGoal public sealed class StationGoalCommand : IConsoleCommand { [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; public string Command => "sendstationgoal"; public string Description => Loc.GetString("send-station-goal-command-description"); @@ -31,15 +32,14 @@ public void Execute(IConsoleShell shell, string argStr, string[] args) } var protoId = args[1]; - var prototypeManager = IoCManager.Resolve(); - if (!prototypeManager.TryIndex(protoId, out var proto)) + if (!_prototypeManager.TryIndex(protoId, out var proto)) { shell.WriteError($"No station goal found with ID {protoId}!"); return; } - var stationGoalPaper = IoCManager.Resolve().System(); - if (!stationGoalPaper.SendStationGoal(euid, protoId)) + var stationGoalPaper = _entManager.System(); + if (!stationGoalPaper.SendStationGoal(euid.Value, protoId)) { shell.WriteError("Station goal was not sent"); return; @@ -52,9 +52,9 @@ public CompletionResult GetCompletion(IConsoleShell shell, string[] args) { case 1: var stations = ContentCompletionHelper.StationIds(_entManager); - return CompletionResult.FromHintOptions(stations, "[StationId]"); + return CompletionResult.FromHintOptions(stations, Loc.GetString("send-station-goal-command-arg-station")); case 2: - var options = IoCManager.Resolve() + var options = _prototypeManager .EnumeratePrototypes() .Select(p => new CompletionOption(p.ID)); diff --git a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs index 383c28bc261..15188d6b7d2 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs @@ -1,12 +1,8 @@ -using System.Linq; using Content.Server.Fax; using Content.Server.GameTicking.Events; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Corvax.CCCVars; using Content.Shared.Fax.Components; -using Content.Shared.GameTicking; -using Content.Shared.Paper; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; @@ -26,10 +22,8 @@ public sealed class StationGoalPaperSystem : EntitySystem [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; - public override void Initialize() { - base.Initialize(); SubscribeLocalEvent(OnRoundStarting); } @@ -71,7 +65,7 @@ private void OnRoundStarting(RoundStartingEvent ev) } } - public bool SendStationGoal(EntityUid? ent, ProtoId goal) + public bool SendStationGoal(EntityUid ent, ProtoId goal) { return SendStationGoal(ent, _proto.Index(goal)); } @@ -80,44 +74,32 @@ public bool SendStationGoal(EntityUid? ent, ProtoId goal) /// Send a station goal on selected station to all faxes which are authorized to receive it. /// /// True if at least one fax received paper - public bool SendStationGoal(EntityUid? ent, StationGoalPrototype goal) + public bool SendStationGoal(EntityUid ent, StationGoalPrototype goal) { - if (ent is null) - return false; - - if (!TryComp(ent, out var stationData)) - return false; - var printout = new FaxPrintout( - Loc.GetString(goal.Text, ("station", MetaData(ent.Value).EntityName)), + Loc.GetString(goal.Text, ("station", MetaData(ent).EntityName)), Loc.GetString("station-goal-fax-paper-name"), null, null, "paper_stamp-centcom", - new List - { - new() { StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), StampedColor = Color.FromHex("#006600") }, - }); + [new() { StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), StampedColor = Color.FromHex("#006600") }] + ); var wasSent = false; var query = EntityQueryEnumerator(); while (query.MoveNext(out var faxUid, out var fax)) { - if (!fax.ReceiveStationGoal) + if (!fax.ReceiveAllStationGoals && !(fax.ReceiveStationGoal && _station.GetOwningStation(faxUid) == ent)) continue; - var largestGrid = _station.GetLargestGrid(stationData); - var grid = Transform(faxUid).GridUid; - if (grid is not null && largestGrid == grid.Value) - { - _fax.Receive(faxUid, printout, null, fax); - foreach (var spawnEnt in goal.Spawns) - { - SpawnAtPosition(spawnEnt, Transform(faxUid).Coordinates); - } - wasSent = true; - } + _fax.Receive(faxUid, printout, null, fax); + + foreach (var spawnEnt in goal.Spawns) + SpawnAtPosition(spawnEnt, Transform(faxUid).Coordinates); + + wasSent |= fax.ReceiveStationGoal; } + return wasSent; } } diff --git a/Content.Shared/Fax/Components/FaxMachineComponent.cs b/Content.Shared/Fax/Components/FaxMachineComponent.cs index 6933401edf1..829781ca907 100644 --- a/Content.Shared/Fax/Components/FaxMachineComponent.cs +++ b/Content.Shared/Fax/Components/FaxMachineComponent.cs @@ -63,9 +63,14 @@ public sealed partial class FaxMachineComponent : Component /// /// Should that fax receive station goal info /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("receiveStationGoal")] - public bool ReceiveStationGoal { get; set; } = false; + [DataField] + public bool ReceiveStationGoal { get; set; } + + /// + /// Should that fax receive station goals from other stations + /// + [DataField] + public bool ReceiveAllStationGoals { get; set; } // Corvax-StationGoal-End /// diff --git a/Resources/Locale/ru-RU/corvax/station-goal/station-goal-command.ftl b/Resources/Locale/ru-RU/corvax/station-goal/station-goal-command.ftl index 0108153e319..02ab954f38b 100644 --- a/Resources/Locale/ru-RU/corvax/station-goal/station-goal-command.ftl +++ b/Resources/Locale/ru-RU/corvax/station-goal/station-goal-command.ftl @@ -1,3 +1,4 @@ send-station-goal-command-description = Отправляет выбранную цель станции на всех факсы способные её принять -send-station-goal-command-help-text = Использование: { $command } +send-station-goal-command-help-text = Использование: { $command } +send-station-goal-command-arg-station = send-station-goal-command-arg-id = diff --git a/Resources/Prototypes/Entities/Structures/Machines/fax_machine.yml b/Resources/Prototypes/Entities/Structures/Machines/fax_machine.yml index daf20fad3c6..ee137b3f045 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/fax_machine.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/fax_machine.yml @@ -84,7 +84,7 @@ - type: FaxMachine name: "Central Command" notifyAdmins: true - receiveStationGoal: true # Corvax-StationGoal + receiveAllStationGoals: true # Corvax-StationGoal - type: entity parent: FaxMachineBase