public void Dispose() { this.Active = false; activeStates = null; stateMachine = null; enterL.Dispose(); enterL = null; exitL.Dispose(); exitL = null; enterCallback = null; exitCallback = null; }
public StateEnterWatcher(StateMachine stateMachine, List <int> activeStates, Action enterState, Action exitState) { this.stateMachine = stateMachine; this.activeStates = activeStates; this.enterCallback = enterState; this.exitCallback = exitState; enterL = new SimpleListener <int>((state) => { if (!inState && activeStates.Contains(state)) { inState = true; enterCallback(); } }); exitL = new SimpleListener <int, int>((exit, enter) => { if (inState && !activeStates.Contains(enter)) { inState = false; exitCallback(); } }); NotifyActiveStatesChanged(); }