using System; using UnityEngine; namespace Syntriax.Modules.State { public class StateEnableMonoBehaviour : MonoBehaviour, IStateEnable { private bool _isEnabled = true; public bool IsEnabled { get => _isEnabled; set { if (value == _isEnabled) return; _isEnabled = value; OnEnabledChanged?.Invoke(value); } } public Action OnEnabledChanged { get; set; } = null; protected void Awake() => OnEnabledChanged += (state) => enabled = state; protected void OnEnable() => IsEnabled = true; protected void OnDisable() => IsEnabled = false; } }