Example #1
0
        public void AddToUnload(Chunk chunk)
        {
            if (!LoadQueue.Contains(chunk))
            {
                UnloadQueue.Enqueue(chunk);
            }

            LoadQueue.Remove(chunk);
            GenerationQueue.Remove(chunk);
            VegetationQueue.Remove(chunk);
        }
Example #2
0
        public void AddToUnload(Chunk chunk)
        {
            if (!LoadQueue.Contains(chunk))
            {
                UnloadQueue.Enqueue(chunk);
            }

            LoadQueue.Remove(chunk);
            GenerationQueue.Remove(chunk);
            VegetationQueue.Remove(chunk);
            BuildQueue.Remove(chunk);
            SetupQueue.Remove(chunk);

            chunk.WillBeUnloaded = true;
        }
Example #3
0
        public void Run()
        {
            Chunk currentChunk;

            while (true)
            {
                if (!Variables.Game.IsInitialized)
                {
                    continue;
                }

                if (UnloadQueue.Count > 0)
                {
                    currentChunk = UnloadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Unload Chunk
                    if (Constants.World.SaveDynamicWorld)
                    {
                        ChunkManager.StoreChunkImmediate(currentChunk);
                    }
                    else
                    {
                        currentChunk = null;
                    }
                    Console.Write("UnloadQueue: " + UnloadQueue.Count);

                    // End Unload Chunk

                    LoadQueue.Remove(currentChunk);
                    GenerationQueue.Remove(currentChunk);
                    SetupQueue.Remove(currentChunk);
                }
                else if (LoadQueue.Count > 0)
                {
                    currentChunk = LoadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Load Chunk

                    ChunkManager.LoadChunkImmediate(currentChunk);
                    currentChunk.BuildOctree();
                    currentChunk.HasData = true;

                    Console.Write("LoadQueue: " + LoadQueue.Count);

                    // End Load Chunk

                    if (SetupQueue.Contains(currentChunk))
                    {
                        SetupQueue.Remove(currentChunk);
                        SetupQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        SetupQueue.Enqueue(currentChunk);
                    }
                }
                else if (GenerationQueue.Count > 0)
                {
                    currentChunk = GenerationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Generate Chunk

                    TerrainGenerator.SetChunkTerrain(currentChunk);

                    Console.Write("GenerationQueue: " + GenerationQueue.Count);

                    // End Generate Chunk

                    if (VegetationQueue.Contains(currentChunk))
                    {
                        VegetationQueue.Remove(currentChunk);
                        VegetationQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToVegetation(currentChunk);
                    }
                }
                else if (VegetationQueue.Count > 0)
                {
                    currentChunk = VegetationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Vegetate Chunk

                    Vegetation.Vegetate(currentChunk);

                    Console.Write("VegetationQueue: " + VegetationQueue.Count);

                    // End Vegetate Chunk

                    if (BuildQueue.Contains(currentChunk))
                    {
                        BuildQueue.Remove(currentChunk);
                        BuildQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToBuild(currentChunk);
                    }

                    if (VegetationQueue.Count == 0 && !Constants.Engines.Physics.Player.IsReleased)
                    {
                        Constants.Engines.Physics.Player.Release();
                    }
                }
                else if (BuildQueue.Count > 0)
                {
                    currentChunk = BuildQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Build Chunk

                    currentChunk.BuildOctree();
                    currentChunk.HasData = true;

                    Console.Write("BuildQueue: " + BuildQueue.Count);

                    // End Build Chunk

                    if (SetupQueue.Contains(currentChunk))
                    {
                        SetupQueue.Remove(currentChunk);
                        SetupQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToSetup(currentChunk);
                    }
                }
                else if (SetupQueue.Count > 0)
                {
                    currentChunk = SetupQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }
                    currentChunk.SetupState = 4;

                    // Setup Chunk

                    currentChunk.BuildGeometry(false);
                    currentChunk.SetupState = 1;

                    Console.Write("SetupQueue: " + SetupQueue.Count);
                    // End Setup Chunk
                }
            }
        }
Example #4
0
        public void Run()
        {
            Chunk currentChunk;

            while (true)
            {
                if (!Variables.Game.IsInitialized)
                {
                    continue;
                }

                if (UnloadQueue.Count > 0)
                {
                    currentChunk = UnloadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Unload Chunk
                    if (Constants.World.SaveDynamicWorld)
                    {
                        ChunkManager.SaveChunk(currentChunk);
                    }
                    else
                    {
                        currentChunk = null;
                    }
                    Console.Write("UnloadQueue: " + UnloadQueue.Count);

                    // End Unload Chunk

                    LoadQueue.Remove(currentChunk);
                    GenerationQueue.Remove(currentChunk);
                }
                else if (LoadQueue.Count > 0)
                {
                    currentChunk = LoadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Load Chunk

                    ChunkManager.LoadChunkImmediate(currentChunk);

                    Console.Write("LoadQueue: " + LoadQueue.Count);

                    // End Load Chunk
                }
                else if (GenerationQueue.Count > 0)
                {
                    currentChunk = GenerationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Generate Chunk

                    TerrainGenerator.SetChunkTerrain(currentChunk);

                    Console.Write("GenerationQueue: " + GenerationQueue.Count);

                    // End Generate Chunk

                    if (VegetationQueue.Contains(currentChunk))
                    {
                        VegetationQueue.Remove(currentChunk);
                        VegetationQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToVegetation(currentChunk);
                    }
                }
                else if (VegetationQueue.Count > 0)
                {
                    currentChunk = VegetationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Vegetate Chunk

                    Vegetation.Vegetate(currentChunk);


                    Console.Write("VegetationQueue: " + VegetationQueue.Count);

                    // End Vegetate Chunk
                }
            }
        }