1
0

LightBulbSystem.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Content.Shared.Light.Components;
  2. using Robust.Client.GameObjects;
  3. namespace Content.Client.Light.Visualizers;
  4. public sealed class LightBulbSystem : VisualizerSystem<LightBulbComponent>
  5. {
  6. protected override void OnAppearanceChange(EntityUid uid, LightBulbComponent comp, ref AppearanceChangeEvent args)
  7. {
  8. if (args.Sprite == null)
  9. return;
  10. // update sprite state
  11. if (AppearanceSystem.TryGetData<LightBulbState>(uid, LightBulbVisuals.State, out var state, args.Component))
  12. {
  13. switch (state)
  14. {
  15. case LightBulbState.Normal:
  16. args.Sprite.LayerSetState(LightBulbVisualLayers.Base, comp.NormalSpriteState);
  17. break;
  18. case LightBulbState.Broken:
  19. args.Sprite.LayerSetState(LightBulbVisualLayers.Base, comp.BrokenSpriteState);
  20. break;
  21. case LightBulbState.Burned:
  22. args.Sprite.LayerSetState(LightBulbVisualLayers.Base, comp.BurnedSpriteState);
  23. break;
  24. }
  25. }
  26. // also update sprites color
  27. if (AppearanceSystem.TryGetData<Color>(uid, LightBulbVisuals.Color, out var color, args.Component))
  28. {
  29. args.Sprite.Color = color;
  30. }
  31. }
  32. }