/// <summary>
        /// Checks if initialization is needed, and if so runs <see cref="T:State_Namespace.StateInitialization"/> methods. Should not be called directly by users.
        /// </summary>
        void CheckInitialization()
        {
            if (!initialized)
            {
                if (DebugActive)
                {
                    Debug.Log("Control Level " + Parent.ControlLevelName + ": State " + StateName + " initialization on Frame " + Time.frameCount + ".");
                }
                //reset default State characteristics
                StateActiveInitialization = null;
                initialized = true;
                Terminated  = false;
                Successor   = null;

                //setup State timing
                TimingInfo.StartFrame        = Time.frameCount;
                TimingInfo.StartTimeAbsolute = Time.time;
                TimingInfo.StartTimeRelative = TimingInfo.StartTimeAbsolute - Parent.StartTimeRelative;
                TimingInfo.EndFrame          = -1;
                TimingInfo.EndTimeAbsolute   = -1;
                TimingInfo.EndTimeRelative   = -1;
                TimingInfo.Duration          = -1;
                //If previous state specified this state's initialization, run it
                if (StateActiveInitialization != null)
                {
                    StateActiveInitialization.InitializationMethod();
                }
                //Otherwise run default initialization
                else if (StateDefaultInitialization != null)
                {
                    StateDefaultInitialization.InitializationMethod();
                }
            }
        }
        public void SpecifyTermination(BoolDelegate terminationCriterion, State successorState, string successorInitName, VoidDelegate termination = null)
        {
            if (Parent.CheckForState(successorState) || successorState == null)
            {
                StateInitialization init = null;
                if (successorInitName != null)
                {
                    foreach (StateInitialization iinit in StateInitializations)
                    {
                        if (iinit.Name == successorInitName)
                        {
                            init = iinit;
                        }
                    }
                }

                StateTerminationSpecifications.Add(new StateTerminationSpecification(terminationCriterion, successorState, init, termination));
                if (StateDefaultTermination == null && termination != null)
                {
                    StateDefaultTermination = termination;
                }
            }
            else
            {
                Debug.LogError(Parent.ControlLevelName + ": Attempted to add successor state to state " + StateName + " but this state is not found in control level " + Parent.ControlLevelName);
            }
        }
        public void AddDefaultInitializationMethod(VoidDelegate method, string name)
        {
            StateInitialization init = new StateInitialization(method, name);

            StateInitializations.Add(init);
            StateDefaultInitialization = init;
        }
 private void DefineTermination(BoolDelegate terminationCriterion, State successorState, StateInitialization successorInit = null, VoidDelegate termination = null)
 {
     TerminationCriterion = terminationCriterion;
     if (termination != null)
     {
         Termination = termination;
     }
     SuccessorState = successorState;
     if (successorInit != null)
     {
         successorState.StateActiveInitialization = successorInit;
     }
 }
 public StateTerminationSpecification(BoolDelegate terminationCriterion, State successorState, VoidDelegate termination, StateInitialization successorInit = null)
 {
     DefineTermination(terminationCriterion, successorState, successorInit, termination);
 }