mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* scope? i don't know her * more cleanup, Entity<T> * priority mail timer, shared dependencies * MailSystem file-scoped namespace * change FTL text * TODOs * mailteleporter file-scoped namespace * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove the evil nyano mail * Update Content.Shared/_DV/Mail/MailTeleporterComponent.cs Co-authored-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com> Signed-off-by: Milon <plmilonpl@gmail.com> --------- Signed-off-by: Milon <plmilonpl@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com>
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Content.Shared._DV.Mail;
|
|
using Content.Shared.StatusIcon;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._DV.Mail;
|
|
|
|
/// <summary>
|
|
/// Display a cool stamp on the parcel based on the job of the recipient.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// GenericVisualizer is not powerful enough to handle setting a string on
|
|
/// visual data then directly relaying that string to a layer's state.
|
|
/// I.e. there is nothing like a regex capture group for visual data.
|
|
/// Hence why this system exists.
|
|
/// To do this with GenericVisualizer would require a separate condition
|
|
/// for every job value, which would be extra mess to maintain.
|
|
/// It would look something like this, multipled a couple dozen times.
|
|
/// enum.MailVisuals.JobIcon:
|
|
/// enum.MailVisualLayers.JobStamp:
|
|
/// StationEngineer:
|
|
/// state: StationEngineer
|
|
/// SecurityOfficer:
|
|
/// state: SecurityOfficer
|
|
/// </remarks>
|
|
public sealed class MailJobVisualizerSystem : VisualizerSystem<MailComponent>
|
|
{
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly SpriteSystem _spriteSystem = default!;
|
|
|
|
private static readonly ProtoId<JobIconPrototype> UnknownJobIcon = "JobIconUnknown";
|
|
|
|
protected override void OnAppearanceChange(EntityUid uid, MailComponent component, ref AppearanceChangeEvent args)
|
|
{
|
|
if (args.Sprite == null)
|
|
return;
|
|
|
|
_appearance.TryGetData(uid, MailVisuals.JobIcon, out string job, args.Component);
|
|
|
|
ProtoId<JobIconPrototype> jobProtoId = string.IsNullOrEmpty(job) ? UnknownJobIcon : job;
|
|
|
|
if (!_prototypeManager.TryIndex(jobProtoId, out var icon))
|
|
{
|
|
_spriteSystem.LayerSetTexture((uid, args.Sprite), MailVisualLayers.JobStamp, _spriteSystem.Frame0(_prototypeManager.Index(UnknownJobIcon).Icon));
|
|
return;
|
|
}
|
|
|
|
_spriteSystem.LayerSetTexture((uid, args.Sprite), MailVisualLayers.JobStamp, _spriteSystem.Frame0(icon.Icon));
|
|
}
|
|
}
|
|
|
|
public enum MailVisualLayers : byte
|
|
{
|
|
Icon,
|
|
Lock,
|
|
FragileStamp,
|
|
JobStamp,
|
|
PriorityTape,
|
|
Breakage
|
|
}
|