Esempio n. 1
0
        //private static void buildInitialState(FireBoltActionList aaq) //TODO actor model defaulting a la create actions
        //{
        //    var interval = new UintT(new UintV(0), new UintV(1));
        //    var initialPositions = from sentence in story.Sentences
        //                           where sentence is Predicate
        //                           let p = (Predicate)sentence
        //                           where p.Temporal &&
        //                                 p.Name == "at" &&
        //                                 p.Time is UintT &&
        //                                 p.Terms[0] is IConstant &&
        //                                 p.Terms[1] is IConstant<Coordinate2D> &&
        //                                 story.IntervalSet.IncludesOrMeetsStartOf<UintV, UintT>((UintT)p.Time, interval)
        //                           select new { Actor = p.Terms[0].Name, Location = (p.Terms[1] as IConstant<Coordinate2D>).Value };

        //    Extensions.Log("building init state creation actions");
        //    foreach (var initPos in initialPositions)
        //    {
        //        Extensions.Log(initPos.Actor + ", " + initPos.Location.ToString());
        //        CM.Actor actor;
        //        if (!cm.TryGetActor(initPos.Actor,out actor))
        //        {
        //            Extensions.Log("actor [" + initPos.Actor + "] not found in cinematic model.");
        //            continue;
        //        }

        //        string modelFileName = actor.Model;
        //        if (string.IsNullOrEmpty(modelFileName))
        //        {
        //            Extensions.Log("model name for actor[" + initPos.Actor + "] not found in cinematic model.");
        //            continue;
        //        }
        //        aaq.Add(new Create(0, initPos.Actor, modelFileName, initPos.Location.ToVector3()));
        //    }
        //}

        private static void createActors(FireBoltActionList aaq)
        {
            var actorNames = (story.ObjectSets[Impulse.v_1_336.Xml.Story.ObjectsSetName] as IFiniteObjectSet).Items.Select(c => c.Name).ToList();

            Extensions.Log("building object set based creation actions");
            foreach (var actorName in actorNames)
            {
                if (!actorActuallyDoesStuff(actorName))
                {
                    //Extensions.Log("not instantiating actor[{0}] as he does nothing in this impulse", actorName);
                    continue;
                }
                CinematicModelMetaData metaData = new CinematicModelMetaData();

                if (!getActorMetaData(actorName, out metaData))
                {
                    Extensions.Log("cannot auto-create actor[{0}]", actorName);
                    continue;
                }
                Extensions.Log("building object set based create for actor[{0}]", actorName);
                Create create = new Create(0, actorName, metaData.ModelName, new Vector3(-10000, 0, -10000), metaData, null, true);
                aaq.Add(create);
                implicitActorInstantiations.Add(actorName, true);
            }
        }
 public void LoadFromStruct(CinematicModelMetaData existingData)
 {
     this.ModelName             = existingData.ModelName;
     this.ActorName             = existingData.ActorName;
     this.AbstractActorName     = existingData.AbstractActorName;
     this.PointOfInterestScalar = existingData.PointOfInterestScalar;
 }
Esempio n. 3
0
 public Create(float startTick, string actorName, string modelName, Vector3 position,
               CinematicModelMetaData metaData, Vector3?orientation = null, bool defaultedCreate = false) :
     base(startTick, startTick)
 {
     this.startTick       = startTick;
     this.actorName       = actorName;
     this.modelName       = modelName;
     this.position        = position;
     this.metaData        = metaData;
     this.orientation     = orientation;
     this.defaultedCreate = defaultedCreate;
     this.actor           = null;
 }
Esempio n. 4
0
        private static bool getActorMetaData(string actorName, out CinematicModelMetaData metaData)
        {
            metaData                   = new CinematicModelMetaData();
            metaData.ActorName         = actorName;
            metaData.AbstractActorName = actorName;

            if (getActorModel(actorName, out metaData.ModelName))
            {
                metaData.PointOfInterestScalar = getActorPointOfInterestScalar(actorName);
                return(true);
            }

            int objectSetIndex          = 0;
            int actorHierarchyStepLevel = 1;

            while (string.IsNullOrEmpty(metaData.ModelName) &&
                   objectSetIndex < orderedObjectSets.Length &&
                   actorHierarchyStepLevel <= cm.SmartModelSettings.ActorMaxSearchDepth)
            {
                if (story.ObjectSets[orderedObjectSets[objectSetIndex]].
                    Contains(new ClassConstant <string>(actorName)))
                {
                    if (getActorModel(orderedObjectSets[objectSetIndex], out metaData.ModelName))
                    {
                        Extensions.Log("using abstract actor[{0}] for actor[{1}] level[{2}] above exact actor", orderedObjectSets[objectSetIndex], actorName, actorHierarchyStepLevel);
                        metaData.AbstractActorName     = story.ObjectSets[orderedObjectSets[objectSetIndex]].Name;
                        metaData.PointOfInterestScalar = getActorPointOfInterestScalar(metaData.AbstractActorName);
                        return(true);//quit looking up the hierarchy.  we found a more generic actor
                    }
                    actorHierarchyStepLevel++;
                }
                objectSetIndex++;
            }
            Extensions.Log("could not find actor def in hierarchy for [{0}]", actorName);
            return(false);//didn't find actor definition.  give up on this create action and move to the next one
        }
Esempio n. 5
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
                    });
                }
            }
        }