Пример #1
0
        /// <summary>
        /// Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length.
        /// </summary>
        public virtual float[] GetRainfall(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5)
        {
            IntCache.ResetIntCache();

            if (par1ArrayOfFloat == null || par1ArrayOfFloat.Length < par4 * par5)
            {
                par1ArrayOfFloat = new float[par4 * par5];
            }

            int[] ai = BiomeIndexLayer.GetInts(par2, par3, par4, par5);

            for (int i = 0; i < par4 * par5; i++)
            {
                float f = (float)BiomeGenBase.BiomeList[ai[i]].GetIntRainfall() / 65536F;

                if (f > 1.0F)
                {
                    f = 1.0F;
                }

                par1ArrayOfFloat[i] = f;
            }

            return(par1ArrayOfFloat);
        }
Пример #2
0
        /// <summary>
        /// Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false,
        /// don't check biomeCache to avoid infinite loop in BiomeCacheBlock)
        /// </summary>
        public virtual BiomeGenBase[] GetBiomeGenAt(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5, bool par6)
        {
            IntCache.ResetIntCache();

            if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.Length < par4 * par5)
            {
                par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];
            }

            if (par6 && par4 == 16 && par5 == 16 && (par2 & 0xf) == 0 && (par3 & 0xf) == 0)
            {
                BiomeGenBase[] abiomegenbase = BiomeCache.GetCachedBiomes(par2, par3);
                Array.Copy(abiomegenbase, 0, par1ArrayOfBiomeGenBase, 0, par4 * par5);
                return(par1ArrayOfBiomeGenBase);
            }

            int[] ai = BiomeIndexLayer.GetInts(par2, par3, par4, par5);

            for (int i = 0; i < par4 * par5; i++)
            {
                par1ArrayOfBiomeGenBase[i] = BiomeGenBase.BiomeList[ai[i]];
            }

            return(par1ArrayOfBiomeGenBase);
        }
Пример #3
0
        /// <summary>
        /// Returns an array of biomes for the location input.
        /// </summary>
        public virtual BiomeGenBase[] GetBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5)
        {
            IntCache.ResetIntCache();

            if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.Length < par4 * par5)
            {
                par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];
            }

            int[] ai = GenBiomes.GetInts(par2, par3, par4, par5);

            for (int i = 0; i < par4 * par5; i++)
            {
                par1ArrayOfBiomeGenBase[i] = BiomeGenBase.BiomeList[ai[i]];
            }

            return(par1ArrayOfBiomeGenBase);
        }
        /// <summary>
        /// Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
        /// amounts, or biomeList[] indices based on the particular GenLayer subclass.
        /// </summary>
        public override int[] GetInts(int par1, int par2, int par3, int par4)
        {
            int i = par1 >> 1;
            int j = par2 >> 1;
            int k = (par3 >> 1) + 3;
            int l = (par4 >> 1) + 3;

            int[] ai  = Parent.GetInts(i, j, k, l);
            int[] ai1 = IntCache.GetIntCache(k * 2 * (l * 2));
            int   i1  = k << 1;

            for (int j1 = 0; j1 < l - 1; j1++)
            {
                int k1 = j1 << 1;
                int i2 = k1 * i1;
                int j2 = ai[0 + (j1 + 0) * k];
                int k2 = ai[0 + (j1 + 1) * k];

                for (int l2 = 0; l2 < k - 1; l2++)
                {
                    InitChunkSeed(l2 + i << 1, j1 + j << 1);
                    int i3 = ai[l2 + 1 + (j1 + 0) * k];
                    int j3 = ai[l2 + 1 + (j1 + 1) * k];
                    ai1[i2]        = j2;
                    ai1[i2++ + i1] = Choose(j2, k2);
                    ai1[i2]        = Choose(j2, i3);
                    ai1[i2++ + i1] = Choose(j2, i3, k2, j3);
                    j2             = i3;
                    k2             = j3;
                }
            }

            int[] ai2 = IntCache.GetIntCache(par3 * par4);

            for (int l1 = 0; l1 < par4; l1++)
            {
                Array.Copy(ai1, (l1 + (par2 & 1)) * (k << 1) + (par1 & 1), ai2, l1 * par3, par3);
            }

            return(ai2);
        }
Пример #5
0
        /// <summary>
        /// Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
        /// amounts, or biomeList[] indices based on the particular GenLayer subclass.
        /// </summary>
        public override int[] GetInts(int par1, int par2, int par3, int par4)
        {
            par1 -= 2;
            par2 -= 2;
            sbyte byte0 = 2;
            int   i     = 1 << byte0;
            int   j     = par1 >> byte0;
            int   k     = par2 >> byte0;
            int   l     = (par3 >> byte0) + 3;
            int   i1    = (par4 >> byte0) + 3;

            int[] ai = Parent.GetInts(j, k, l, i1);
            int   j1 = l << byte0;
            int   k1 = i1 << byte0;

            int[] ai1 = IntCache.GetIntCache(j1 * k1);

            for (int l1 = 0; l1 < i1 - 1; l1++)
            {
                int i2 = ai[0 + (l1 + 0) * l];
                int k2 = ai[0 + (l1 + 1) * l];

                for (int l2 = 0; l2 < l - 1; l2++)
                {
                    double d = (double)i * 0.90000000000000002D;
                    InitChunkSeed(l2 + j << byte0, l1 + k << byte0);
                    double d1 = ((double)NextInt(1024) / 1024D - 0.5D) * d;
                    double d2 = ((double)NextInt(1024) / 1024D - 0.5D) * d;
                    InitChunkSeed(l2 + j + 1 << byte0, l1 + k << byte0);
                    double d3 = ((double)NextInt(1024) / 1024D - 0.5D) * d + (double)i;
                    double d4 = ((double)NextInt(1024) / 1024D - 0.5D) * d;
                    InitChunkSeed(l2 + j << byte0, l1 + k + 1 << byte0);
                    double d5 = ((double)NextInt(1024) / 1024D - 0.5D) * d;
                    double d6 = ((double)NextInt(1024) / 1024D - 0.5D) * d + (double)i;
                    InitChunkSeed(l2 + j + 1 << byte0, l1 + k + 1 << byte0);
                    double d7 = ((double)NextInt(1024) / 1024D - 0.5D) * d + (double)i;
                    double d8 = ((double)NextInt(1024) / 1024D - 0.5D) * d + (double)i;
                    int    i3 = ai[l2 + 1 + (l1 + 0) * l];
                    int    j3 = ai[l2 + 1 + (l1 + 1) * l];

                    for (int k3 = 0; k3 < i; k3++)
                    {
                        int l3 = ((l1 << byte0) + k3) * j1 + (l2 << byte0);

                        for (int i4 = 0; i4 < i; i4++)
                        {
                            double d9  = ((double)k3 - d2) * ((double)k3 - d2) + ((double)i4 - d1) * ((double)i4 - d1);
                            double d10 = ((double)k3 - d4) * ((double)k3 - d4) + ((double)i4 - d3) * ((double)i4 - d3);
                            double d11 = ((double)k3 - d6) * ((double)k3 - d6) + ((double)i4 - d5) * ((double)i4 - d5);
                            double d12 = ((double)k3 - d8) * ((double)k3 - d8) + ((double)i4 - d7) * ((double)i4 - d7);

                            if (d9 < d10 && d9 < d11 && d9 < d12)
                            {
                                ai1[l3++] = i2;
                                continue;
                            }

                            if (d10 < d9 && d10 < d11 && d10 < d12)
                            {
                                ai1[l3++] = i3;
                                continue;
                            }

                            if (d11 < d9 && d11 < d10 && d11 < d12)
                            {
                                ai1[l3++] = k2;
                            }
                            else
                            {
                                ai1[l3++] = j3;
                            }
                        }
                    }

                    i2 = i3;
                    k2 = j3;
                }
            }

            int[] ai2 = IntCache.GetIntCache(par3 * par4);

            for (int j2 = 0; j2 < par4; j2++)
            {
                Array.Copy(ai1, (j2 + (par2 & i - 1)) * (l << byte0) + (par1 & i - 1), ai2, j2 * par3, par3);
            }

            return(ai2);
        }