Beispiel #1
0
        //Static Methods

        /// <summary>
        /// Inspects a MonoBehaviour for state methods as definied by the supplied Enum, and returns a stateMachine instance used to trasition states.
        /// </summary>
        /// <param name="component">The component with defined state methods</param>
        /// <returns>A valid stateMachine instance to manage MonoBehaviour state transitions</returns>
        public static StateMachine <T> Initialize(MonoBehaviour component)
        {
            var engine = component.GetComponent <StateMachineRunner>();

            if (engine == null)
            {
                engine = component.gameObject.AddComponent <StateMachineRunner>();
            }

            return(engine.Initialize <T>(component));
        }
        /// <summary>
        /// Inspects a MonoBehaviour for state methods as definied by the supplied Enum, and returns a stateMachine instance used to trasition states.
        /// </summary>
        public static StateMachine <T> Initialize(MonoBehaviour i_Component, T i_StartState)
        {
            StateMachineRunner stateMachineRunner = i_Component.GetComponent <StateMachineRunner>();

            if (stateMachineRunner == null)
            {
                stateMachineRunner = i_Component.gameObject.AddComponent <StateMachineRunner>();
            }

            return(stateMachineRunner.Initialize <T>(i_Component, i_StartState));
        }