RgbLightControllerComponent.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Serialization;
  3. namespace Content.Shared.Light.Components;
  4. /// <summary>
  5. /// Makes the color of lights on an entity fluctuate. Will update point-light color and modulate some or all of the
  6. /// sprite layers. Will also modulate the color of any unshaded layers that this entity contributes to a wearer or holder.
  7. /// </summary>
  8. /// <remarks>
  9. /// Networked ~~solely for admemes~~ for completely legitimate reasons, like hacked energy swords.
  10. /// </remarks>
  11. [NetworkedComponent, RegisterComponent, Access(typeof(SharedRgbLightControllerSystem))]
  12. public sealed partial class RgbLightControllerComponent : Component
  13. {
  14. [DataField("cycleRate")]
  15. public float CycleRate { get; set; } = 0.1f;
  16. /// <summary>
  17. /// What layers of the sprite to modulate? If null, will affect only unshaded layers.
  18. /// </summary>
  19. [DataField("layers")]
  20. public List<int>? Layers;
  21. /// <summary>
  22. /// Original light color from befor the rgb was aded. Used to revert colors when removed.
  23. /// </summary>
  24. public Color OriginalLightColor;
  25. /// <summary>
  26. /// Original colors of the sprite layersfrom before the rgb was added. Used to revert colors when removed.
  27. /// </summary>
  28. public Dictionary<int, Color>? OriginalLayerColors;
  29. /// <summary>
  30. /// User that is holding or wearing this entity
  31. /// </summary>
  32. public EntityUid? Holder;
  33. /// <summary>
  34. /// List of unshaded layers on the holder/wearer that are being modulated.
  35. /// </summary>
  36. public List<string>? HolderLayers;
  37. }
  38. [Serializable, NetSerializable]
  39. public sealed class RgbLightControllerState : ComponentState
  40. {
  41. public readonly float CycleRate;
  42. public List<int>? Layers;
  43. public RgbLightControllerState(float cycleRate, List<int>? layers)
  44. {
  45. CycleRate = cycleRate;
  46. Layers = layers;
  47. }
  48. }