TilemapTileData.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Collections.Generic;
  2. using Microsoft.Xna.Framework.Graphics;
  3. namespace MonoGame.Extended.Tilemaps
  4. {
  5. /// <summary>
  6. /// Represents metadata and properties for a specific tile in a tileset.
  7. /// </summary>
  8. /// <remarks>
  9. /// Tile data contains information such as custom properties, animations,
  10. /// collision shapes, and custom images for individual tiles.
  11. /// </remarks>
  12. public class TilemapTileData
  13. {
  14. /// <summary>
  15. /// Gets the local tile ID within the tileset.
  16. /// </summary>
  17. public int LocalId { get; }
  18. /// <summary>
  19. /// Gets or sets the class/type identifier for the tile.
  20. /// </summary>
  21. public string Class { get; set; } = string.Empty;
  22. /// <summary>
  23. /// Gets or sets the probability of this tile being used in random tile generation.
  24. /// </summary>
  25. /// <value>A value between 0.0 and 1.0, where 1.0 is the default probability.</value>
  26. public float Probability { get; set; }
  27. /// <summary>
  28. /// Gets the custom properties of the tile.
  29. /// </summary>
  30. public TilemapProperties Properties { get; }
  31. /// <summary>
  32. /// Gets or sets the animation data for animated tiles.
  33. /// </summary>
  34. public TilemapTileAnimation Animation { get; set; }
  35. /// <summary>
  36. /// Gets the collision objects associated with this tile.
  37. /// </summary>
  38. /// <remarks>
  39. /// Collision objects define the collision shape(s) for the tile and will be
  40. /// integrated with the 2D collision system.
  41. /// </remarks>
  42. public List<TilemapObject> CollisionObjects { get; }
  43. /// <summary>
  44. /// Gets or sets a custom image texture for this tile.
  45. /// </summary>
  46. /// <remarks>
  47. /// When set, this texture overrides the tileset's atlas texture for this specific tile.
  48. /// </remarks>
  49. public Texture2D CustomImage { get; set; }
  50. /// <summary>
  51. /// Initializes a new instance of the <see cref="TilemapTileData"/> class.
  52. /// </summary>
  53. /// <param name="localId">The local tile ID within the tileset.</param>
  54. public TilemapTileData(int localId)
  55. {
  56. LocalId = localId;
  57. Properties = new TilemapProperties();
  58. CollisionObjects = new List<TilemapObject>();
  59. Probability = 1.0f;
  60. }
  61. }
  62. }