abstract public class FSMState  <T>  
{
	abstract public void enter (T entity);
	abstract public void exit(T entity);
}

public class FiniteStateMachine <T>  
{
	T m_Owner;
	FSMState<T> m_CurrentState;

	public void init()
	{
		m_CurrentState = null;
	}

	public void configure(T owner, FSMState<T> initialState)
	{
		m_Owner = owner;
		changeState(initialState);
	}

	public void changeState(FSMState<T> newState)
	{
		if (m_CurrentState != null)
			m_CurrentState.exit(m_Owner);
		m_CurrentState = newState;
		if (m_CurrentState != null)
			m_CurrentState.enter(m_Owner);
	}

	public FSMState<T> getState()
	{
		return m_CurrentState;
	}
};