// Change state from the previous state, if any, and begin working in the new state. // The previous state's onExit() and the new state's onEnter() will both be called. public void ChangeState(ImmediateStateDelegate enter, ImmediateStateDelegate update, ImmediateStateDelegate exit) { // If a state is currently running, it should be allowed to gracefully exit // before the next state takes over if (this.exit != null) { this.exit(); } // Cache the given state values this.enter = enter; this.update = update; this.exit = exit; // If a state isn't currently running, we can immediately switch to our entering // state using the state delegates we cached a few lines above if (this.enter != null) { this.enter(); } }
public bool IsInState(ImmediateStateDelegate update) { return(this.update == update); }
public bool IsUsingThisUpdateDelegate(ImmediateStateDelegate update) { return(this.update == update); }