Add support for contraband text to the reagent guidebook (#37113)

* Add contraband text to reagent guidebook

* Add reagent for examining

* Update Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
SlamBamActionman
2025-09-10 15:30:53 +02:00
committed by GitHub
parent a5ef016f1e
commit 3da0b0299f
4 changed files with 118 additions and 14 deletions

View File

@@ -66,17 +66,13 @@ public sealed class ContrabandSystem : EntitySystem
// 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
{
@@ -95,6 +91,7 @@ public sealed class ContrabandSystem : EntitySystem
}
}
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";
@@ -112,6 +109,19 @@ public sealed class ContrabandSystem : EntitySystem
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();
@@ -131,3 +141,12 @@ public sealed class ContrabandSystem : EntitySystem
_contrabandExamineOnlyInHudEnabled = val;
}
}
/// <summary>
/// The item type that the contraband text should follow in the description text.
/// </summary>
public enum ContrabandItemType
{
Item,
Reagent
}