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

public class ItemManager : MonoBehaviour
{
    public E_ItemType itemType;

    private Vector3 rotationEulers;
    private CoroutineHandle rotationHandle;

    private void Start()
    {
        rotationHandle = Timing.RunCoroutine(C_RotatePlanet());
    }

    private void OnBecameVisible()
    {
        Timing.ResumeCoroutines(rotationHandle);
    }

    private void OnBecameInvisible()
    {
        Timing.PauseCoroutines(rotationHandle);
    }

    private IEnumerator<float> C_RotatePlanet()
    {
        rotationEulers = new Vector3(3f, 6f, 0f) * Time.deltaTime;
        while (true)
        {
            transform.Rotate(rotationEulers);

            yield return Timing.WaitForOneFrame;
        }
    }
}
