1
0

ParallaxLayerConfig.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Numerics;
  2. namespace Content.Client.Parallax.Data;
  3. /// <summary>
  4. /// The configuration for a parallax layer.
  5. /// </summary>
  6. [DataDefinition]
  7. public sealed partial class ParallaxLayerConfig
  8. {
  9. /// <summary>
  10. /// The texture source for this layer.
  11. /// </summary>
  12. [DataField("texture", required: true)]
  13. public IParallaxTextureSource Texture { get; set; } = default!;
  14. /// <summary>
  15. /// A scaling factor for the texture.
  16. /// In the interest of simplifying maths, this is rounded down to integer for ParallaxControl, so be careful.
  17. /// </summary>
  18. [DataField("scale")]
  19. public Vector2 Scale { get; set; } = Vector2.One;
  20. /// <summary>
  21. /// If true, this layer is tiled as the camera scrolls around.
  22. /// If false, this layer only shows up around it's home position.
  23. /// </summary>
  24. [DataField("tiled")]
  25. public bool Tiled { get; set; } = true;
  26. /// <summary>
  27. /// A position relative to the centre of a ParallaxControl that this parallax should be drawn at, in pixels.
  28. /// Used for menus.
  29. /// Note that this is ignored if the parallax layer is tiled - in that event a random pixel offset is used and slowness is applied.
  30. /// </summary>
  31. [DataField("controlHomePosition")]
  32. public Vector2 ControlHomePosition { get; set; }
  33. /// <summary>
  34. /// The "relative to ParallaxAnchor" starting world position for this layer.
  35. /// Essentially, an unclamped lerp occurs between here and the eye position, with Slowness as the factor.
  36. /// Used for in-game.
  37. /// </summary>
  38. [DataField("worldHomePosition")]
  39. public Vector2 WorldHomePosition { get; set; }
  40. /// <summary>
  41. /// An adjustment performed to the world position of this layer after parallax shifting.
  42. /// Used for in-game.
  43. /// Useful for moving around Slowness = 1.0 objects (which can't otherwise be moved from screen centre).
  44. /// </summary>
  45. [DataField("worldAdjustPosition")]
  46. public Vector2 WorldAdjustPosition { get; set; }
  47. /// <summary>
  48. /// Multiplier of parallax shift.
  49. /// A slowness of 0.0f anchors this layer to the world.
  50. /// A slowness of 1.0f anchors this layer to the camera.
  51. /// </summary>
  52. [DataField("slowness")]
  53. public float Slowness { get; set; } = 0.5f;
  54. /// <summary>
  55. /// Should the parallax scroll at a specific rate per second.
  56. /// </summary>
  57. [DataField("scrolling")] public Vector2 Scrolling = Vector2.Zero;
  58. [DataField("shader")] public string? Shader = "unshaded";
  59. }