Job icons are stored on ID cards (#18233)

This commit is contained in:
PrPleGoo
2023-07-29 10:25:27 +02:00
committed by GitHub
parent 7c9d7423d2
commit 7c088ac1de
65 changed files with 685 additions and 96 deletions

View File

@@ -4,7 +4,9 @@ using Content.Server.UserInterface;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Interaction;
using Content.Shared.StatusIcon;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server.Access.Systems
{
@@ -13,6 +15,7 @@ namespace Content.Server.Access.Systems
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IdCardSystem _cardSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
@@ -22,6 +25,7 @@ namespace Content.Server.Access.Systems
SubscribeLocalEvent<AgentIDCardComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardNameChangedMessage>(OnNameChanged);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobChangedMessage>(OnJobChanged);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobIconChangedMessage>(OnJobIconChanged);
}
private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args)
@@ -61,7 +65,7 @@ namespace Content.Server.Access.Systems
if (!TryComp<IdCardComponent>(uid, out var idCard))
return;
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "");
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons);
UserInterfaceSystem.SetUiState(ui, state, args.Session);
}
@@ -80,5 +84,20 @@ namespace Content.Server.Access.Systems
_cardSystem.TryChangeFullName(uid, args.Name, idCard);
}
private void OnJobIconChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobIconChangedMessage args)
{
if (!TryComp<IdCardComponent>(uid, out var idCard))
{
return;
}
if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIcon, out var jobIcon))
{
return;
}
_cardSystem.TryChangeJobIcon(uid, jobIcon, idCard);
}
}
}