using UnityEngine;
using System.Collections.Generic;
using Core;

namespace Script.Gameplay.Connect
{
    public class ConnectionLineManager : MonoSingleton<ConnectionLineManager>
    {
        [SerializeField] private GameObject linePrefab; 
        public List<ConnectionLine> connectionLines = new List<ConnectionLine>();
        
        public ConnectionLine GenerateConnectionLine(IConnectable source, IConnectable target)
        {
            GameObject lineObject = Instantiate(linePrefab, this.transform);
            ConnectionLine connectionLine = lineObject.GetComponent<ConnectionLine>();
            if (connectionLine != null)
            {
                connectionLine.SetConnectable(source, target);
                connectionLines.Add(connectionLine);
                return connectionLine;
            }
            return null;
        }
    }
}