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

public class Socket : MonoBehaviour {

    public bool socketFilled;
    public Cable cableInSocket;

    public void Start ()
    {
        SocketController.AddSocket(this);
    }

    public void OnDestroy ()
    {
        SocketController.RemoveSocket(this);
    }
    
    public void FillSocketWithCable (SocketChannelSettings channel,  CableSettings cableSettings)
    {
        if (!socketFilled)
        {
            cableInSocket = CableGenerator.CreateCableWithSettingsAtPos(channel, cableSettings, transform.position);
            socketFilled = true;
        }
    }

    public void ClearSocket ()
    {
        if (cableInSocket != null)
        {
            Destroy(cableInSocket.gameObject);
        }

        socketFilled = false;
    }
}
