2025-02-10 02:13:46 +00:00
|
|
|
using DDD.Interfaces;
|
2024-10-22 12:41:31 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
2025-02-10 02:13:46 +00:00
|
|
|
namespace DDD
|
2024-10-22 12:41:31 +00:00
|
|
|
{
|
|
|
|
public class StateMachineController<T> where T : MonoBehaviour
|
|
|
|
{
|
|
|
|
private IStateMachine<T> _currentState;
|
|
|
|
|
|
|
|
public StateMachineController(T character, IStateMachine<T> startState)
|
|
|
|
{
|
|
|
|
_currentState = startState;
|
|
|
|
_currentState.EnterState(character);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateState(T character)
|
|
|
|
{
|
|
|
|
_currentState.UpdateState(character);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void TransitionToState(IStateMachine<T> newState, T character)
|
|
|
|
{
|
|
|
|
_currentState.ExitState(character);
|
|
|
|
_currentState = newState;
|
|
|
|
_currentState.EnterState(character);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|