Example #1
0
        /// <summary>
        /// Formats the state name from the AnimatorItemStateData. The result will be in the format "ItemType.ItemType AbilityType.StateName".
        /// </summary>
        /// <param name="stateData">The AnimatorItemStateData to format.</param>
        /// <param name="layer">The layer to use for formatting.</param>
        /// <returns>The formatted state name.</returns>
        public string FormatStateName(AnimatorItemStateData stateData, int layer)
        {
            if (stateData == null)
            {
                return(string.Empty);
            }

            var stateDataName = stateData.Name;
            var stateName     = string.Empty;

            if (stateData.ItemNamePrefix && m_ItemName != null)
            {
                stateName = m_ItemName.Invoke(stateData.ItemType == null ? true : (stateData.ItemType is PrimaryItemType || stateData.ItemType is DualWieldItemType));
            }
            if (stateData.Ability != null)
            {
                // The state name can be overridden by the ability destination state.
                var destinationState = stateData.Ability.GetDestinationState(layer);
                if (!string.IsNullOrEmpty(destinationState))
                {
                    // If the state name is empty then use the destination state. Otherwise, if the state isn't empty then use the item state name instead of the
                    // ability state name.
                    if (string.IsNullOrEmpty(stateData.Name))
                    {
                        stateDataName = destinationState;
                    }
                    else
                    {
                        var substateIndex = destinationState.IndexOf('.');
                        stateDataName = destinationState.Remove(substateIndex + 1, destinationState.Length - substateIndex - 1) + stateData.Name;
                    }
                    if (!string.IsNullOrEmpty(stateName))
                    {
                        stateName += "." + stateName + " ";
                    }
                }
                else
                {
                    stateName += ".";
                }
            }
            else if (!string.IsNullOrEmpty(stateName))
            {
                stateName += ".";
            }
            return(string.IsNullOrEmpty(stateName) ? stateDataName : stateName + stateDataName);
        }
Example #2
0
 /// <summary>
 /// Changes the animator to the specified state.
 /// </summary>
 /// <param name="state">The state to transition to.</param>
 /// <param name="layer">The current animator layer.</param>
 /// <param name="normalizedTime">The normalized time to start playing the animation state.</param>
 /// <returns>True if the state was changed.</returns>
 private bool ChangeItemState(AnimatorItemStateData state, int layer, float normalizedTime)
 {
     m_IgnoreLowerPriority = state.IgnoreLowerPriority;
     return(ChangeAnimatorStates(layer, state, normalizedTime));
 }
Example #3
0
 public string FormatUpperBodyState(AnimatorItemStateData stateData)
 {
     return(FormatStateName(stateData, UpperLayerIndex));
 }
Example #4
0
 public string FormatLowerBodyState(AnimatorItemStateData stateData)
 {
     return(FormatStateName(stateData, BaseLayerIndex));
 }