コード例 #1
0
        public static void GenerateChunk(Vector3 chunkPos)
        {
            Chunk c;

            if (!ChunkCollection.TryGetValue(chunkPos, out c))
            {
                AssignedWorkContainer awc = GetWorkContainer(chunkPos);

                if (!awc.ContainsWork(JobType.Generate))
                {
                    ThreadedChunkGeneration tcg = new ThreadedChunkGeneration(chunkPos);
                    awc.AddAssignedJob(JobType.Generate, new AssignedJob(chunkPos, JobType.Generate, tcg));
                    ThreadHandler.EnqueuWork(tcg);
                }
            }
        }
コード例 #2
0
    public void TestChunkGeneration(Vector3 cPos)
    {
        ThreadedChunkGeneration tcg = new ThreadedChunkGeneration(cPos);

        System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();

        watch.Start();
        CompletedChunkGenerationWork ccgw = tcg.Work() as CompletedChunkGenerationWork;

        watch.Stop();

        Debug.Log("Completed generation of chunk " + cPos.ToString() + " in " + ((double)watch.Elapsed.Ticks / (double)System.TimeSpan.TicksPerMillisecond).ToString() + "ms");


        ChunkHandler.TryAddChunk(ccgw.Chunk);
    }