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

namespace mgaia.Utils.StateMachine
{
    /// <summary>
    /// Classe que representa um estado criado através de delegates para evitar o overhead de classes
    /// </summary>
    /// <owner>Victor</owner>
    public class DelegateState<TOwner> : IState<TOwner>
    {
        /// <summary>
        /// Delegate que representa um método que executa um estado
        /// </summary>
        public delegate void DelegateStateHandler(TOwner owner);

        private DelegateStateHandler mHandler;

        public DelegateState(DelegateStateHandler handler)
        {
            mHandler = handler;
        }

        /// <summary>
        /// Roda o estado, chamando o delegate
        /// </summary>
        public void Run(TOwner owner)
        {
            mHandler(owner);
        }
    }
}