Exemplo n.º 1
0
 /// <summary>
 /// Checks the transitions, swaps the current state if any return true.
 /// Then updates the current state if we have one
 /// </summary>
 public void DoState(ref T obj)
 {   //Don't do anything if we don't have a reference to the controller
     if (EqualityComparer <T> .Default.Equals(obj, default))
     {
         return;
     }
     //Represents the start function
     if (_current == null && _target != null)
     {
         _current = _target;
         _current.State_Start(ref obj);
     }
     //Make sure we have a state we can call
     if (_current != null)
     {
         //Do we need to make a global transition                    //Do we need to make a transition out of the current state
         if (CheckTransitions(ref obj, ref globalTransitions, null) || CheckTransitions(ref obj, ref _current.transitions, _current.ignoreTransition))
         {
             //Swap the states
             SwapStates(ref obj);
         }
         //Call update on our current state
         _current.State_Update(ref obj);
     }
 }