// Initialize a runtime event receiver via the state's event configuration and add it to the event receiver dictionary
        private BaseEventReceiver InitializeAndAddEventReceiver(string stateName)
        {
            InteractionState state = stateManager.GetState(stateName);

            BaseInteractionEventConfiguration eventConfiguration = (BaseInteractionEventConfiguration)state.EventConfiguration;

            string subStateName = state.GetSubStateName();

            // Find the associated event receiver for the state if it has one
            var eventReceiverTypes = TypeCacheUtility.GetSubClasses <BaseEventReceiver>();

            Type eventReceiver;

            try
            {
                eventReceiver = eventReceiverTypes?.Find((type) => type.Name.StartsWith(subStateName));
            }
            catch
            {
                eventReceiver = null;
            }

            if (eventReceiver != null)
            {
                eventConfiguration.EventReceiver = Activator.CreateInstance(eventReceiver, new object[] { eventConfiguration }) as BaseEventReceiver;
            }
            else
            {
                eventConfiguration.EventReceiver = Activator.CreateInstance(typeof(StateReceiver), new object[] { eventConfiguration }) as BaseEventReceiver;
            }

            EventReceivers.Add(stateName, eventConfiguration.EventReceiver);

            return(eventConfiguration.EventReceiver);
        }
 public SelectFarReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public StateReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }
 public ToggleOnReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public PressedNearReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }
 public FocusReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }
Ejemplo n.º 7
0
 public ClickedReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }
 /// <summary>
 /// Constructor for an event receiver.
 /// </summary>
 /// <param name="eventConfiguration">The associated serialized event configuration for an event receiver.</param>
 public BaseEventReceiver(BaseInteractionEventConfiguration eventConfiguration)
 {
     EventConfiguration = eventConfiguration;
     StateName          = EventConfiguration.StateName;
 }
        /// <summary>
        /// Create and add a new state given the state name and the associated existing event configuration.
        /// </summary>
        /// <param name="stateName">The name of the state to create</param>
        /// <param name="eventConfiguration">The existing event configuration for the new state</param>
        /// <returns>The new state added</returns>
        public InteractionState AddNewStateWithCustomEventConfiguration(string stateName, BaseInteractionEventConfiguration eventConfiguration)
        {
            InteractionState state = GetState(stateName);

            if (state == null)
            {
                // Check if the new state name defined is considered a core state
                if (!coreStates.Contains(stateName))
                {
                    InteractionState newState = AddNewState(stateName);

                    if (eventConfiguration != null)
                    {
                        // Set the event configuration if one exists for the core interaction state
                        EventReceiverManager.SetEventConfiguration(newState);
                    }
                    else
                    {
                        Debug.LogError("The event configuration entered is null and the event configuration was not set");
                    }

                    // Add the state to the States list to ensure the inspector displays the new state
                    interactionStates.Add(newState);

                    statesDictionary.Add(newState.Name, newState);
                    return(newState);
                }
                else
                {
                    Debug.LogError($"The state name {stateName} is a defined core state, please use AddCoreState() to add to the States list.");
                    return(null);
                }
            }
            else
            {
                Debug.LogError($"The {stateName} state is already tracking, please use another name.");
                return(state);
            }
        }
 public SpeechKeywordReceiver(BaseInteractionEventConfiguration eventConfiguration) : base(eventConfiguration)
 {
 }