Пример #1
0
    public override void _Process(float delta)
    {
        int camX = int.Parse(Mathf.Stepify(Camera.Transform.origin.x / ChunkSize.x, 1).ToString());
        int camZ = int.Parse(Mathf.Stepify(Camera.Transform.origin.z / ChunkSize.z, 1).ToString());

        for (int x = -RenderDistance; x <= RenderDistance; x++)
        {
            for (int y = -RenderDistance; y <= RenderDistance; y++)
            {
                var pos = new Vector2(x + camX, y + camZ);
                if (!PreloadedChunks.ContainsKey(pos) && !LoadedChunks.ContainsKey(pos) && !toRenderPos.Contains(pos))
                {
                    toRenderPos.Enqueue(pos);
                }
            }
        }

        var temp = TemperatureManager.GetTemperature((int)(Camera.Transform.origin.x), (int)(Camera.Transform.origin.z));
        var hum  = TemperatureManager.GetHumidity((int)(Camera.Transform.origin.x), (int)(Camera.Transform.origin.z));

        InfoLabel.Clear();
        //InfoLabel.Text += "FPS: " + Engine.GetFramesPerSecond() + "\n";
        InfoLabel.Text += "PreloadedCount: " + PreloadedChunks.Count.ToString() + "\n";
        InfoLabel.Text += "LoadedChunksCount: " + LoadedChunks.Count.ToString() + "\n";
        InfoLabel.Text += "ToRenderCount: " + toRenderPos.Count.ToString() + "\n";
        InfoLabel.Text += "CamPosition: " + "X: " + camX + " Z: " + camZ + "\n";
        InfoLabel.Text += "Current Temperature: " + temp + "\n";
        InfoLabel.Text += "Current Humidity: " + hum + "% \n";
        InfoLabel.Text += "Current biome: " + BiomeManager.FindMatchingBiome(temp, hum).ToString();

        foreach (var item in LoadedChunks.Keys)
        {
            if (DistanceToChunk(item) >= RenderDistance * 2)
            {
                Chunk chunk = LoadedChunks[item];
                if (!HasNode("item.ToString()"))
                {
                    continue;
                }
                var node = GetNode(item.ToString());
                node.CallDeferred("free");
                LoadedChunks.TryRemove(item, out chunk);
            }
        }
    }