NukeOps start with either station codes or their codes (#14025)
* NukeOps start with all nuke codes * make it pick a random code * clarify this
This commit is contained in:
@@ -7,5 +7,12 @@ namespace Content.Server.Nuke
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class NukeCodePaperComponent : Component
|
public sealed class NukeCodePaperComponent : Component
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not paper will contain a code for a nuke on the same
|
||||||
|
/// station as the paper, or if it will get a random code from all
|
||||||
|
/// possible nukes.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("allNukesAvailable")]
|
||||||
|
public bool AllNukesAvailable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
using Content.Server.Fax;
|
using Content.Server.Fax;
|
||||||
using Content.Server.Paper;
|
using Content.Server.Paper;
|
||||||
using Content.Server.Station.Components;
|
using Content.Server.Station.Components;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.Nuke
|
namespace Content.Server.Nuke
|
||||||
{
|
{
|
||||||
public sealed class NukeCodePaperSystem : EntitySystem
|
public sealed class NukeCodePaperSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||||
[Dependency] private readonly StationSystem _station = default!;
|
[Dependency] private readonly StationSystem _station = default!;
|
||||||
[Dependency] private readonly PaperSystem _paper = default!;
|
[Dependency] private readonly PaperSystem _paper = default!;
|
||||||
@@ -23,12 +27,15 @@ namespace Content.Server.Nuke
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, NukeCodePaperComponent component, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, NukeCodePaperComponent component, MapInitEvent args)
|
||||||
{
|
{
|
||||||
SetupPaper(uid);
|
SetupPaper(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupPaper(EntityUid uid, EntityUid? station = null)
|
private void SetupPaper(EntityUid uid, NukeCodePaperComponent? component = null, EntityUid? station = null)
|
||||||
{
|
{
|
||||||
if (TryGetRelativeNukeCode(uid, out var paperContent, station))
|
if (!Resolve(uid, ref component))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (TryGetRelativeNukeCode(uid, out var paperContent, station, onlyCurrentStation: component.AllNukesAvailable))
|
||||||
{
|
{
|
||||||
_paper.SetContent(uid, paperContent);
|
_paper.SetContent(uid, paperContent);
|
||||||
}
|
}
|
||||||
@@ -45,11 +52,11 @@ namespace Content.Server.Nuke
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var faxes = EntityManager.EntityQuery<FaxMachineComponent>();
|
var faxes = EntityQueryEnumerator<FaxMachineComponent>();
|
||||||
var wasSent = false;
|
var wasSent = false;
|
||||||
foreach (var fax in faxes)
|
while (faxes.MoveNext(out var faxEnt, out var fax))
|
||||||
{
|
{
|
||||||
if (!fax.ReceiveNukeCodes || !TryGetRelativeNukeCode(fax.Owner, out var paperContent, station))
|
if (!fax.ReceiveNukeCodes || !TryGetRelativeNukeCode(faxEnt, out var paperContent, station))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -60,7 +67,7 @@ namespace Content.Server.Nuke
|
|||||||
null,
|
null,
|
||||||
"paper_stamp-cent",
|
"paper_stamp-cent",
|
||||||
new() { Loc.GetString("stamp-component-stamped-name-centcom") });
|
new() { Loc.GetString("stamp-component-stamped-name-centcom") });
|
||||||
_faxSystem.Receive(fax.Owner, printout, null, fax);
|
_faxSystem.Receive(faxEnt, printout, null, fax);
|
||||||
|
|
||||||
wasSent = true;
|
wasSent = true;
|
||||||
}
|
}
|
||||||
@@ -78,7 +85,8 @@ namespace Content.Server.Nuke
|
|||||||
EntityUid uid,
|
EntityUid uid,
|
||||||
[NotNullWhen(true)] out string? nukeCode,
|
[NotNullWhen(true)] out string? nukeCode,
|
||||||
EntityUid? station = null,
|
EntityUid? station = null,
|
||||||
TransformComponent? transform = null)
|
TransformComponent? transform = null,
|
||||||
|
bool onlyCurrentStation = false)
|
||||||
{
|
{
|
||||||
nukeCode = null;
|
nukeCode = null;
|
||||||
if (!Resolve(uid, ref transform))
|
if (!Resolve(uid, ref transform))
|
||||||
@@ -88,20 +96,28 @@ namespace Content.Server.Nuke
|
|||||||
|
|
||||||
var owningStation = station ?? _station.GetOwningStation(uid);
|
var owningStation = station ?? _station.GetOwningStation(uid);
|
||||||
|
|
||||||
|
var codesMessage = new FormattedMessage();
|
||||||
// Find the first nuke that matches the passed location.
|
// Find the first nuke that matches the passed location.
|
||||||
foreach (var nuke in EntityQuery<NukeComponent>())
|
var query = EntityQuery<NukeComponent>().ToList();
|
||||||
|
_random.Shuffle(query);
|
||||||
|
foreach (var nuke in query)
|
||||||
{
|
{
|
||||||
if (owningStation == null && nuke.OriginMapGrid != (transform.MapID, transform.GridUid)
|
if (!onlyCurrentStation &&
|
||||||
|| nuke.OriginStation != owningStation)
|
(owningStation == null &&
|
||||||
|
nuke.OriginMapGrid != (transform.MapID, transform.GridUid) ||
|
||||||
|
nuke.OriginStation != owningStation))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nukeCode = Loc.GetString("nuke-codes-message", ("name", MetaData(nuke.Owner).EntityName), ("code", nuke.Code));
|
codesMessage.PushNewline();
|
||||||
return true;
|
codesMessage.AddMarkup(Loc.GetString("nuke-codes-list", ("name", MetaData(nuke.Owner).EntityName), ("code", nuke.Code)));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (!codesMessage.IsEmpty)
|
||||||
|
nukeCode = Loc.GetString("nuke-codes-message")+codesMessage;
|
||||||
|
return !codesMessage.IsEmpty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,5 @@ nuke-label-syndicate = SYN-{$serial}
|
|||||||
|
|
||||||
# Codes
|
# Codes
|
||||||
nuke-codes-message = [color=red]TOP SECRET![/color]
|
nuke-codes-message = [color=red]TOP SECRET![/color]
|
||||||
Nuclear device activation code: {$name} - {$code}
|
nuke-codes-list = {$name} code: {$code}
|
||||||
nuke-codes-fax-paper-name = nuclear authentication codes
|
nuke-codes-fax-paper-name = nuclear authentication codes
|
||||||
|
|||||||
@@ -156,8 +156,16 @@
|
|||||||
name: nuclear authentication codes
|
name: nuclear authentication codes
|
||||||
components:
|
components:
|
||||||
- type: NukeCodePaper
|
- type: NukeCodePaper
|
||||||
|
allNukesAvailable: true
|
||||||
- type: Paper
|
- type: Paper
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: NukeCodePaper
|
||||||
|
id: NukeCodePaperStation
|
||||||
|
suffix: Station Only
|
||||||
|
components:
|
||||||
|
- type: NukeCodePaper
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: pen
|
name: pen
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
|
|||||||
Reference in New Issue
Block a user