using Content.Shared.Roles;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared._Sunrise.Helpers;
public sealed class ChatIconsHelpersSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
public const string NoIdIconPath = "/Textures/Interface/Misc/job_icons.rsi/NoId.png";
///
/// Собирает и возвращает иконку для переданной работы
///
[PublicAPI]
public string GetJobIcon(ProtoId? job, int scale = 1)
{
var iconPath = _prototype.TryIndex(job, out var jobPrototype)
? GetJobIconPath(jobPrototype)
: NoIdIconPath;
var jobIcon = Loc.GetString("texture-tag",
("path", iconPath),
("scale", scale)
);
return jobIcon;
}
///
/// Возвращает путь к иконке работы, используя переданный прототип работы
///
[PublicAPI]
public string GetJobIconPath(JobPrototype job)
{
var icon = _prototype.Index(job.Icon);
var sprite = icon.Icon switch
{
SpriteSpecifier.Texture tex => tex.TexturePath.CanonPath,
SpriteSpecifier.Rsi rsi => rsi.RsiPath.CanonPath + '/' + rsi.RsiState + ".png",
_ => NoIdIconPath,
};
return sprite;
}
}