Skip to content

Commit

Permalink
job and department restricted chemicals
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian321 committed Jan 15, 2025
1 parent c99ff17 commit 08dcc3b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
28 changes: 27 additions & 1 deletion Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Content.Shared.Body.Prototypes;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Localizations;
using Content.Shared.Roles;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -195,7 +197,31 @@ private void GenerateControl(ReagentPrototype reagent)
FormattedMessage description = new();
if (_prototype.TryIndex(reagent.Contraband, out var severity))
{
description.AddMarkupOrThrow(Loc.GetString(severity.ExamineText, ("color", severity.ExamineColor)));
if (severity.ShowDepartments && (reagent is { AllowedDepartments: not null } || reagent is { AllowedJobs: not null }))
{
var departments = reagent.AllowedDepartments?.Select(x =>
{
if (_prototype.TryIndex(x, out var department))
{
return Loc.GetString(department.Name);
}
return x.Id;
}) ?? [];
var jobs = reagent.AllowedJobs?.Select(x =>
{
if (_prototype.TryIndex(x, out var job))
{
return Loc.GetString("generic-multiple", ("thing", Loc.GetString(job.Name)));
}
return x.Id;
}) ?? [];
var list = ContentLocalizationManager.FormatList([.. departments, .. jobs]);
description.AddMarkupOrThrow(Loc.GetString("contraband-examine-text-Restricted-department", ("color", severity.ExamineColor), ("departments", list)));
}
else
{
description.AddMarkupOrThrow(Loc.GetString(severity.ExamineText, ("color", severity.ExamineColor)));
}
description.PushNewline();
}
description.AddText(reagent.LocalizedDescription);
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Guidebook/Richtext/ContrabandColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Robust.Client.UserInterface.RichText;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Content.Shared.Localizations;

namespace Content.Client.Guidebook.RichText;

Expand All @@ -22,10 +23,10 @@ public sealed class ContrabandColors : IMarkupTag
/// <inheritdoc/>
public bool TryGetControl(MarkupNode node, [NotNullWhen(true)] out Control? control)
{
var text = _prototypeManager.EnumeratePrototypes<ContrabandSeverityPrototype>().Select(x =>
var text = ContentLocalizationManager.FormatList([.. _prototypeManager.EnumeratePrototypes<ContrabandSeverityPrototype>().Select(x =>
{
return $"[color={x.ExamineColor}]{x.ID}[/color]";
}).Aggregate((x, y) => x + ", " + y);
})]);

var label = new RichTextLabel()
{
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Forensics/Systems/ForensicPadSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Localizations;
using Robust.Shared.Prototypes;

namespace Content.Server.Forensics
Expand Down Expand Up @@ -96,7 +97,7 @@ private void OnAfterInteract(EntityUid uid, ForensicPadComponent component, Afte
return;
}

var sample = solution.Contents.Select(x =>
var sample = ContentLocalizationManager.FormatList([.. solution.Contents.Select(x =>
{
if (_prototypeManager.TryIndex(x.Reagent.Prototype, out ReagentPrototype? reagent))
{
Expand All @@ -108,7 +109,7 @@ private void OnAfterInteract(EntityUid uid, ForensicPadComponent component, Afte
return localizedName;
}
return "???";
}).Aggregate((x, y) => x + ", " + y);
})]);
StartScan(uid, args.User, args.Target.Value, component, sample);
return;
}
Expand Down
11 changes: 11 additions & 0 deletions Content.Shared/Chemistry/Reagent/ReagentPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Utility;
using Content.Shared.Roles;

namespace Content.Shared.Chemistry.Reagent
{
Expand Down Expand Up @@ -149,6 +150,16 @@ public sealed partial class ReagentPrototype : IPrototype, IInheritingPrototype
/// </summary>
[DataField]
public ProtoId<ContrabandSeverityPrototype>? Contraband = null;
/// <summary>
/// Which departments is this reagent restricted to?
/// </summary>
[DataField]
public HashSet<ProtoId<DepartmentPrototype>>? AllowedDepartments = null;
/// <summary>
/// Which jobs is this reagent restricted to?
/// </summary>
[DataField]
public HashSet<ProtoId<JobPrototype>>? AllowedJobs = null;

public FixedPoint2 ReactionTile(TileRef tile, FixedPoint2 reactVolume, IEntityManager entityManager, List<ReagentData>? data)
{
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/generic.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ generic-minutes = minutes
generic-playtime-title = Playtime
generic-confirm = Confirm
generic-multiple = {MAKEPLURAL($thing)}

0 comments on commit 08dcc3b

Please sign in to comment.