Job contraband rework (#33385)
* contraband system rework to allow restriction by job, not just department * Fixing detective trenchcoat inheritance * removing unnecessary using declarations * trying to fix testing error by re-adding diagnostics using declaration * removing unecessary dependency, making allowedJobs nullable * Adding all of slarti's requested changes except for the hacky job icon method fix * removing accidental whitespace * choosing to use the non-localized version because we're comparing the string against the AllowedJobs field, and the contraband classes that fill that field are written in english * removing unneeded using dec, fixing nesting logic problem * didn't remove the old nesting, doing that now * using localized job title and localizing the allowed jobs string, removing usages of JobTitle field. Also networked the _jobTitle field instead. * rewrite some stuff * fixes * fix energy pen --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -40,6 +40,7 @@ public sealed class ContrabandSystem : EntitySystem
|
||||
|
||||
contraband.Severity = other.Severity;
|
||||
contraband.AllowedDepartments = other.AllowedDepartments;
|
||||
contraband.AllowedJobs = other.AllowedJobs;
|
||||
Dirty(uid, contraband);
|
||||
}
|
||||
|
||||
@@ -54,11 +55,15 @@ public sealed class ContrabandSystem : EntitySystem
|
||||
|
||||
using (args.PushGroup(nameof(ContrabandComponent)))
|
||||
{
|
||||
// TODO shouldn't department prototypes have a localized name instead of just using the ID for this?
|
||||
var localizedDepartments = ent.Comp.AllowedDepartments.Select(p => Loc.GetString($"department-{p.Id}"));
|
||||
var localizedJobs = ent.Comp.AllowedJobs.Select(p => _proto.Index(p).LocalizedName);
|
||||
|
||||
var severity = _proto.Index(ent.Comp.Severity);
|
||||
if (severity.ShowDepartments && ent.Comp is { AllowedDepartments: not null })
|
||||
if (severity.ShowDepartmentsAndJobs)
|
||||
{
|
||||
// TODO shouldn't department prototypes have a localized name instead of just using the ID for this?
|
||||
var list = ContentLocalizationManager.FormatList(ent.Comp.AllowedDepartments.Select(p => Loc.GetString($"department-{p.Id}")).ToList());
|
||||
//creating a combined list of jobs and departments for the restricted text
|
||||
var list = ContentLocalizationManager.FormatList(localizedDepartments.Concat(localizedJobs).ToList());
|
||||
|
||||
// department restricted text
|
||||
args.PushMarkup(Loc.GetString("contraband-examine-text-Restricted-department", ("departments", list)));
|
||||
@@ -69,23 +74,30 @@ public sealed class ContrabandSystem : EntitySystem
|
||||
}
|
||||
|
||||
// text based on ID card
|
||||
List<ProtoId<DepartmentPrototype>>? departments = null;
|
||||
List<ProtoId<DepartmentPrototype>> departments = new();
|
||||
var jobId = "";
|
||||
|
||||
if (_id.TryFindIdCard(args.Examiner, out var id))
|
||||
{
|
||||
departments = id.Comp.JobDepartments;
|
||||
if (id.Comp.LocalizedJobTitle is not null)
|
||||
{
|
||||
jobId = id.Comp.LocalizedJobTitle;
|
||||
}
|
||||
}
|
||||
|
||||
// either its fully restricted, you have no departments, or your departments dont intersect with the restricted departments
|
||||
if (ent.Comp.AllowedDepartments is null
|
||||
|| departments is null
|
||||
|| !departments.Intersect(ent.Comp.AllowedDepartments).Any())
|
||||
// for the jobs we compare the localized string in case you use an agent ID or custom job name that is not a prototype
|
||||
if (departments.Intersect(ent.Comp.AllowedDepartments).Any()
|
||||
|| localizedJobs.Contains(jobId))
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("contraband-examine-text-avoid-carrying-around"));
|
||||
return;
|
||||
// you are allowed to use this!
|
||||
args.PushMarkup(Loc.GetString("contraband-examine-text-in-the-clear"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// straight to jail!
|
||||
args.PushMarkup(Loc.GetString("contraband-examine-text-avoid-carrying-around"));
|
||||
}
|
||||
|
||||
// otherwise fine to use :tm:
|
||||
args.PushMarkup(Loc.GetString("contraband-examine-text-in-the-clear"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user