Exemple #1
0
        private static void tweakerSendEvent([NamedToggleValue(typeof(StateMachineContextNameGenerator), 0u)] string contextName, [NamedToggleValue(typeof(StateMachineNameGenerator), 0u)] string targetString, string eventString)
        {
            StateMachineContext stateMachineContext = null;

            StateMachineContext[] array = UnityEngine.Object.FindObjectsOfType <StateMachineContext>();
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].name == contextName)
                {
                    stateMachineContext = array[i];
                    break;
                }
            }
            if (stateMachineContext != null)
            {
                if (stateMachineContext.ContainsStateMachine(targetString))
                {
                    stateMachineContext.SendEvent(new ExternalEvent(targetString, eventString));
                    return;
                }
                Log.LogErrorFormatted(typeof(StateMachineContext), "StateMachineContext {0} does not contain StateMachine {1}", contextName, targetString);
            }
            else
            {
                Log.LogErrorFormatted(typeof(StateMachineContext), "Could not find a StateMachineContext with name {0}", contextName);
            }
        }
Exemple #2
0
        private void Awake()
        {
            StateMachineContext componentInParent = GetComponentInParent <StateMachineContext>();

            componentInParent.AddStateMachineProxy(TargetStateMachine, this);
            events = new Queue <string>();
        }
Exemple #3
0
        public void OnDestroy()
        {
            StateMachineContext componentInParent = GetComponentInParent <StateMachineContext>();

            if (componentInParent != null)
            {
                for (int i = 0; i < Bindings.Length; i++)
                {
                    string text = Bindings[i].Name;
                    componentInParent.RemoveStateMachine(text);
                }
            }
        }
        private IEnumerator Start()
        {
            while (Context == null)
            {
                yield return(null);

                Context = ContextTarget.GetComponentInChildren <StateMachineContext>();
                if (Context != null && this.OnContextAdded != null)
                {
                    yield return(new WaitForEndOfFrame());

                    this.OnContextAdded(Context);
                }
            }
        }
Exemple #5
0
 private void init()
 {
     pendingStateChanges = new Queue <string>();
     if (context == null)
     {
         context = GetComponentInParent <StateMachineContext>();
         context.AddStateMachine(this);
     }
     if (Definition != null)
     {
         if (Definition.PersistState && context.GetPersistentState(base.name) != null)
         {
             currentState = context.GetPersistentState(base.name);
         }
         else
         {
             currentState = Definition.States[0];
         }
         if (this.InitialStateSet != null)
         {
             this.InitialStateSet(this);
         }
     }
 }