SmokeVisualizerSystem.cs 799 B

12345678910111213141516171819202122
  1. using Content.Shared.Smoking;
  2. using Robust.Client.GameObjects;
  3. namespace Content.Client.Chemistry.Visualizers;
  4. /// <summary>
  5. /// Ensures entities with <see cref="SmokeVisualsComponent"/> have a color corresponding with their contained reagents.
  6. /// </summary>
  7. public sealed class SmokeVisualizerSystem : VisualizerSystem<SmokeVisualsComponent>
  8. {
  9. /// <summary>
  10. /// Syncs the color of the smoke with the color of its contained reagents.
  11. /// </summary>
  12. protected override void OnAppearanceChange(EntityUid uid, SmokeVisualsComponent comp, ref AppearanceChangeEvent args)
  13. {
  14. if (args.Sprite == null)
  15. return;
  16. if(!AppearanceSystem.TryGetData<Color>(uid, SmokeVisuals.Color, out var color))
  17. return;
  18. args.Sprite.Color = color;
  19. }
  20. }