using UnityEngine;

namespace ScrambleKit.ProcGen
{
    public class IntervalPlacement : MonoBehaviour
    {
        public Transform Prefab;

        public int Rows;
        public int Cols;

        public float XInterval;
        public float YInterval;

        void Start()
        {
            for (int r = 0; r < Rows; r++)
            {
                for (int c = 0; c < Cols; c++)
                {
                    Vector3 position = transform.position + new Vector3(r * XInterval, c * YInterval, 0);
                    PlaceOneAt(position);
                }
            }
        }

        private void PlaceOneAt(Vector3 pos)
        {
            Transform t = Instantiate(Prefab);
            t.position = pos;
        }
    }
}