using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Kav
{
    public class PointLightCollection
    {
        private readonly Vector3[] positions;
        private readonly Vector3[] colors;

        readonly EffectParameter lightPositionsParam;
        readonly EffectParameter lightColorsParam;

        public PointLightCollection(EffectParameter lightPositionsParam, EffectParameter lightColorsParam, int maxLights)
        {
            positions = new Vector3[maxLights];
            colors = new Vector3[maxLights];
            this.lightPositionsParam = lightPositionsParam;
            this.lightColorsParam = lightColorsParam;
        }

        public PointLight this[int i]
        {
            set
            {
                positions[i] = value.Position;
                colors[i] = value.Color.ToVector3() * value.Radius;
                lightPositionsParam.SetValue(positions);
                lightColorsParam.SetValue(colors);
            }
        }
    }
}