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

namespace mgaia.Utils
{
    /// <summary>
    /// Behaviour utilizado para receber os eventos de timing da Unity
    /// </summary>
    /// <owner>Victor</owner>
    public class GameTimeBridgeBehaviour : MonoBehaviour
    {
        private Action<float> mUpdateHandler;
        private Action<float> mFixedUpdateHandler;

        public void Initialize(Action<float> updateHandler, Action<float> fixedUpdateHandler)
        {
            Assert.AssertTrue(updateHandler != null, "updateHandler não pode ser nulo!");
            Assert.AssertTrue(fixedUpdateHandler != null, "fixedUpdateHandler naõ pode ser nulo!");

            mUpdateHandler = updateHandler;
            mFixedUpdateHandler = fixedUpdateHandler;
        }

        private void Update()
        {
            mUpdateHandler(Time.deltaTime);
        }

        private void FixedUpdate()
        {
            mFixedUpdateHandler(Time.fixedDeltaTime);
        }
    }
}