Exemplo n.º 1
0
 private static void enqueueRotateActions(IStoryAction <UintT> storyAction, CM.DomainAction domainAction,
                                          CM.Animation effectingAnimation, FireBoltActionList aaq,
                                          string parentActionId, bool implicitActorInstantiation)
 {
     foreach (CM.RotateAction ra in domainAction.RotateActions)
     {
         float   startTick     = 0;
         float   endTick       = 0;
         string  actorName     = null;
         float?  targetDegrees = null;
         Vector2?targetPoint   = null;
         foreach (CM.DomainActionParameter domainActionParameter in domainAction.Params)
         {
             if (domainActionParameter.Name == ra.ActorNameParamName)
             {
                 if (!getActionParameterValue(storyAction, domainActionParameter, out actorName) ||
                     (implicitActorInstantiation && !actorWillBeInstantiated(actorName)))
                 {
                     break;
                 }
             }
             else if (domainActionParameter.Name == ra.DestinationParamName)
             {
                 IActionProperty targetOrientation;
                 if (storyAction.TryGetProperty(domainActionParameter.Name, out targetOrientation))
                 {
                     if (targetOrientation.Value.Value is float)
                     {
                         targetDegrees = (float)targetOrientation.Value.Value;
                         if (targetOrientation.Range.Name == "x+degrees")
                         {
                             targetDegrees = targetDegrees.Value.convertSourceEngineToUnityRotation();
                         }
                     }
                     else if (targetOrientation.Value.Value is Coordinate2D)
                     {
                         targetPoint = new Vector2((float)((Coordinate2D)targetOrientation.Value.Value).X,
                                                   (float)((Coordinate2D)targetOrientation.Value.Value).Y);
                     }
                 }
                 else
                 {
                     Debug.LogError("orientation not set for stepId[" + storyAction.Name + "]");
                 }
             }
         }
         startTick = getStartTick(storyAction, ra, effectingAnimation);
         endTick   = getEndTick(storyAction, ra, effectingAnimation, startTick);
         var targetRotation = new Vector3Nullable(null, targetDegrees, null);
         if (Rotate.ValidForConstruction(actorName, targetRotation, targetPoint))
         {
             aaq.Add(new Rotate(startTick, endTick, actorName, targetRotation, targetPoint)
             {
                 ParentActionId = parentActionId
             });
         }
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private static bool getActionParameterValue(IStoryAction <UintT> storyAction, CM.DomainActionParameter domainActionParameter, out string parameterValueName)
        {
            parameterValueName = null;
            IActionProperty ParamNameProperty;

            if (storyAction.TryGetProperty(domainActionParameter.Name, out ParamNameProperty))
            {
                parameterValueName = ParamNameProperty.Value.Name;
                return(true);
            }
            Extensions.Log(domainActionParameter.Name + " not set for stepId[" + storyAction.Name + "]");
            return(false);
        }
Exemplo n.º 4
0
        private static void enqueueCreateActions(IStoryAction <UintT> storyAction, CM.DomainAction domainAction,
                                                 CM.Animation effectingAnimation, FireBoltActionList aaq, string parentActionId)
        {
            foreach (CM.CreateAction ca in domainAction.CreateActions)
            {
                float   startTick   = 0;
                string  actorName   = null;
                Vector3 destination = new Vector3();
                Vector3?orientation = null;
                float   targetDegrees;
                CinematicModelMetaData metaData = new CinematicModelMetaData();

                foreach (CM.DomainActionParameter domainActionParameter in domainAction.Params)
                {
                    if (domainActionParameter.Name == ca.ActorNameParamName)
                    {
                        if (getActionParameterValue(storyAction, domainActionParameter, out actorName))//actorName is defined, we can look up a model
                        {
                            if (!getActorMetaData(actorName, out metaData))
                            {
                                break; //we failed to find the actor within the hierarchy
                            }
                        }
                    }
                    else if (domainActionParameter.Name == ca.OriginParamName)
                    {
                        IActionProperty coord;
                        if (storyAction.TryGetProperty(domainActionParameter.Name, out coord))
                        {
                            if (coord.Value.Value is Coordinate2D)
                            {
                                destination = ((Coordinate2D)coord.Value.Value).ToVector3(cm.DomainDistancePerEngineDistanceX,
                                                                                          cm.DomainDistancePerEngineDistanceY,
                                                                                          cm.DomainDistancePerEngineDistanceZ);
                            }
                            else if (coord.Value.Value is Coordinate3D)
                            {
                                destination = ((Coordinate3D)coord.Value.Value).ToVector3(cm.DomainDistancePerEngineDistanceX,
                                                                                          cm.DomainDistancePerEngineDistanceY,
                                                                                          cm.DomainDistancePerEngineDistanceZ);
                            }
                        }
                        else
                        {
                            Debug.LogError("origin not set for stepId[" + storyAction.Name + "]");
                        }
                    }
                    else if (domainActionParameter.Name == ca.OrientationParamName)
                    {
                        IActionProperty orientationProperty;
                        if (storyAction.TryGetProperty(domainActionParameter.Name, out orientationProperty) &&
                            tryConvertOrientation(orientationProperty, out targetDegrees))
                        {
                            orientation = new Vector3(0, targetDegrees, 0);
                        }
                        else
                        {
                            Debug.LogError("origin not set for stepId[" + storyAction.Name + "]");
                        }
                    }
                }
                startTick = getStartTick(storyAction, ca, effectingAnimation);
                if (Create.ValidForConstruction(actorName, metaData.ModelName))
                {
                    aaq.Add(new Create(startTick, actorName, metaData.ModelName, destination, metaData, orientation)
                    {
                        ParentActionId = parentActionId
                    });
                }
            }
        }
Exemplo n.º 5
0
 private static void enqueuetranslateActions(IStoryAction <UintT> storyAction, CM.DomainAction domainAction,
                                             CM.Animation effectingAnimation, FireBoltActionList aaq,
                                             string parentActionId, bool implicitActorInstantiation)
 {
     foreach (CM.TranslateAction ta in domainAction.TranslateActions)
     {
         float           startTick   = 0;
         float           endTick     = 0;
         string          actorName   = null;
         Vector3Nullable destination = new Vector3Nullable(null, null, null);
         Vector3         origin      = Vector3.zero;
         foreach (CM.DomainActionParameter domainActionParameter in domainAction.Params)
         {
             if (domainActionParameter.Name == ta.OriginParamName)
             {
                 IActionProperty coord;
                 if (storyAction.TryGetProperty(domainActionParameter.Name, out coord))
                 {
                     if (coord.Value.Value is Coordinate2D)
                     {
                         origin = ((Coordinate2D)coord.Value.Value).ToVector3(cm.DomainDistancePerEngineDistanceX, cm.DomainDistancePerEngineDistanceY, cm.DomainDistancePerEngineDistanceZ);
                     }
                     else if (coord.Value.Value is Coordinate3D)
                     {
                         origin = ((Coordinate3D)coord.Value.Value).ToVector3(cm.DomainDistancePerEngineDistanceX, cm.DomainDistancePerEngineDistanceY, cm.DomainDistancePerEngineDistanceZ);
                     }
                 }
                 else
                 {
                     Debug.LogError("origin not set for stepId[" + storyAction.Name + "]");
                 }
             }
             else if (domainActionParameter.Name == ta.DestinationParamName)
             {
                 IActionProperty coord;
                 if (storyAction.TryGetProperty(domainActionParameter.Name, out coord))
                 {
                     if (coord.Value.Value is Coordinate2D)
                     {
                         destination = ((Coordinate2D)coord.Value.Value).ToVector3Nullable(cm.DomainDistancePerEngineDistanceX, cm.DomainDistancePerEngineDistanceY, cm.DomainDistancePerEngineDistanceZ);
                     }
                     else if (coord.Value.Value is Coordinate3D)
                     {
                         destination = ((Coordinate3D)coord.Value.Value).ToVector3Nullable(cm.DomainDistancePerEngineDistanceX, cm.DomainDistancePerEngineDistanceY, cm.DomainDistancePerEngineDistanceZ);
                     }
                 }
                 else
                 {
                     Debug.LogError("destination not set for stepId[" + storyAction.Name + "]");
                 }
             }
             else if (domainActionParameter.Name == ta.ActorNameParamName)
             {
                 if (!getActionParameterValue(storyAction, domainActionParameter, out actorName) ||
                     (implicitActorInstantiation && !actorWillBeInstantiated(actorName)))
                 {
                     break;
                 }
             }
         }
         startTick = getStartTick(storyAction, ta, effectingAnimation);
         endTick   = getEndTick(storyAction, ta, effectingAnimation, startTick);
         if (Translate.ValidForConstruction(actorName))
         {
             aaq.Add(new Translate(startTick, endTick, actorName, origin, destination)
             {
                 ParentActionId = parentActionId
             });
         }
     }
 }