mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* 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>
78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using Content.Shared.Access.Components;
|
|
using Content.Shared.Hands;
|
|
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.PDA;
|
|
using Content.Shared.StatusIcon;
|
|
using Content.Shared.StatusIcon.Components;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Access.Systems;
|
|
|
|
public abstract partial class SharedJobStatusSystem : EntitySystem
|
|
{
|
|
[Dependency] private AccessReaderSystem _accessReader = default!;
|
|
|
|
private static readonly ProtoId<JobIconPrototype> JobIconForNoId = "JobIconNoId";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
// if the mob picks up, drops or (un)equips a pda or Id card then update their crew status
|
|
SubscribeLocalEvent<JobStatusComponent, DidEquipEvent>((uid, comp, _) => UpdateStatus((uid, comp)));
|
|
SubscribeLocalEvent<JobStatusComponent, DidEquipHandEvent>((uid, comp, _) => UpdateStatus((uid, comp)));
|
|
SubscribeLocalEvent<JobStatusComponent, DidUnequipEvent>((uid, comp, _) => UpdateStatus((uid, comp)));
|
|
SubscribeLocalEvent<JobStatusComponent, DidUnequipHandEvent>((uid, comp, _) => UpdateStatus((uid, comp)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates this mob's job and crew status depending on their currently equipped or held pda or Id card.
|
|
/// </summary>
|
|
public void UpdateStatus(Entity<JobStatusComponent?> ent)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp, false))
|
|
return;
|
|
|
|
var iconId = JobIconForNoId;
|
|
|
|
if (_accessReader.FindAccessItemsInventory(ent.Owner, out var items))
|
|
{
|
|
foreach (var item in items)
|
|
{
|
|
// ID Card
|
|
if (TryComp<IdCardComponent>(item, out var id))
|
|
{
|
|
iconId = id.JobIcon;
|
|
break;
|
|
}
|
|
|
|
// PDA
|
|
if (TryComp<PdaComponent>(item, out var pda)
|
|
&& pda.ContainedId != null
|
|
&& TryComp(pda.ContainedId, out id))
|
|
{
|
|
iconId = id.JobIcon;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
ent.Comp.JobStatusIcon = iconId;
|
|
ent.Comp.IsCrew = ProtoMan.Index(iconId).IsCrewJob;
|
|
Dirty(ent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the job status of the entity wearing/holding the given ID card.
|
|
/// </summary>
|
|
public void UpdateIdHolderStatus(EntityUid idCard)
|
|
{
|
|
var holder = Transform(idCard).ParentUid;
|
|
|
|
// ID is inside a PDA, ascend to whoever is wearing/holding the PDA.
|
|
if (HasComp<PdaComponent>(holder))
|
|
holder = Transform(holder).ParentUid;
|
|
|
|
UpdateStatus(holder);
|
|
}
|
|
}
|