public override void OnExit(MyContext context, SuperState newState) { if (ParentOf(newState)) return; Console.WriteLine("AA - Run on exit code"); base.OnExit(context, newState); }
public override void OnEnter(MyContext context, SuperState oldState) { if (ParentOf(oldState)) return; base.OnEnter(context, oldState); Console.WriteLine("AB - Run on enter code"); }
static void Main(string[] args) { Console.WriteLine("# Starting in A"); var stm = new MyContext(); Console.WriteLine("\n# Going to B"); stm.State.GotoB(stm); Console.WriteLine("\n# Going to AA"); stm.State.GotoAA(stm); Console.WriteLine("\n# Going to AA"); stm.State.GotoAB(stm); Console.WriteLine("\n# Going to B"); stm.State.GotoB(stm); Console.WriteLine("\n# Going to A"); stm.State.GotoA(stm); }
public virtual void GotoB(MyContext context) { var newState = new B(); context.LeaveState(newState); Console.WriteLine("Going To B Action"); context.SetState(newState, this); }
public virtual void OnExit(MyContext context, SuperState newState) { }