TilemapLayer.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using Microsoft.Xna.Framework;
  2. namespace MonoGame.Extended.Tilemaps
  3. {
  4. /// <summary>
  5. /// Base class for all tilemap layers.
  6. /// </summary>
  7. public abstract class TilemapLayer
  8. {
  9. /// <summary>
  10. /// Gets the name of the layer.
  11. /// </summary>
  12. public string Name { get; }
  13. /// <summary>
  14. /// Gets or sets the class/type identifier for this layer.
  15. /// </summary>
  16. public string Class { get; set; } = string.Empty;
  17. /// <summary>
  18. /// Gets or sets a value indicating whether the layer is visible.
  19. /// </summary>
  20. public bool IsVisible { get; set; }
  21. /// <summary>
  22. /// Gets or sets the opacity of the layer.
  23. /// </summary>
  24. /// <value>A value between 0.0 (fully transparent) and 1.0 (fully opaque).</value>
  25. public float Opacity { get; set; }
  26. /// <summary>
  27. /// Gets or sets the tint color applied to the layer.
  28. /// </summary>
  29. public Color? TintColor { get; set; }
  30. /// <summary>
  31. /// Gets or sets the rendering offset for the layer.
  32. /// </summary>
  33. public Vector2 Offset { get; set; }
  34. /// <summary>
  35. /// Gets or sets the parallax scrolling factor for this layer, affecting scrolling speed relative to the camera.
  36. /// </summary>
  37. /// <value>A factor where (1,1) represents normal scrolling.</value>
  38. /// <remarks>
  39. /// A factor of (1, 1) scrolls at normal speed. Values less than 1 create a background effect,
  40. /// while values greater than 1 create a foreground effect.
  41. /// This feature is primarily used by Tiled. For other formats, this value will be (1, 1).
  42. /// </remarks>
  43. public Vector2 ParallaxFactor { get; set; }
  44. /// <summary>
  45. /// Gets the custom properties of the layer.
  46. /// </summary>
  47. public TilemapProperties Properties { get; }
  48. /// <summary>
  49. /// Gets the bounding rectangle of the layer in world coordinates.
  50. /// </summary>
  51. public abstract Rectangle Bounds { get; }
  52. /// <summary>
  53. /// Initializes a new instance of the <see cref="TilemapLayer"/> class.
  54. /// </summary>
  55. /// <param name="name">The name of the layer.</param>
  56. protected TilemapLayer(string name)
  57. {
  58. Name = name;
  59. IsVisible = true;
  60. Opacity = 1.0f;
  61. ParallaxFactor = Vector2.One;
  62. Properties = new TilemapProperties();
  63. }
  64. }
  65. }