//Allow user of this method to optionally pass in a stance for a more detailed lookup.
    public FacialAnimationData GetFacialAnimation(string type, string actionID, InteractionAnimationType interactionType, Stance stance)
    {
        try
        {
            if (this.databases.ContainsKey(type))
            {
                actionID = actionID.ToLower();
                List <FacialAnimationData> list = this.databases[type];
                FacialAnimationData        item = null;

                //Track how many recursive runs we have done, so we dont run into stack overflows.
                this.searchDepth += 1;

                for (int i = 0; i < list.Count; i++)
                {
                    FacialAnimationData currentItem = list[i];

                    if (string.Compare(currentItem.ID, actionID, true) == 0 && currentItem.Stance == (int)stance && currentItem.InteractionType == interactionType)
                    {
                        item = currentItem;
                        break;
                    }
                }

                //We did not find a excakt match for the facial animation we where looking for, try to find an approximate hit.
                if (item == null && this.searchDepth <= MaxSearchDepth)
                {
                    //If first iteration fails we use lookup based on stance.
                    if (searchDepth == 1)
                    {
                        if ((stance & Stance.UseStanding) != 0)
                        {
                            item = GetFacialAnimation(type, actionID, interactionType, Stance.StandingNormal);
                        }

                        if ((stance & Stance.UseSitting) != 0)
                        {
                            item = GetFacialAnimation(type, actionID, interactionType, Stance.SittingNormal);
                        }
                    }
                    //Else we default to standing stance.
                    else
                    {
                        item = GetFacialAnimation(type, actionID, interactionType, Stance.StandingNormal);
                    }
                }

                //Reset for the next caller.
                this.searchDepth = 0;

                return(item);
            }
        }
        catch (Exception e)
        {
            //CrashHelp.Report("AnimationMetaDatabase", e.Message, e);
        }

        return(null);
    }
Esempio n. 2
0
    public FacialAnimationClip ConstructFacialAnimationClip(string type, string actionID, string stance, InteractionAnimationType interactionType = InteractionAnimationType.Null)
    {
        FacialAnimationData data = FacialAnimationDatabase.Instance.GetFacialAnimation(type, actionID, interactionType, AnimationUtilities.StanceStringToEnum(stance));

        if (data != null)
        {
            FacialAnimationClip clip = FillAnimationClip(data);

            return(clip);
        }

        return(null);
    }
    public static string BuildStateInfo(AnimationType type, string actionID, string stance, InteractionAnimationType interactionType = InteractionAnimationType.Null, bool mirror = false)     //skeleton for later missdeads
    {
        string state = type.ToString() + stance + "." + actionID;

        if (interactionType != InteractionAnimationType.Null)
        {
            state += "_" + interactionType.ToString().ToLower();
        }
        if (mirror)
        {
            state += "_mirror";
        }

        return(state);
    }