mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* First impl. of appearance TryGetData cleanup * Handful of fixes * DamageVisuals: fix HandleDamage call, inheritdoc * bunch of unused AppearanceSystem instances * Handful more unused appearance systems, inheritdoc * JetpackSystem: Ent<T> * cleanup roundup, more Ent<T> * a few lingering AppearanceSystem.TryGetData calls * more lingering AppearanceData access * Remove unnecessary inheritdoc * once again, with feeling
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 (!args.TryGetData<string>(HolidayVisuals.Holiday, out var data))
|
|
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);
|
|
}
|
|
}
|