Exemple #1
0
        public RasterizeWorker(Chunk chunk)
        {
            this.chunk         = chunk;
            this.chunk.Working = true;

            mesh      = new ChunkMesh();
            renderer  = new ChunkRenderer();
            chunkView = new ChunkView(chunk);
        }
Exemple #2
0
        public IRenderResult RenderBiomesTile(ChunkView view)
        {
            if (!view.HasBiomeData)
            {
                throw new ArgumentException("Chunk view must be loaded with biomes data.", nameof(view));
            }

            var pixels = view.GetBiomesArea().Select(biome => biomeConfig_[biome].Rgba32Color).ToArray();
            var image  = Image.LoadPixelData(pixels, 16, 16);

            return(new ImageSharpResult(image));
        }
Exemple #3
0
    public Chunk LoadChunk(Vector2DInt inPosition)
    {
        // Create chunkdata and begin load from disk on a separate thread
        ChunkData chunkData = new ChunkData(inPosition);

        new System.Threading.Thread(() => chunkData.LoadFromDisk(inPosition)).Start();

        // Create blank chunk view
        GameObject chunkTerrainView   = _viewGenerator.GenerateBlankTerrainView(inPosition);
        GameObject chunkFurnitureView = _viewGenerator.GenerateBlankFurnitureView(inPosition);

        // Make the viewGenerator update the UV2 of the view every time the chunk's data changes
        chunkData.OnTerrainDataDirtied += (ChunkData dirtiedData) =>
                                          chunkTerrainView.GetComponent <MeshFilter>().mesh.uv2 = _viewGenerator.GenerateTerrainUV2(dirtiedData); // TODO: Getting these meshfilters before the event saves having to do it every time it's called

        chunkData.OnFurnitureDataDirtied += (ChunkData dirtiedData) =>
                                            chunkFurnitureView.GetComponent <MeshFilter>().mesh.uv2 = _viewGenerator.GenerateFurnitureUV2(dirtiedData); // TODO: Getting these meshfilters before the event saves having to do it every time it's called

        ChunkView chunkView = new ChunkView(chunkTerrainView, chunkFurnitureView);

        return(new Chunk(chunkData, chunkView));
    }
Exemple #4
0
 public Chunk(ChunkData inData, ChunkView inView)
 {
     data = inData;
     view = inView;
 }