Example #1
0
        void LoadNext()
        {
            var pos   = this.ChunkQueue.Dequeue();
            var chunk = WorldManager.Active.CreateChunk(pos);

            var g = SimplePool.Spawn(this.ChunkPrefab, Vector3.zero, Quaternion.identity);

            g.transform.SetParent(this.WorldTransform);

            g.GetComponent <ChunkRenderer>().Chunk = chunk;

            chunk.Dirty = true;

            this.CurrActive--;
        }
Example #2
0
        void Start()
        {
            SimplePool.Preload(this.ChunkPrefab, this.LoadRadius ^ 3);

            for (int x = 0; x < this.LoadRadius; x++)
            {
                for (int y = -1; y < this.LoadRadius; y++)
                {
                    for (int z = 0; z < this.LoadRadius; z++)
                    {
                        var pos = new Vector3Int(x, y, z);

                        this.ChunkQueue.Enqueue(pos);
                    }
                }
            }
        }
Example #3
0
        void OnGUI()
        {
            if (GUI.Button(new Rect(10, 10, 100, 25), "Rebuild Chunks"))
            {
                var seed = Random.Range(1, 1000000);
                WorldManager.Active.SetSeed(seed);

                Debug.Log(seed);

                foreach (var chunk in WorldManager.Active._chunks)
                {
                    WorldManager.Active.TerrainGenerator.Generate(chunk.Value);
                    chunk.Value.Dirty = true;
                }
            }

            if (GUI.Button(new Rect(10, 40, 100, 25), "Add Chunk"))
            {
                var g = SimplePool.Spawn(this.ChunkGameObject, Vector3.zero, Quaternion.identity);
                //g.GetComponent<ChunkRenderer>().chunkPosition = new Vector3Int(0, -testY++, 0);

                //ChunkPool.Create(new Vector3Int(0, -testY++, 0));
            }
        }