Ejemplo n.º 1
0
        private static CM.Animation getEffectingAnimation(IStoryAction <UintT> storyAction, CM.DomainAction domainAction)
        {
            //find effector if any
            CM.AnimateAction effectorAnimateAction = domainAction.AnimateActions.Find(x => x.Effector);
            //didn't find an effector for this domain action...move along; nothing to see here
            if (effectorAnimateAction == null)
            {
                return(null);
            }

            string effectorActorName = null;

            CM.AnimationMapping effectorAnimationMapping = null;
            CM.Animation        effectingAnimation       = null;
            foreach (CM.DomainActionParameter domainActionParameter in domainAction.Params)
            {
                if (domainActionParameter.Name == effectorAnimateAction.ActorNameParamName)
                {
                    IActionProperty actorNameProperty;
                    if (storyAction.TryGetProperty(domainActionParameter.Name, out actorNameProperty))
                    {
                        effectorActorName = actorNameProperty.Value.Name;
                    }
                    if (effectorActorName == null)
                    {
                        Debug.LogError("actorName not set for stepId[" + storyAction.Name + "]");
                        return(null);
                    }
                    string abstractEffectorActorName;
                    if (!getAbstractActorName(effectorActorName, out abstractEffectorActorName))
                    {
                        Extensions.Log("Failed to find effectorActorName[{0}] in hierarchy for stepid[{1}]", effectorActorName, storyAction.Name);
                        return(null);
                    }

                    CM.Actor effectorActor;
                    if (!cm.TryGetActor(abstractEffectorActorName, out effectorActor))
                    {
                        Extensions.Log("effector actor [{0}] undefined for step[{1}]", effectorActorName, storyAction.Name);
                        return(null);
                    }
                    if (!effectorActor.TryGetAnimationMapping(effectorAnimateAction.Name, out effectorAnimationMapping))
                    {
                        Extensions.Log("cinematic model animation instance undefined for actor[" +
                                       effectorActorName + "] action[" + domainAction.Name + "] paramName[" + domainActionParameter.Name + "]");
                        return(null);
                    }
                    effectingAnimation = cm.FindAnimation(effectorAnimationMapping.AnimationName);
                    if (effectingAnimation == null)
                    {
                        Debug.LogError(string.Format("animation name [{0}] undefined.", effectingAnimation));
                    }
                }
            }
            return(effectingAnimation);
        }