Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
 /// <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;
 }
Exemplo n.º 3
0
 /// <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;
 }
Exemplo n.º 4
0
 /// <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);
     }
 }
Exemplo n.º 5
0
        /// <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);
            }
        }
Exemplo n.º 6
0
 public int GetStateID(TSSState state)
 {
     return(states.FindIndex(s => s == state));
 }