Ejemplo n.º 1
0
        public static async Task Run(EngineContext engineContext)
        {
            var config = AppConfig.GetConfiguration <Config>("Script1");

            CommonSetup(engineContext);

            if (config.Synthetic)
            {
                await ScriptCube.Run(engineContext);
            }
            else
            {
                PipelineSetup(engineContext);

                // Check config file
                var configDebug = AppConfig.GetConfiguration <ScriptDebug.Config>("ScriptDebug");
                if (configDebug.DebugManager)
                {
                    engineContext.Scheduler.Add(() => ScriptDebug.RunDebug(engineContext));
                }

                engineContext.Scheduler.Add(async() =>
                {
                    if (config.Scene == "cave")
                    {
                        VirtualFileSystem.MountFileSystem("/sync", ".");
                        await ScriptCave.Run(engineContext);
                    }
                    else if (config.Scene == "sync")
                    {
                        ScriptSceneSerialization.gitFolder = "..\\..\\gittest\\" + config.SyncFolder + "\\";
                        VirtualFileSystem.MountFileSystem("/sync", ScriptSceneSerialization.gitFolder);
                        await ScriptCube.GenerateSimpleCubeEffect(engineContext);
                    }
                    else if (config.Scene == "factory")
                    {
                        await SetupFactory(engineContext);
                        await LightScript.MoveLights(engineContext);
                    }
                    else if (config.Scene == "particles")
                    {
                        //ScriptParticleSmoke.Run(engineContext);
                    }
                    else if (config.Scene == "cputest")
                    {
                        await ScriptMulticore.Run(engineContext);
                    }
                    else if (config.Scene == "permutation")
                    {
                        await ScriptPermutation.Run(engineContext);
                    }
                });
            }
        }
Ejemplo n.º 2
0
        public void GenerateChildren(ViewModelContext context, IViewModelNode viewModelNode, ref bool handled)
        {
            if (viewModelNode.NodeValue is Entity)
            {
                viewModelNode.Children.Add(new ViewModelNode("Name", new PropertyInfoViewModelContent(new ParentNodeValueViewModelContent(), typeof(Entity).GetProperty("Name"))));
                viewModelNode.Children.Add(new ViewModelNode("Guid", new PropertyInfoViewModelContent(new ParentNodeValueViewModelContent(), typeof(Entity).GetProperty("Guid"))));
                viewModelNode.Children.Add(new ViewModelNode("IsSelected", new PropertyKeyViewModelContent(new ParentNodeValueViewModelContent(), isSelectedProperty)));
                viewModelNode.Children.Add(new ViewModelNode("ParentReference", LambdaViewModelContent <ViewModelReference> .FromParent <Entity>(x =>
                {
                    var transformationComponent = x.Transformation;
                    var parent = transformationComponent != null ? transformationComponent.Parent : null;
                    return(new ViewModelReference(parent != null ? parent.Entity : null));
                })));
                viewModelNode.Children.Add(new ViewModelNode("HierarchicalEntities", EnumerableViewModelContent.FromUnaryLambda <ViewModelReference, Entity>(new ParentNodeValueViewModelContent(),
                                                                                                                                                             (entity) =>
                {
                    var result = Enumerable.Empty <ViewModelReference>();

                    // Enumerates children nodes
                    var transformationComponent = entity.Transformation;
                    if (transformationComponent != null)
                    {
                        result = result.Concat(transformationComponent.Children
                                               .Select(x => new ViewModelReference(x.Entity, true)));
                    }

                    // Enumerates EffectMesh
                    var meshComponent = entity.Get(ModelComponent.Key);
                    if (meshComponent != null && meshComponent.InstantiatedSubMeshes != null)
                    {
                        result = result.Concat(meshComponent.InstantiatedSubMeshes.Select((x, i) =>
                        {
                            effectMeshIndices.GetOrCreateValue(x.Value).Index = i;
                            return(new ViewModelReference(x.Value, true));
                        }));
                    }

                    return(result);
                })));

                viewModelNode.Children.Add(new ViewModelNode("EventOpen", new RootViewModelContent((ExecuteCommand)((viewModel2, parameter) =>
                {
                    ScriptDebug.SelectEntity((Entity)viewModel2.Parent.NodeValue);
                }))));

                viewModelNode.Children.Add(new ViewModelNode("CreateNewEntity", new RootViewModelContent((ExecuteCommand)((viewModel2, parameter) =>
                {
                    var entity = (Entity)viewModel2.Parent.NodeValue;
                    var newEntity = new Entity("New Entity");
                    entity.Transformation.Children.Add(newEntity.Transformation);
                }))));

                viewModelNode.Children.Add(new ViewModelNode("Remove", new RootViewModelContent((ExecuteCommand)((viewModel2, parameter) =>
                {
                    var entity = (Entity)viewModel2.Parent.NodeValue;
                    EntitySystem.Remove(entity);
                }))));

                handled = true;
            }
            else if (viewModelNode.NodeValue is EffectMesh)
            {
                viewModelNode.Children.Add(new ViewModelNode("Name", new LambdaViewModelContent <string>(new NullViewModelContent(), (content) =>
                {
                    var effectMesh = (EffectMesh)content.OwnerNode.Parent.NodeValue;
                    var result     = effectMeshIndices.GetOrCreateValue(effectMesh).Index.ToString();
                    if (effectMesh.Name != null)
                    {
                        result += " - " + effectMesh.Name;
                    }

                    return(result);
                })));

                viewModelNode.Children.Add(new ViewModelNode("EventOpen", new RootViewModelContent((ExecuteCommand)((viewModel2, parameter) =>
                {
                    selectedEntitiesContext.ViewModelByGuid.Clear();
                    selectedEntitiesContext.Root = new ViewModelNode("Root", new RootViewModelContent(new[] { new ViewModelReference(viewModel2.Parent.NodeValue, true) }, typeof(IList <ViewModelReference>)));
                }))));

                handled = true;
            }
        }