public bool Transit(APlayerState toState) { //TODO:[Gafgar: Sat/01-02-2020] implement recursive guard! if (toState.CanEnter(this, mState)) { mState.Exit(this, toState); var oldState = mState; mState = toState; mState.Enter(this, oldState); return(true); } return(false); }
//Called when chaining to a new state. Before the new state can call enter. NOTICE: Never call transit from within the enter or exit functions to avoid recursive. public virtual void Exit(PlayerController p, APlayerState toState) { }
//Called after previous state have exited. NOTICE: Never call transit from within the enter or exit functions to avoid recursive. //Enter on the default state must be able to accept null as the from state. public virtual void Enter(PlayerController p, APlayerState fromState) { }
//return if we can enter this state or not (check for prerequisites if there are any) public virtual bool CanEnter(PlayerController p, APlayerState fromState) { return(true); }
public override void Enter(PlayerController p, APlayerState fromState) { mTimer = 0; }