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

public class Fan : MonoBehaviour
{
    public float length = 8;
    public Vector3 rotationSpeed;
    public Transform anchor;
    public ValueProvider value;
    public Transform halo;

    public GameObject wind;
    public Wind[] winds;

    private void Start()
    {
        OnValidate();
    }

    private void Update()
    {
        wind.SetActive(value.value);

        halo.localScale = new Vector3(1, 1, length);
        halo.gameObject.SetActive(value.value);

        if (value.value)
        {
            anchor.Rotate(rotationSpeed * Time.deltaTime, Space.Self);
        }
    }

    private void OnValidate()
    {
        foreach (var wind in winds)
        {
            wind.maxLength = length;
        }
        halo.localScale = new Vector3(1, 1, length);
    }
}
