/// <summary> /// Create and add a new state to track given the new state name. Also sets the state's event configuration. /// </summary> /// <param name="stateName">The name of the state to add</param> /// <returns>The new state added</returns> public InteractionState AddNewState(string stateName) { // Check if the state name is an empty string if (stateName == string.Empty) { Debug.LogError("The state name entered is empty, please add characters to the state name."); return(null); } // If the state does not exist, then add it if (!statesDictionary.ContainsKey(stateName)) { InteractionState newState = new InteractionState(stateName); statesDictionary.Add(newState.Name, newState); // Add the state to the States list to ensure the inspector displays the new state interactionStates.Add(newState); // Set the event configuration if one exists for the core interaction state EventReceiverManager.SetEventConfiguration(newState); // Set special cases for specific states SetStateSpecificSettings(newState); return(newState); } else { Debug.Log($" The {stateName} state is already being tracked and does not need to be added."); return(GetState(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); } }