29 lines
739 B
C#
29 lines
739 B
C#
using BlueWater.Interfaces;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|