1
0

HolidaySystem.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Content.Shared.Holiday;
  2. using Content.Shared.Item;
  3. using Robust.Client.GameObjects;
  4. using Robust.Client.Graphics;
  5. using Robust.Client.ResourceManagement;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations;
  7. namespace Content.Client.Holiday;
  8. public sealed class HolidaySystem : EntitySystem
  9. {
  10. [Dependency] private readonly IResourceCache _rescache = default!;
  11. [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
  12. /// <inheritdoc/>
  13. public override void Initialize()
  14. {
  15. SubscribeLocalEvent<HolidayRsiSwapComponent, AppearanceChangeEvent>(OnAppearanceChange);
  16. }
  17. private void OnAppearanceChange(Entity<HolidayRsiSwapComponent> ent, ref AppearanceChangeEvent args)
  18. {
  19. if (!_appearance.TryGetData<string>(ent, HolidayVisuals.Holiday, out var data, args.Component))
  20. return;
  21. var comp = ent.Comp;
  22. if (!comp.Sprite.TryGetValue(data, out var rsistring) || args.Sprite == null)
  23. return;
  24. var path = SpriteSpecifierSerializer.TextureRoot / rsistring;
  25. if (_rescache.TryGetResource(path, out RSIResource? rsi))
  26. args.Sprite.BaseRSI = rsi.RSI;
  27. }
  28. }