TilemapObject.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Microsoft.Xna.Framework;
  2. namespace MonoGame.Extended.Tilemaps
  3. {
  4. /// <summary>
  5. /// Base class for all tilemap objects
  6. /// </summary>
  7. public abstract class TilemapObject
  8. {
  9. /// <summary>
  10. /// Gets the unique identifier for this object.
  11. /// </summary>
  12. public int Id { get; }
  13. /// <summary>
  14. /// Gets or sets the name of the object.
  15. /// </summary>
  16. public string Name { get; set; } = string.Empty;
  17. /// <summary>
  18. /// Gets or sets the class/type identifier for the object.
  19. /// </summary>
  20. public string Class { get; set; } = string.Empty;
  21. /// <summary>
  22. /// Gets or sets the position of the object in world coordinates.
  23. /// </summary>
  24. public Vector2 Position { get; set; }
  25. /// <summary>
  26. /// Gets or sets the rotation of the object in radians.
  27. /// </summary>
  28. public float Rotation { get; set; }
  29. /// <summary>
  30. /// Gets or sets a value indicating whether the object is visible.
  31. /// </summary>
  32. public bool IsVisible { get; set; }
  33. /// <summary>
  34. /// Gets the custom properties of the object.
  35. /// </summary>
  36. public TilemapProperties Properties { get; }
  37. /// <summary>
  38. /// Gets the axis-aligned bounding rectangle that encloses the object.
  39. /// </summary>
  40. public abstract RectangleF Bounds { get; }
  41. // TODO: BoundingVolume property will be added when IBoundingVolume2D is integrated
  42. // public abstract IBoundingVolume2D BoundingVolume {get;}
  43. protected TilemapObject(int id, Vector2 position)
  44. {
  45. Id = id;
  46. Position = position;
  47. IsVisible = true;
  48. Properties = new TilemapProperties();
  49. }
  50. }
  51. }