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