public bool ChangeGlobalState(FSMState <T> NewGlobalState) { if (NewGlobalState != null) { GlobalState.Exit(Owner); NewGlobalState.Enter(Owner); GlobalState = NewGlobalState; return(true); } else { return(false); } }
public void SetGlobalState(State <T> NewGlobalState) { //if a global state currently exists then exit i if (GlobalState != null) { GlobalState.Exit(Entity); //remove change state request from old global GlobalState.ChangeStateRequest -= CurrentState_ChangeStateRequest; } //set new global state GlobalState = NewGlobalState; // Update GUI OnGlobalStateChanged(GlobalState); //connect up to the global states change state request GlobalState.ChangeStateRequest += CurrentState_ChangeStateRequest; //enter new global state GlobalState.Enter(Entity); }