コード例 #1
0
ファイル: ExecutionBuilder.cs プロジェクト: zhangbo27/fireasy
        protected override Expression VisitNew(NewExpression node)
        {
            var elementType = node.Type;

            if (typeof(IEntity).IsAssignableFrom(elementType))
            {
                if (elementType.IsNotImplAOPType())
                {
                    elementType = EntityCompiler.GetProxyType(elementType);
                    return(Expression.New(elementType));
                }
            }

            return(base.VisitNew(node));
        }
コード例 #2
0
        private void Compile()
        {
            Console.WriteLine("Compiling resources...");
            using (var sprites_texture = new TextureCompiler(Path.Combine(OutputDirectory, "SpritesTexture")))
                using (var tiles_texture = new TextureCompiler(Path.Combine(OutputDirectory, "TilesTexture")))
                    using (var interfaces_texture = new TextureCompiler(Path.Combine(OutputDirectory, "InterfacesTexture")))
                    {
                        foreach (var cat in Table.Categories)
                        {
                            var      type     = Enum.Parse <ResourceType>(cat.Key);
                            string   output   = "";
                            Compiler compiler = null;
                            switch (type)
                            {
                            case ResourceType.Entity:
                                compiler         = new EntityCompiler();
                                compiler.Texture = sprites_texture;
                                output           = Path.Combine(OutputDirectory, "Entities");
                                break;

                            case ResourceType.Event:
                                compiler         = new EventCompiler();
                                compiler.Texture = sprites_texture;
                                output           = Path.Combine(OutputDirectory, "Events");
                                break;

                            case ResourceType.Interface:
                                compiler         = new InterfaceCompiler();
                                compiler.Texture = interfaces_texture;
                                output           = Path.Combine(OutputDirectory, "Interfaces");
                                break;

                            //case ResourceType.Item:
                            //    compiler = new ItemCompiler();
                            //    break;
                            case ResourceType.Tile:
                                compiler         = new TileCompiler();
                                compiler.Texture = tiles_texture;
                                output           = Path.Combine(OutputDirectory, "Tiles");
                                break;
                            }

                            if (compiler != null)
                            {
                                using (compiler.Writer = new BinaryWriter(File.OpenWrite(output)))
                                {
                                    compiler.RootDirectory = InputDirectory;
                                    compiler.Table         = Table;

                                    compiler.Writer.Write(Table.GetLastID(cat.Key) + 1);

                                    int id = 0;
                                    foreach (var item in cat.Value)
                                    {
                                        while (id < item.ID)
                                        {
                                            compiler.Placeholder();
                                            id++;
                                        }
                                        compiler.Compile(item.Path);
                                        id++;
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine($"Warning: Unsupported resource type [{type}].");
                            }
                            //foreach (var v in cat.Value)
                            //    Console.WriteLine(v.Path);
                        }
                    }
            Console.WriteLine("Compilation done.");
            Console.WriteLine();
        }