public bool TryGetAnimationMapping(string animateActionName, out AnimationMapping animationMapping) { animationMapping = findAnimationMapping(animateActionName); if (animationMapping == null) { return(false); } return(true); }
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); }
private static bool getAnimationMapping(string actorName, string animateActionName, out CM.AnimationMapping animationMapping) { animationMapping = null; CM.Actor actor = null; if (cm.TryGetActor(actorName, out actor) && actor.TryGetAnimationMapping(animateActionName, out animationMapping)) { return(true); } return(false); }
private static void enqueueAnimateActions(IStoryAction <UintT> storyAction, CM.DomainAction domainAction, CM.Animation effectingAnimation, FireBoltActionList aaq, string parentActionId, bool implicitActorInstantiation) { foreach (CM.AnimateAction animateAction in domainAction.AnimateActions) { string actorName = null; string abstractActorName = null; float startTick = 0; float endTick = 0; CM.AnimationMapping animMapping = null; CM.AnimationMapping stateMapping = null; CM.Animation animation = null; CM.Animation stateAnimation = new CM.Animation(); string endName = !string.IsNullOrEmpty(animateAction.End) ? animateAction.End : string.Empty; string animateActionName = animateAction.Name; //PURPOSE: if domain action parameter is the name of an animateAction for that domain action as defined in the cinematic model, //then use the parameter value as the animateAction name. // Used when a domain action has a variable for accepting an action to play, handy for spawn actions that require an initial state foreach (CM.DomainActionParameter domainActionParameter in domainAction.Params) { //endName = string.Empty; //The endName should not be string.Empty if the below propety is never true. // Extensions.Log("beforeset: " + animateAction.Name + " " + domainActionParameter.Name); if (domainActionParameter.Name.Equals(animateAction.Name)) { getActionParameterValue(storyAction, domainActionParameter, out animateActionName); endName = animateActionName; break; } } foreach (CM.DomainActionParameter domainActionParameter in domainAction.Params) { if (domainActionParameter.Name == animateAction.ActorNameParamName) { if (getActionParameterValue(storyAction, domainActionParameter, out actorName) && (!implicitActorInstantiation || actorWillBeInstantiated(actorName))) { //abstractActorName = actorName; if (!getAbstractActorName(actorName, out abstractActorName)) { //can't figure out what this actor name is supposed to be. don't try to animate it. break; } else { //this forces all levels of hierarchy to implement all animations if we want them played //we can't partially look up levels above for some things //iterate back and forth between finding matching hierarchical parents and looking for mappings to alleviate if (!getAnimationMapping(abstractActorName, animateActionName, out animMapping)) { Extensions.Log("cinematic model animation instance undefined for actor[" + abstractActorName + "] animateAction[" + animateActionName + "]"); break; } } //we have a valid mapping, let's use it to find an animation for this actor animation = cm.FindAnimation(animMapping.AnimationName); if (animation == null) { Extensions.Log("animation name [{0}] undefined", animMapping.AnimationName); break; } //end name is optional, we don't have to do this for the animation to be valid if (!string.IsNullOrEmpty(endName)) { getAnimationMapping(abstractActorName, endName, out stateMapping); if (!(stateMapping == null)) { stateAnimation = cm.FindAnimation(stateMapping.AnimationName); if (stateAnimation == null) { Extensions.Log("state animation name [{0}] undefined", stateMapping.AnimationName); break; } } } } } } startTick = getStartTick(storyAction, animateAction, effectingAnimation); endTick = getEndTick(storyAction, animateAction, effectingAnimation, startTick); if (AnimateMecanim.ValidForConstruction(actorName, animation)) { // Extensions.Log("actor: " + actorName + " animMappingName: " + animMapping.AnimationName + " animateActionName: " + animMapping.AnimateActionName + " loop: " + animMapping.LoopAnimation); aaq.Add(new AnimateMecanim(startTick, endTick, actorName, animation.FileName, animMapping.LoopAnimation, stateAnimation.FileName) { ParentActionId = parentActionId }); } } }