Files
tbd-station-14/Content.Client/SprayPainter/SprayPainterSystem.cs
c4llv07e d7eb3bfb44 Pipe painter (now with airlock painter) (#19031)
* Add a pipe painting function to the airlock painter

Signed-off-by: c4llv07e <kseandi@gmail.com>

* Rename engineer painter to omnipainter

Signed-off-by: c4llv07e <kseandi@gmail.com>

* review changes

Signed-off-by: c4llv07e <kseandi@gmail.com>

* fix migration duplicate

Signed-off-by: c4llv07e <kseandi@gmail.com>

---------

Signed-off-by: c4llv07e <kseandi@gmail.com>
2023-08-14 15:06:21 +03:00

54 lines
1.5 KiB
C#

using Content.Shared.SprayPainter;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.Client.SprayPainter;
public sealed class SprayPainterSystem : SharedSprayPainterSystem
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
public List<SprayPainterEntry> Entries { get; private set; } = new();
public override void Initialize()
{
base.Initialize();
foreach (string style in Styles)
{
string? iconPath = Groups
.FindAll(x => x.StylePaths.ContainsKey(style))?
.MaxBy(x => x.IconPriority)?.StylePaths[style];
if (iconPath == null)
{
Entries.Add(new SprayPainterEntry(style, null));
continue;
}
RSIResource doorRsi = _resourceCache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / new ResPath(iconPath));
if (!doorRsi.RSI.TryGetState("closed", out var icon))
{
Entries.Add(new SprayPainterEntry(style, null));
continue;
}
Entries.Add(new SprayPainterEntry(style, icon.Frame0));
}
}
}
public sealed class SprayPainterEntry
{
public string Name;
public Texture? Icon;
public SprayPainterEntry(string name, Texture? icon)
{
Name = name;
Icon = icon;
}
}