Files
OldThink/Content.Client/Overlays/ShowSecurityIconsSystem.cs

87 lines
2.7 KiB
C#
Raw Normal View History

using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Mindshield.Components;
using Content.Shared.Overlays;
using Content.Shared.PDA;
using Content.Shared.Security.Components;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Shared.Prototypes;
namespace Content.Client.Overlays;
Add health bar overlays for eye equipment (#21980) * PR 1 * fix an error with health bar overlay (#1292) * Revert "Revert "Replace `ResourcePath` with `ResPath` (#15308)" (#155… (#15566) * [1612] change ShowHealthBarsComponent's DamageContainer field to a list (#1662) * fix build * no crit entities from not updating * cleanup * namespace * undu irrelevant changes * undo icon change * make health bar 1 px taller and icon 1 px shorter * fix medibot * fix comment * don't show health bar ratio when in crit * fix build * put the crit bar back * don't render healthbars for mobs that are in containers * draw more boxes without the background sprite * fine status icon for all bio mobs * add wacky mandatory things * attempt 2 * whoops wrong file * cool, this works too * move null check to top * only 1 init * security huds * remove shader * fix build after cleanup * slight cleanup * little more cleanup * Remove clothing grant component system * security HUD now shows a job icon on entities with a body * remove sec stuff and do similar changes to split off PR + remove unused comp * process comments * don't return * update to ComponentAddedOverlaySystemBase * no cache * colors and not rendering out of sight * touch ups * fix build & cleanup * undo * remove shader from icons * process comments * documentation * fix licence * validate prototype id * just use args * rename method and append in method * type * just fucken delete the command * space * undo * remove * don't use LocalPlayer * re-add showhealthbars command, but working * rename icon lists and conform health icon code to the others * space * undo * update command * oops --------- Co-authored-by: Rane <60792108+Elijahrane@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2024-01-04 17:48:57 +01:00
public sealed class ShowSecurityIconsSystem : EquipmentHudSystem<ShowSecurityIconsComponent>
{
[Dependency] private readonly IPrototypeManager _prototypeMan = default!;
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
[ValidatePrototypeId<StatusIconPrototype>]
private const string JobIconForNoId = "JobIconNoId";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StatusIconComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
}
private void OnGetStatusIconsEvent(EntityUid uid, StatusIconComponent _, ref GetStatusIconsEvent @event)
{
if (!IsActive || @event.InContainer)
{
return;
}
Add health bar overlays for eye equipment (#21980) * PR 1 * fix an error with health bar overlay (#1292) * Revert "Revert "Replace `ResourcePath` with `ResPath` (#15308)" (#155… (#15566) * [1612] change ShowHealthBarsComponent's DamageContainer field to a list (#1662) * fix build * no crit entities from not updating * cleanup * namespace * undu irrelevant changes * undo icon change * make health bar 1 px taller and icon 1 px shorter * fix medibot * fix comment * don't show health bar ratio when in crit * fix build * put the crit bar back * don't render healthbars for mobs that are in containers * draw more boxes without the background sprite * fine status icon for all bio mobs * add wacky mandatory things * attempt 2 * whoops wrong file * cool, this works too * move null check to top * only 1 init * security huds * remove shader * fix build after cleanup * slight cleanup * little more cleanup * Remove clothing grant component system * security HUD now shows a job icon on entities with a body * remove sec stuff and do similar changes to split off PR + remove unused comp * process comments * don't return * update to ComponentAddedOverlaySystemBase * no cache * colors and not rendering out of sight * touch ups * fix build & cleanup * undo * remove shader from icons * process comments * documentation * fix licence * validate prototype id * just use args * rename method and append in method * type * just fucken delete the command * space * undo * remove * don't use LocalPlayer * re-add showhealthbars command, but working * rename icon lists and conform health icon code to the others * space * undo * update command * oops --------- Co-authored-by: Rane <60792108+Elijahrane@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2024-01-04 17:48:57 +01:00
var securityIcons = DecideSecurityIcon(uid);
Add health bar overlays for eye equipment (#21980) * PR 1 * fix an error with health bar overlay (#1292) * Revert "Revert "Replace `ResourcePath` with `ResPath` (#15308)" (#155… (#15566) * [1612] change ShowHealthBarsComponent's DamageContainer field to a list (#1662) * fix build * no crit entities from not updating * cleanup * namespace * undu irrelevant changes * undo icon change * make health bar 1 px taller and icon 1 px shorter * fix medibot * fix comment * don't show health bar ratio when in crit * fix build * put the crit bar back * don't render healthbars for mobs that are in containers * draw more boxes without the background sprite * fine status icon for all bio mobs * add wacky mandatory things * attempt 2 * whoops wrong file * cool, this works too * move null check to top * only 1 init * security huds * remove shader * fix build after cleanup * slight cleanup * little more cleanup * Remove clothing grant component system * security HUD now shows a job icon on entities with a body * remove sec stuff and do similar changes to split off PR + remove unused comp * process comments * don't return * update to ComponentAddedOverlaySystemBase * no cache * colors and not rendering out of sight * touch ups * fix build & cleanup * undo * remove shader from icons * process comments * documentation * fix licence * validate prototype id * just use args * rename method and append in method * type * just fucken delete the command * space * undo * remove * don't use LocalPlayer * re-add showhealthbars command, but working * rename icon lists and conform health icon code to the others * space * undo * update command * oops --------- Co-authored-by: Rane <60792108+Elijahrane@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2024-01-04 17:48:57 +01:00
@event.StatusIcons.AddRange(securityIcons);
}
private IReadOnlyList<StatusIconPrototype> DecideSecurityIcon(EntityUid uid)
{
var result = new List<StatusIconPrototype>();
var jobIconToGet = JobIconForNoId;
if (_accessReader.FindAccessItemsInventory(uid, out var items))
{
foreach (var item in items)
{
// ID Card
if (TryComp(item, out IdCardComponent? id))
{
jobIconToGet = id.JobIcon;
break;
}
// PDA
if (TryComp(item, out PdaComponent? pda)
&& pda.ContainedId != null
&& TryComp(pda.ContainedId, out id))
{
jobIconToGet = id.JobIcon;
break;
}
}
}
if (_prototypeMan.TryIndex<StatusIconPrototype>(jobIconToGet, out var jobIcon))
result.Add(jobIcon);
else
Log.Error($"Invalid job icon prototype: {jobIcon}");
if (TryComp<MindShieldComponent>(uid, out var comp))
{
if (_prototypeMan.TryIndex<StatusIconPrototype>(comp.MindShieldStatusIcon.Id, out var icon))
result.Add(icon);
}
if (TryComp<CriminalRecordComponent>(uid, out var record))
{
if(_prototypeMan.TryIndex<StatusIconPrototype>(record.StatusIcon.Id, out var criminalIcon))
result.Add(criminalIcon);
}
return result;
}
}