mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using Content.Shared.Holiday;
|
|
using Content.Shared.Item;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.ResourceManagement;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations;
|
|
|
|
namespace Content.Client.Holiday;
|
|
|
|
public sealed partial class HolidaySystem : EntitySystem
|
|
{
|
|
[Dependency] private IResourceCache _rescache = default!;
|
|
[Dependency] private SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private SpriteSystem _sprite = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<HolidayRsiSwapComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
|
}
|
|
|
|
private void OnAppearanceChange(Entity<HolidayRsiSwapComponent> ent, ref AppearanceChangeEvent args)
|
|
{
|
|
if (!_appearance.TryGetData<string>(ent, HolidayVisuals.Holiday, out var data, args.Component))
|
|
return;
|
|
|
|
var comp = ent.Comp;
|
|
if (!comp.Sprite.TryGetValue(data, out var rsistring) || args.Sprite == null)
|
|
return;
|
|
|
|
var path = SpriteSpecifierSerializer.TextureRoot / rsistring;
|
|
if (_rescache.TryGetResource(path, out RSIResource? rsi))
|
|
_sprite.SetBaseRsi((ent.Owner, args.Sprite), rsi.RSI);
|
|
}
|
|
}
|