SunShadowCycleComponent.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Linq;
  2. using System.Numerics;
  3. using Robust.Shared.GameStates;
  4. namespace Content.Shared.Light.Components;
  5. /// <summary>
  6. /// Applies <see cref="SunShadowComponent"/> direction vectors based on a time-offset. Will track <see cref="LightCycleComponent"/> on on MapInit
  7. /// </summary>
  8. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  9. public sealed partial class SunShadowCycleComponent : Component
  10. {
  11. /// <summary>
  12. /// How long an entire cycle lasts
  13. /// </summary>
  14. [DataField, AutoNetworkedField]
  15. public TimeSpan Duration = TimeSpan.FromMinutes(30);
  16. [DataField, AutoNetworkedField]
  17. public TimeSpan Offset;
  18. // Originally had this as ratios but it was slightly annoying to use.
  19. /// <summary>
  20. /// Time to have each direction applied. Will lerp from the current value to the next one.
  21. /// </summary>
  22. [DataField, AutoNetworkedField]
  23. public List<(float Ratio, Vector2 Direction, float Alpha)> Directions = new()
  24. {
  25. (0f, new Vector2(0f, 3f), 0f),
  26. (0.25f, new Vector2(-3f, -0.1f), 0.5f),
  27. (0.5f, new Vector2(0f, -3f), 0.8f),
  28. (0.75f, new Vector2(3f, -0.1f), 0.5f),
  29. };
  30. }