Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix station goals #3002

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Content.Server/Corvax/StationGoal/StationGoalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -31,15 +32,14 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
}

var protoId = args[1];
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
if (!prototypeManager.TryIndex<StationGoalPrototype>(protoId, out var proto))
if (!_prototypeManager.TryIndex<StationGoalPrototype>(protoId, out var proto))
{
shell.WriteError($"No station goal found with ID {protoId}!");
return;
}

var stationGoalPaper = IoCManager.Resolve<IEntityManager>().System<StationGoalPaperSystem>();
if (!stationGoalPaper.SendStationGoal(euid, protoId))
var stationGoalPaper = _entManager.System<StationGoalPaperSystem>();
if (!stationGoalPaper.SendStationGoal(euid.Value, protoId))
{
shell.WriteError("Station goal was not sent");
return;
Expand All @@ -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<IPrototypeManager>()
var options = _prototypeManager
.EnumeratePrototypes<StationGoalPrototype>()
.Select(p => new CompletionOption(p.ID));

Expand Down
44 changes: 13 additions & 31 deletions Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<RoundStartingEvent>(OnRoundStarting);
}

Expand Down Expand Up @@ -71,7 +65,7 @@ private void OnRoundStarting(RoundStartingEvent ev)
}
}

public bool SendStationGoal(EntityUid? ent, ProtoId<StationGoalPrototype> goal)
public bool SendStationGoal(EntityUid ent, ProtoId<StationGoalPrototype> goal)
{
return SendStationGoal(ent, _proto.Index(goal));
}
Expand All @@ -80,44 +74,32 @@ public bool SendStationGoal(EntityUid? ent, ProtoId<StationGoalPrototype> goal)
/// Send a station goal on selected station to all faxes which are authorized to receive it.
/// </summary>
/// <returns>True if at least one fax received paper</returns>
public bool SendStationGoal(EntityUid? ent, StationGoalPrototype goal)
public bool SendStationGoal(EntityUid ent, StationGoalPrototype goal)
{
if (ent is null)
return false;

if (!TryComp<StationDataComponent>(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<StampDisplayInfo>
{
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<FaxMachineComponent>();
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;
}
}
Expand Down
11 changes: 8 additions & 3 deletions Content.Shared/Fax/Components/FaxMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ public sealed partial class FaxMachineComponent : Component
/// <summary>
/// Should that fax receive station goal info
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("receiveStationGoal")]
public bool ReceiveStationGoal { get; set; } = false;
[DataField]
public bool ReceiveStationGoal { get; set; }

/// <summary>
/// Should that fax receive station goals from other stations
/// </summary>
[DataField]
public bool ReceiveAllStationGoals { get; set; }
// Corvax-StationGoal-End

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
send-station-goal-command-description = Отправляет выбранную цель станции на всех факсы способные её принять
send-station-goal-command-help-text = Использование: { $command } <id-цели>
send-station-goal-command-help-text = Использование: { $command } <entityuid-станции> <id-цели>
send-station-goal-command-arg-station = <EntityUid станции>
send-station-goal-command-arg-id = <ID цели>
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
- type: FaxMachine
name: "Central Command"
notifyAdmins: true
receiveStationGoal: true # Corvax-StationGoal
receiveAllStationGoals: true # Corvax-StationGoal

- type: entity
parent: FaxMachineBase
Expand Down
Loading