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

[RequireComponent(typeof(RopeAttachPoint))]
public class PlayPlug : MonoBehaviour {
    public float power = 0;
    private RopeAttachPoint me;
    public UnityEvent callback;

    void Start() {
        me = GetComponent<RopeAttachPoint>();
    }

    // Update is called once per frame
    void Update () {
        foreach( GameObject obj in me.GetConnections() ) {
            Generator generator = obj.GetComponent<Generator>();
            if ( generator != null ) {
                if ( generator.power > 2 ) {
                    generator.power -= 2;
                    /// I'M CONNECTED, DO STUFF
                    callback.Invoke();
                }
            }
        }
    }
}
