using UnityEngine;

namespace mgaia.Utils.Pause
{
    /// <summary>
    /// Classe de pause que pausa todos os rigidbodies e animations rodando dentro de grupos
    /// </summary>
    /// <owner>Victor</owner>
    public class PhysicsPauseManager : BasePauseManager
    {
        public static PhysicsPauseManager Instance { get; private set; }

        static PhysicsPauseManager()
        {
            Instance = new PhysicsPauseManager();
        }

        /// <summary>
        /// Procura por ocorrências de PausableBehaviourGroup e pausa ou despausa todas as animações e rigidbodies internos destes
        /// </summary>
        protected override void HandlePauseStateChanged(bool isPaused)
        {
            foreach (PausableBehaviourGroup pausableBehaviourGroup in GameObject.FindObjectsOfType<PausableBehaviourGroup>())
            {
                pausableBehaviourGroup.SetPauseState(isPaused);
            }
        }
    }
}