ToString() public method

public ToString ( ) : string
return string
Exemplo n.º 1
0
        public Cave(ref Random rnd, ref IMapHandler mh, Vector3i StartingPoint)
        {
            mMap = mh;
            rand = rnd;
            AddPoint(StartingPoint);
            // We need at least 4 points.
            int numPoints2Make = rand.Next(3, 10);
            for(int i=0;i<numPoints2Make;i++)
            {
                i++;
                AddPoint(new Vector3i(StartingPoint.X+rand.Next(-16, 16), StartingPoint.Y+rand.Next(-16, 16), StartingPoint.Z+rand.Next(-16, 16)));
            }
            Profiler profSphere = new Profiler("MakeSphere");
            Profiler profSpline = new Profiler("GetInterpolatedSplinePoint");
            int rad = rand.Next(1, 3);
            for(int p = 0;p<20;p++)
            {
                double t = (double)p/(double)(Points.Count*32);
                // Between 2/10 radius.
                profSpline.Start();
                Vector3i derp = this.GetInterpolatedSplinePoint(t);
                profSpline.Stop();

                mMap.SetBlockAt(derp.X, derp.Y, derp.Z, 0);

                profSphere.Start();
                MakeSphere(derp, rad);
                profSphere.Stop();
                //Console.WriteLine("MakeSphere r={0} @ t={1}", rad, t);
                //t += 0.05;
            }
            mMap.SaveAll();
            Console.WriteLine(profSpline.ToString());
            Console.WriteLine(profSphere.ToString());
        }
Exemplo n.º 2
0
        private void MakeSphere(Vector3i pos, int rad)
        {
            Profiler profRead = new Profiler("Read");
            Profiler profWrite = new Profiler("Write");
            int radsq = rad ^ 2; // So we don't have to do sqrt, which is slow

            for (int x = (int)pos.X - rad; x < pos.X + rad; x++)
            {
                for (int y = (int)pos.Y - rad; y < pos.Y + rad; y++)
                {
                    for (int z = (int)pos.Z - rad; z < pos.Z + rad; z++)
                    {
                        if(y<0||y>=mMap.ChunkScale.Y-1) continue;

                        profRead.Start();
                        byte block = mMap.GetBlockAt(x,y,z);
                        profRead.Stop();
                        //byte blockabove = mMap.GetBlockAt(x,y+1,z);

                        // If water/sand/gravel, or the block above is, abort
                        if (block == 0 || block == 8 || block == 9 || block == 12 || block == 13 || block==KnownBlocks.Error)
                            continue;
                        //if (blockabove == 0 || blockabove == 8 || blockabove == 9 || blockabove == 12 || blockabove == 13)
                        //    continue;

                        int distsq = (x - (int)pos.X) ^ 2 + (y - (int)pos.Y) ^ 2 + (z - (int)pos.Z);
                        if (distsq <= radsq)
                        {
                            profWrite.Start();
                            mMap.SetBlockAt(x, y, z, 0);
                            profWrite.Stop();
                        }
                    }
                }
            }

            Console.WriteLine(profRead.ToString());
            Console.WriteLine(profWrite.ToString());
        }