using System; using UnityEngine; namespace AI.FSM { public class ChaseStateMachine : MonoBehaviour, IFiniteStateMachine { [SerializeField] private Transform player; private IState _currentState; // private IdleState _idleState; // private PlayerDetectedState _playerDetectedState; // // ... // private void Awake() // { // _idleState = new IdleState(); // _playerDetectedState = new PlayerDetectedState(); // // ... // } private void OnEnable() { ChangeState(new IdleState(gameObject, player, 30.0f)); } private void OnDisable() { ChangeState(null); } public void Update() { _currentState?.Update(this); } public void ChangeState(IState state) { _currentState?.Exit(this); _currentState = state; _currentState?.Enter(this); } // public void ChangeState(States state) // { // _currentState?.Exit(this); // // switch (state) // { // case States.Idle: // _currentState = _idleState; // break; // case States.PlayerDetected: // _currentState = _playerDetectedState; // break; // case States.PlayerInRange: // break; // case States.PlayerOutOfRange: // break; // default: // throw new ArgumentOutOfRangeException(nameof(state), state, null); // } // // _currentState?.Enter(this); // } } }