Example #1
0
 internal BatchIndex2R(BPlusTree <C, B> di41R, BPlusTree <BlockKey <C>, BlockValue> di42R, C left, C right, ConcurrentDictionary <C, int> addedBlocks)
 {
     _di41R       = di41R;
     _di42R       = di42R;
     _left        = left;
     _right       = right;
     _addedBlocks = addedBlocks;
     _bCounter    = new BlockCounter();
 }
Example #2
0
 public void AddCounter(string key, BlockCounter counter)
 {
     foreach (MyCubeGrid grid in grids)
     {
         foreach (MyCubeBlock block in grid.GetFatBlocks())
         {
             counter.TryAddCount(block);
         }
     }
     BlockCounters [key] = counter;
 }
    // Start is called before the first frame update
    void Start()
    {
        // Debug.Log($"Start {nameof(BuildGridState)}");

        grid.Fill(new Vector2(gridWidth, gridHeight));
        // blockCounter = blockCounterObject.GetComponent<BlockCounter>();
        blockCounter = FindObjectOfType <BlockCounter>();

        // grid.Set(new Vector2(0,0), true);
        // grid.Set(new Vector2(0,1), true);
    }
    private void createPlains(Region region)
    {
        BlockCounter counter  = new BlockCounter(Region.regionXZ * Region.regionXZ * Region.regionY);
        int          x_offset = region.getBlockOffsetX();
        int          y_offset = region.getBlockOffsetY();
        int          z_offset = region.getBlockOffsetZ();

        for (int x = 0; x < region.data.GetLength(0); x++)
        {
            for (int z = 0; z < region.data.GetLength(2); z++)
            {
                int xi = x_offset + x;
                int zi = z_offset + z;


                int highHills = PerlinNoise(xi, 751, zi, 50, 10f, 1.0f) + 128;
                int lowHills  = PerlinNoise(xi, 407, zi, 50, 10f, 1.0f) + 128;
                //int val = (int)Math.Max (highHills, lowHills);
                for (int y = 0; y < region.data.GetLength(1); y++)
                {
                    int yi = y_offset + y;
                    if (yi <= highHills)
                    {
                        counter.add(DirtBlock.blockId);
                        region.data [x, y, z] = DirtBlock.blockId;
                    }
                    else if (yi <= lowHills)
                    {
                        counter.add(GrassBlock.blockId);
                        region.data [x, y, z] = GrassBlock.blockId;
                    }
                    else
                    {
                        counter.add(0);
                    }
                }
            }
        }

        //process flags
        if (counter.isAirOnly())
        {
            region.flags.isEmptyAir = true;
        }
        else if (counter.isSingleSolidOnly())
        {
            region.flags.isSingleSolid = true;
        }
    }
    private void createMountains(Region region)
    {
        BlockCounter counter  = new BlockCounter(Region.regionXZ * Region.regionXZ * Region.regionY);
        int          x_offset = region.getBlockOffsetX();
        int          y_offset = region.getBlockOffsetY();
        int          z_offset = region.getBlockOffsetZ();

        for (int x = 0; x < Region.regionXZ; x++)
        {
            for (int z = 0; z < Region.regionXZ; z++)
            {
                int xi = x_offset + x;
                int zi = z_offset + z;


                int stone      = PerlinNoise(xi, 751, zi, 550, 15f, 2.2f) + 200;
                int lowHills   = PerlinNoise(xi, 400, zi, 200, 10f, 2.2f);
                int roughness1 = PerlinNoise(xi, 231, zi, 20, 2f, 1.5f);
                int roughness2 = PerlinNoise(xi, 845, zi, 50, 2f, 2.5f);
                int roughness3 = PerlinNoise(xi, 19, zi, 100, 3f, 3.5f);
                int val        = stone + lowHills + roughness1 + roughness2 + roughness3;
                for (int y = 0; y < Region.regionY; y++)
                {
                    int yi = y_offset + y;
                    if (yi <= val)
                    {
                        region.data [x, y, z] = 1;
                        counter.add(1);
                    }
                    else
                    {
                        counter.add(0);
                    }
                }
            }
        }

        //process flags
        if (counter.isAirOnly())
        {
            region.flags.isEmptyAir = true;
        }
        else if (counter.isSingleSolidOnly())
        {
            region.flags.isSingleSolid = true;
        }
    }
    public void genRegionv2(Region region)
    {
        BlockCounter counter  = new BlockCounter(Region.regionXZ * Region.regionXZ * Region.regionY);
        int          x_offset = region.getBlockOffsetX();
        int          y_offset = region.getBlockOffsetY();
        int          z_offset = region.getBlockOffsetZ();

        for (int x = 0; x < Region.regionXZ; x++)
        {
            for (int z = 0; z < Region.regionXZ; z++)
            {
                int xi = x_offset + x;
                int zi = z_offset + z;

                //Read a tile from the overland map.
            }
        }
    }
Example #7
0
 // Start is called before the first frame update
 void Start()
 {
     buildGridState = state.GetComponent <BuildGridState>();
     blockCounter   = FindObjectOfType <BlockCounter>();
 }