using Content.Client.Message;
using Content.Client.UserInterface.ControlExtensions;
using Content.Shared.Body.Prototypes;
+using Content.Shared.CCVar;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
+using Content.Shared.Contraband;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
+ [Dependency] private readonly IConfigurationManager _config = default!;
private readonly ChemistryGuideDataSystem _chemistryGuideData;
+ private readonly ContrabandSystem _contraband;
private readonly ISawmill _sawmill;
public IPrototype? RepresentedPrototype { get; private set; }
IoCManager.InjectDependencies(this);
_sawmill = _logManager.GetSawmill("guidebook.reagent");
_chemistryGuideData = _systemManager.GetEntitySystem<ChemistryGuideDataSystem>();
+ _contraband = _systemManager.GetEntitySystem<ContrabandSystem>();
MouseFilter = MouseFilterMode.Stop;
}
description.PushNewline();
description.AddMarkupOrThrow(Loc.GetString("guidebook-reagent-physical-description",
("description", reagent.LocalizedPhysicalDescription)));
+
+ if (_config.GetCVar(CCVars.ContrabandExamine))
+ {
+ // Department-restricted text
+ if (reagent.AllowedJobs.Count > 0 || reagent.AllowedDepartments.Count > 0)
+ {
+ description.PushNewline();
+ description.AddMarkupPermissive(
+ _contraband.GenerateDepartmentExamineMessage(reagent.AllowedDepartments, reagent.AllowedJobs, ContrabandItemType.Reagent));
+ }
+ // Other contraband text
+ else if (reagent.ContrabandSeverity != null &&
+ _prototype.Resolve(reagent.ContrabandSeverity.Value, out var severity))
+ {
+ description.PushNewline();
+ description.AddMarkupPermissive(Loc.GetString(severity.ExamineText, ("type", ContrabandItemType.Reagent)));
+ }
+ }
+
ReagentDescription.SetMessage(description);
}
using Content.Shared.Body.Prototypes;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
+using Content.Shared.Contraband;
using Content.Shared.EntityEffects;
using Content.Shared.Database;
using Content.Shared.Nutrition;
using Content.Shared.Prototypes;
+using Content.Shared.Roles;
using Content.Shared.Slippery;
using Robust.Shared.Audio;
using Robust.Shared.Map;
[ViewVariables(VVAccess.ReadOnly)]
public string LocalizedPhysicalDescription => Loc.GetString(PhysicalDescription);
+ /// <summary>
+ /// The degree of contraband severity this reagent is considered to have.
+ /// If AllowedDepartments or AllowedJobs are set, they take precedent and override this value.
+ /// </summary>
+ [DataField]
+ public ProtoId<ContrabandSeverityPrototype>? ContrabandSeverity = null;
+
+ /// <summary>
+ /// Which departments is this reagent restricted to, if any?
+ /// </summary>
+ [DataField]
+ public HashSet<ProtoId<DepartmentPrototype>> AllowedDepartments = new();
+
+ /// <summary>
+ /// Which jobs is this reagent restricted to, if any?
+ /// </summary>
+ [DataField]
+ public HashSet<ProtoId<JobPrototype>> AllowedJobs = new();
+
/// <summary>
/// Is this reagent recognizable to the average spaceman (water, welding fuel, ketchup, etc)?
/// </summary>
// two strings:
// one, the actual informative 'this is restricted'
// then, the 'you can/shouldn't carry this around' based on the ID the user is wearing
- var localizedDepartments = component.AllowedDepartments.Select(p => Loc.GetString("contraband-department-plural", ("department", Loc.GetString(_proto.Index(p).Name))));
- var jobs = component.AllowedJobs.Select(p => _proto.Index(p).LocalizedName).ToArray();
- var localizedJobs = jobs.Select(p => Loc.GetString("contraband-job-plural", ("job", p)));
var severity = _proto.Index(component.Severity);
String departmentExamineMessage;
if (severity.ShowDepartmentsAndJobs)
{
- //creating a combined list of jobs and departments for the restricted text
- var list = ContentLocalizationManager.FormatList(localizedDepartments.Concat(localizedJobs).ToList());
// department restricted text
- departmentExamineMessage = Loc.GetString("contraband-examine-text-Restricted-department", ("departments", list));
+ departmentExamineMessage =
+ GenerateDepartmentExamineMessage(component.AllowedDepartments, component.AllowedJobs);
}
else
{
}
}
+ var jobs = component.AllowedJobs.Select(p => _proto.Index(p).LocalizedName).ToArray();
// if it is fully restricted, you're department-less, or your department isn't in the allowed list, you cannot carry it. Otherwise, you can.
var carryingMessage = Loc.GetString("contraband-examine-text-avoid-carrying-around");
var iconTexture = "/Textures/Interface/VerbIcons/lock-red.svg.192dpi.png";
iconTexture);
}
+ public string GenerateDepartmentExamineMessage(HashSet<ProtoId<DepartmentPrototype>> allowedDepartments, HashSet<ProtoId<JobPrototype>> allowedJobs, ContrabandItemType itemType = ContrabandItemType.Item)
+ {
+ var localizedDepartments = allowedDepartments.Select(p => Loc.GetString("contraband-department-plural", ("department", Loc.GetString(_proto.Index(p).Name))));
+ var jobs = allowedJobs.Select(p => _proto.Index(p).LocalizedName).ToArray();
+ var localizedJobs = jobs.Select(p => Loc.GetString("contraband-job-plural", ("job", p)));
+
+ //creating a combined list of jobs and departments for the restricted text
+ var list = ContentLocalizationManager.FormatList(localizedDepartments.Concat(localizedJobs).ToList());
+
+ // department restricted text
+ return Loc.GetString("contraband-examine-text-Restricted-department", ("departments", list), ("type", itemType));
+ }
+
private FormattedMessage GetContrabandExamine(String deptMessage, String carryMessage)
{
var msg = new FormattedMessage();
_contrabandExamineOnlyInHudEnabled = val;
}
}
+
+/// <summary>
+/// The item type that the contraband text should follow in the description text.
+/// </summary>
+public enum ContrabandItemType
+{
+ Item,
+ Reagent
+}
-contraband-examine-text-Minor = [color=yellow]This item is considered minor contraband.[/color]
-contraband-examine-text-Restricted = [color=yellow]This item is departmentally restricted.[/color]
-contraband-examine-text-Restricted-department = [color=yellow]This item is restricted to {$departments}, and may be considered contraband.[/color]
-contraband-examine-text-Major = [color=red]This item is considered major contraband.[/color]
-contraband-examine-text-GrandTheft = [color=red]This item is a highly valuable target for Syndicate agents![/color]
-contraband-examine-text-Highly-Illegal = [color=red]This item is highly illegal contraband![/color]
-contraband-examine-text-Syndicate = [color=crimson]This item is highly illegal Syndicate contraband![/color]
-contraband-examine-text-Magical = [color=#b337b3]This item is highly illegal magical contraband![/color]
+contraband-examine-text-Minor =
+ { $type ->
+ *[item] [color=yellow]This item is considered minor contraband.[/color]
+ [reagent] [color=yellow]This reagent is considered minor contraband.[/color]
+ }
+
+contraband-examine-text-Restricted =
+ { $type ->
+ *[item] [color=yellow]This item is departmentally restricted.[/color]
+ [reagent] [color=yellow]This reagent is departmentally restricted.[/color]
+ }
+
+contraband-examine-text-Restricted-department =
+ { $type ->
+ *[item] [color=yellow]This item is restricted to {$departments}, and may be considered contraband.[/color]
+ [reagent] [color=yellow]This reagent is restricted to {$departments}, and may be considered contraband.[/color]
+ }
+
+contraband-examine-text-Major =
+ { $type ->
+ *[item] [color=red]This item is considered major contraband.[/color]
+ [reagent] [color=red]This reagent is considered major contraband.[/color]
+ }
+
+contraband-examine-text-GrandTheft =
+ { $type ->
+ *[item] [color=red]This item is a highly valuable target for Syndicate agents![/color]
+ [reagent] [color=red]This reagent is a highly valuable target for Syndicate agents![/color]
+ }
+
+contraband-examine-text-Highly-Illegal =
+ { $type ->
+ *[item] [color=crimson]This item is highly illegal contraband![/color]
+ [reagent] [color=crimson]This reagent is highly illegal contraband![/color]
+ }
+
+contraband-examine-text-Syndicate =
+ { $type ->
+ *[item] [color=crimson]This item is highly illegal Syndicate contraband![/color]
+ [reagent] [color=crimson]This reagent is highly illegal Syndicate contraband![/color]
+ }
+
+contraband-examine-text-Magical =
+ { $type ->
+ *[item] [color=#b337b3]This item is highly illegal magical contraband![/color]
+ [reagent] [color=#b337b3]This reagent is highly illegal magical contraband![/color]
+ }
contraband-examine-text-avoid-carrying-around = [color=red][italic]You probably want to avoid visibly carrying this around without a good reason.[/italic][/color]
contraband-examine-text-in-the-clear = [color=green][italic]You should be in the clear to visibly carry this around.[/italic][/color]