using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Moloch { public class StateMachine : MonoBehaviour { BaseState m_currentState; void Start () { m_currentState = GetInitialState(); if (m_currentState != null) m_currentState.Enter(); } void FixedUpdate() { if (m_currentState != null) m_currentState.UpdateLogic(); } public void SwitchState(BaseState nextState) { m_currentState.Exit(); m_currentState = nextState; m_currentState.Enter(); } protected virtual BaseState GetInitialState() { return null; } } }