/// <summary>Remove specified state by state pointer</summary> /// <param name="state">state pointer</param> public void RemoveState(TSSState state) { if (states.Contains(state)) { states.Remove(state); } }
/// <summary>Close all states</summary> /// <param name="stateName">state identifier</param> public void CloseAll() { states.ForEach(s => s.Close()); if (currentState != null && useEvents) { OnCurrentStatedClosed.Invoke(currentState); } currentState = null; }
/// <summary>Set specified state as default core state</summary> /// <param name="state">state pointer</param> public void SetDefaultState(TSSState state) { states.ForEach(s => s.isDefault = false); if (state == null) { return; } state.isDefault = true; }
/// <summary>Close specified state</summary> /// <param name="state">state pointer</param> public void Close(TSSState state) { state.Close(); if (state != currentState) { return; } currentState = null; if (useEvents) { OnCurrentStatedClosed.Invoke(state); } }
/// <summary>Open specified state</summary> /// <param name="state">state pointer</param> public void SelectState(TSSState state) { if (state == null || !state.enabled) { switch (incorrectAction) { case IncorrectStateAction.openDefault: SelectDefaultState(); break; case IncorrectStateAction.closeAll: states.ForEach(s => s.Close()); break; } currentState = null; if (useEvents) { OnIncorrectStateSelected.Invoke(); } return; } currentState = state; states.Where(s => s.name.ToLower() != state.name.ToLower()).ToList().ForEach(s => s.Close()); currentState.Open(); if (!useEvents) { return; } OnStateSelected.Invoke(currentState); if (currentState == FirstEnabled || currentState == First) { OnFirstStateSelected.Invoke(currentState); } if (currentState == LastEnabled || currentState == Last) { OnLastStateSelected.Invoke(currentState); } }
public int GetStateID(TSSState state) { return(states.FindIndex(s => s == state)); }