1
0

ClientRandomIconSmoothSystem.cs 947 B

1234567891011121314151617181920212223242526272829
  1. using Content.Shared.IconSmoothing;
  2. using Robust.Client.GameObjects;
  3. namespace Content.Client.IconSmoothing;
  4. public sealed class ClientRandomIconSmoothSystem : SharedRandomIconSmoothSystem
  5. {
  6. [Dependency] private readonly IconSmoothSystem _iconSmooth = default!;
  7. [Dependency] private readonly AppearanceSystem _appearance = default!;
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<RandomIconSmoothComponent, AppearanceChangeEvent>(OnAppearanceChange);
  12. }
  13. private void OnAppearanceChange(Entity<RandomIconSmoothComponent> ent, ref AppearanceChangeEvent args)
  14. {
  15. if (!TryComp<IconSmoothComponent>(ent, out var smooth))
  16. return;
  17. if (!_appearance.TryGetData<string>(ent, RandomIconSmoothState.State, out var state, args.Component))
  18. return;
  19. smooth.StateBase = state;
  20. _iconSmooth.SetStateBase(ent, smooth, state);
  21. }
  22. }