CatStation/Content.Server/Access/Systems/AgentIDCardSystem.cs
āda d33e63a5a2
New Agent Id UI (#39769)
* icon group prototype

* prototype v2

* agent id uses groups

* working UI using groups

* UI work, new header

* formatting and misc work

* fix some texture scaling

* aesthetics

* tabs, scrollbar, MinSize

* commit

* commit

* commit

* commit

* Revert "commit"

This reverts commit 8f29ae30c69670c6dc8d5fba3dd6bd98f574830d.

* we're back

* well enough

* Final visuals for the Id (for now)

* code cleaning

* minor cleanup

* self review

* id card system changes

* try index -> resolve

* DisposeAllChildren -> RemoveAllChildren

* fix the id cards

* all pretty

* unneeded

* merge

* Review by Fildrance

* Review by Pok

* fix

* cleanup

* refactor: revert icon setsize changes back to good old '32', made container button be resizable for localization reasons

* jobIconGroup

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
Co-authored-by: Fildrance <fildrance@gmail.com>
2026-07-18 19:51:36 +00:00

59 lines
2.5 KiB
C#

using Content.Server.Clothing.Systems;
using Content.Server.Implants;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Clothing.Components;
using Content.Shared.Implants;
using Content.Shared.Inventory;
using Content.Shared.PDA;
namespace Content.Server.Access.Systems;
/// <inheritdoc />
public sealed partial class AgentIdCardSystem : SharedAgentIdCardSystem
{
[Dependency] private SharedIdCardSystem _card = default!;
[Dependency] private ChameleonClothingSystem _chameleon = default!;
[Dependency] private ChameleonControllerSystem _chamController = default!;
[SubscribeLocalEvent]
private void OnChameleonControllerOutfitChangedItem(Entity<AgentIDCardComponent> ent, ref InventoryRelayedEvent<ChameleonControllerOutfitSelectedEvent> args)
{
if (!TryComp<IdCardComponent>(ent, out var idCardComp))
return;
ProtoMan.Resolve(args.Args.ChameleonOutfit.Job, out var jobProto);
var jobIcon = args.Args.ChameleonOutfit.Icon ?? jobProto?.Icon;
var jobName = args.Args.ChameleonOutfit.Name ?? jobProto?.Name ?? "";
if (jobIcon != null)
_card.TryChangeJobIcon(ent, ProtoMan.Index(jobIcon.Value), idCardComp);
if (jobName != "")
_card.TryChangeJobTitle(ent, Loc.GetString(jobName), idCardComp);
// If you have forced departments use those over the jobs actual departments.
if (args.Args.ChameleonOutfit.Departments?.Count > 0)
_card.TryChangeJobDepartment(ent, args.Args.ChameleonOutfit.Departments, idCardComp);
else if (jobProto != null)
_card.TryChangeJobDepartment(ent, jobProto, idCardComp);
// Ensure that you chameleon IDs in PDAs correctly. Yes this is sus...
// There is one weird interaction: If the job / icon don't match the PDAs job the chameleon will be updated
// to the PDAs IDs sprite but the icon and job title will not match. There isn't a way to get around this
// really as there is no tie between job -> pda or pda -> job.
var idSlotGear = _chamController.GetGearForSlot(args, "id");
if (idSlotGear == null)
return;
var proto = ProtoMan.Index(idSlotGear);
if (!proto.TryComp<PdaComponent>(out var comp, EntityManager.ComponentFactory))
return;
if (TryComp<ChameleonClothingComponent>(ent, out var chameleonComp) && chameleonComp.CanBeSetByController)
_chameleon.SetSelectedPrototype(ent, comp.IdCard, component: chameleonComp);
}
}