2023-08-14 12:06:21 +00:00
|
|
|
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;
|
2023-09-11 19:18:06 +10:00
|
|
|
using Robust.Shared.Graphics;
|
2023-08-14 12:06:21 +00:00
|
|
|
|
|
|
|
|
namespace Content.Client.SprayPainter;
|
|
|
|
|
|
|
|
|
|
public sealed class SprayPainterSystem : SharedSprayPainterSystem
|
|
|
|
|
{
|
2023-10-29 15:29:30 +11:00
|
|
|
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
2023-08-14 12:06:21 +00:00
|
|
|
|
|
|
|
|
public List<SprayPainterEntry> Entries { get; private set; } = new();
|
|
|
|
|
|
2024-02-01 22:30:46 +00:00
|
|
|
protected override void CacheStyles()
|
2023-08-14 12:06:21 +00:00
|
|
|
{
|
2024-02-01 22:30:46 +00:00
|
|
|
base.CacheStyles();
|
2023-08-14 12:06:21 +00:00
|
|
|
|
2024-02-01 22:30:46 +00:00
|
|
|
Entries.Clear();
|
|
|
|
|
foreach (var style in Styles)
|
2023-08-14 12:06:21 +00:00
|
|
|
{
|
2024-02-01 22:30:46 +00:00
|
|
|
var name = style.Name;
|
2023-08-14 12:06:21 +00:00
|
|
|
string? iconPath = Groups
|
2024-02-01 22:30:46 +00:00
|
|
|
.FindAll(x => x.StylePaths.ContainsKey(name))?
|
|
|
|
|
.MaxBy(x => x.IconPriority)?.StylePaths[name];
|
2023-08-14 12:06:21 +00:00
|
|
|
if (iconPath == null)
|
|
|
|
|
{
|
2024-02-01 22:30:46 +00:00
|
|
|
Entries.Add(new SprayPainterEntry(name, null));
|
2023-08-14 12:06:21 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RSIResource doorRsi = _resourceCache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / new ResPath(iconPath));
|
|
|
|
|
if (!doorRsi.RSI.TryGetState("closed", out var icon))
|
|
|
|
|
{
|
2024-02-01 22:30:46 +00:00
|
|
|
Entries.Add(new SprayPainterEntry(name, null));
|
2023-08-14 12:06:21 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-01 22:30:46 +00:00
|
|
|
Entries.Add(new SprayPainterEntry(name, icon.Frame0));
|
2023-08-14 12:06:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed class SprayPainterEntry
|
|
|
|
|
{
|
|
|
|
|
public string Name;
|
|
|
|
|
public Texture? Icon;
|
|
|
|
|
|
|
|
|
|
public SprayPainterEntry(string name, Texture? icon)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
Icon = icon;
|
|
|
|
|
}
|
|
|
|
|
}
|