コード例 #1
0
 private void ActiveManager_OnCycle(object sender, System.EventArgs e)
 {
     if (activeGenerator == null)
     {
         throw new Exception("Tried to poll null terrain generator!");
     }
     activeGenerator.Update();
     if (activeGenerator.IsDone)
     {
         InfiniManager.activeManager.OnCycle -= ActiveManager_OnCycle;
         activeGenerator = null;
     }
 }
コード例 #2
0
        public bool GenerateTerrain(float scale, float height, float xOffset, float yOffset)
        {
            if (activeGenerator != null)
            {
                return(false);
            }
            ChunkTerrainGenerator ctg = new ChunkTerrainGenerator(terrainObject, scale, height, xOffset, yOffset);

            ctg.Start();
            activeGenerator = ctg;
            InfiniManager.activeManager.OnCycle += ActiveManager_OnCycle;
            return(true);
        }
コード例 #3
0
    public ChunkOperator(ChunkManager chunks, string saveName, string worldName, int seed)
    {
        _terrainGenerator = new ChunkTerrainGenerator();
        _terrainGenerator.Init();

        _chunks = chunks;

        _seed = seed;

        Air = BlockManager.Inst.GetBlockOrDefault("Base/Block/Air");

        int threadCount = 4;//Mathf.Max(Environment.ProcessorCount / 2 - 1, 2);

        Console.WriteLine($"Worker thread count: {threadCount}");
        _threadHolder.Release(threadCount);
    }
コード例 #4
0
    public ChunkOperator(ChunkManager chunks, string saveName, string worldName, int seed)
    {
        _terrainGenerator = new ChunkTerrainGenerator();
        _terrainGenerator.Init();

        _chunks      = chunks;
        _toWorldSave = Path.Combine(_toSaveFolder, saveName, worldName);

        _seed = seed;

        Air = BlockManager.Inst.GetBlockOrDefault("Base/Block/Air");

        int threadCount = 6;//Mathf.Max(Environment.ProcessorCount / 2 - 1, 2);

        Debug.Log($"Worker thread count: {threadCount}");
        _threadHolder.Release(threadCount);
    }
コード例 #5
0
 public void StartGenerator()
 {
     chunkGen = new ChunkTerrainGenerator(this.gameObject, EngineComponent.instance.terrainDetailScale, EngineComponent.instance.terrainDetailHeight, 0.0f, 0.0f);
     chunkGen.Start();
 }