using System;
using UnityEngine;

namespace Ingvar.LiveWatch.TowerDefenceDemo
{
    [DefaultExecutionOrder(-99999)]
    public class TD_WatchManager : MonoBehaviour
    {
        private void Awake()
        {
            Watch.DestroyAll();

            Watch.GetOrAdd("Frame", () => Time.frameCount)
                .SetAlwaysCollapsable()
                .SetSortOrder(TD_WatchSortOrder.Frame);

            Watch.GetOrAdd("FPS", () => (int)(1f / Time.unscaledDeltaTime))
                .SetAlwaysCollapsable()
                .SetSortOrder(TD_WatchSortOrder.FPS);

            Watch.GetOrAdd("TimeScale", () => Time.timeScale)
                .SetAlwaysCollapsable()
                .SetSortOrder(TD_WatchSortOrder.TimeScale);
        }
        
        private void LateUpdate()
        {
            Watch.UpdateAll();
        }
    }
}