using Microsoft.Xna.Framework;
using MonoGame.FourEngine.Interfaces;

namespace MonoGame.FourEngine.Entities
{
    public class CameraEntity : Entity
    {
        public Point Position
        {
            get => Component.Position;
            set => Component.Position = value;
        }

        protected Component Component { get; }

        public CameraEntity()
        {
            Components.Add(Component = new Component());
        }

        public void AttachTo(ICanTransform entity)
        {
            entity.Transformations.Add(Transform);
        }

        public virtual void Transform(SpriteDrawEventArgs args)
        {
            args.DestinationRectangle = new Rectangle(
                args.DestinationRectangle.Location - Component.Position,
                args.DestinationRectangle.Size);
        }
    }
}