Exemplo n.º 1
0
        public static DesertDescription CreateFromPlacement(Point origin)
        {
            Vector2 defaultBlockScale = DefaultBlockScale;
            float   num  = (float)Main.maxTilesX / 4200f;
            int     num2 = (int)(80f * num);
            int     num3 = (int)((WorldGen.genRand.NextFloat() + 1f) * 170f * num);
            int     num4 = (int)(defaultBlockScale.X * (float)num2);
            int     num5 = (int)(defaultBlockScale.Y * (float)num3);

            origin.X -= num4 / 2;
            SurfaceMap surfaceMap = SurfaceMap.FromArea(origin.X - 5, num4 + 10);

            if (RowHasInvalidTiles(origin.X, surfaceMap.Bottom, num4))
            {
                return(Invalid);
            }
            int num6 = (int)(surfaceMap.Average + (float)surfaceMap.Bottom) / 2;

            origin.Y = num6 + WorldGen.genRand.Next(40, 60);
            return(new DesertDescription
            {
                CombinedArea = new Rectangle(origin.X, num6, num4, origin.Y + num5 - num6),
                Hive = new Rectangle(origin.X, origin.Y, num4, num5),
                Desert = new Rectangle(origin.X, num6, num4, origin.Y + num5 / 2 - num6),
                BlockScale = defaultBlockScale,
                BlockColumnCount = num2,
                BlockRowCount = num3,
                Surface = surfaceMap,
                IsValid = true
            });
        }
Exemplo n.º 2
0
        public static DesertDescription CreateFromPlacement(Point origin)
        {
            Vector2 defaultBlockScale = DesertDescription.DefaultBlockScale;
            float   num1   = (float)Main.maxTilesX / 4200f;
            int     num2   = (int)(80.0 * (double)num1);
            int     num3   = (int)(((double)WorldGen.genRand.NextFloat() + 1.0) * 170.0 * (double)num1);
            int     width  = (int)((double)defaultBlockScale.X * (double)num2);
            int     height = (int)((double)defaultBlockScale.Y * (double)num3);

            origin.X -= width / 2;
            SurfaceMap surfaceMap = SurfaceMap.FromArea(origin.X - 5, width + 10);

            if (DesertDescription.RowHasInvalidTiles(origin.X, surfaceMap.Bottom, width))
            {
                return(DesertDescription.Invalid);
            }
            int y = (int)((double)surfaceMap.Average + (double)surfaceMap.Bottom) / 2;

            origin.Y = y + WorldGen.genRand.Next(40, 60);
            return(new DesertDescription()
            {
                CombinedArea = new Rectangle(origin.X, y, width, origin.Y + height - y),
                Hive = new Rectangle(origin.X, origin.Y, width, height),
                Desert = new Rectangle(origin.X, y, width, origin.Y + height / 2 - y),
                BlockScale = defaultBlockScale,
                BlockColumnCount = num2,
                BlockRowCount = num3,
                Surface = surfaceMap,
                IsValid = true
            });
        }
Exemplo n.º 3
0
        public static void Place(DesertDescription description)
        {
            Rectangle desert = description.Desert;

            desert.Height = Math.Min(description.Desert.Height, description.Hive.Height / 2);
            Rectangle desert2 = description.Desert;

            desert2.Y      = desert.Bottom;
            desert2.Height = Math.Max(0, description.Desert.Bottom - desert.Bottom);
            SurfaceMap surface = description.Surface;
            int        num     = 0;
            int        num2    = 0;

            for (int i = -5; i < desert.Width + 5; i++)
            {
                float value = Math.Abs((float)(i + 5) / (float)(desert.Width + 10)) * 2f - 1f;
                value = MathHelper.Clamp(value, -1f, 1f);
                if (i % 3 == 0)
                {
                    num += WorldGen.genRand.Next(-1, 2);
                    num  = Utils.Clamp(num, -10, 10);
                }
                num2 += WorldGen.genRand.Next(-1, 2);
                num2  = Utils.Clamp(num2, -10, 10);
                float num3 = (float)Math.Sqrt(1f - value * value * value * value);
                int   num4 = desert.Bottom - (int)(num3 * (float)desert.Height) + num;
                if (Math.Abs(value) < 1f)
                {
                    float num5 = Utils.UnclampedSmoothStep(0.5f, 0.8f, Math.Abs(value));
                    num5 = num5 * num5 * num5;
                    int val = 10 + (int)((float)desert.Top - num5 * 20f) + num2;
                    val = Math.Min(val, num4);
                    for (int j = surface[i + desert.X] - 1; j < val; j++)
                    {
                        int num6 = i + desert.X;
                        int num7 = j;
                        Main.tile[num6, num7].active(active: false);
                        Main.tile[num6, num7].wall = 0;
                    }
                }
                PlaceSandColumn(i + desert.X, num4, desert2.Bottom - num4);
            }
        }
Exemplo n.º 4
0
        public static void Place(DesertDescription description)
        {
            Rectangle desert1 = description.Desert;

            desert1.Height = Math.Min(description.Desert.Height, description.Hive.Height / 2);
            Rectangle desert2 = description.Desert;

            desert2.Y      = desert1.Bottom;
            desert2.Height = Math.Max(0, description.Desert.Bottom - desert1.Bottom);
            SurfaceMap surface = description.Surface;
            int        num1    = 0;
            int        num2    = 0;

            for (int index1 = -5; index1 < desert1.Width + 5; ++index1)
            {
                float num3 = MathHelper.Clamp((float)((double)Math.Abs((float)(index1 + 5) / (float)(desert1.Width + 10)) * 2.0 - 1.0), -1f, 1f);
                if (index1 % 3 == 0)
                {
                    num1 = Utils.Clamp <int>(num1 + WorldGen.genRand.Next(-1, 2), -10, 10);
                }
                num2 = Utils.Clamp <int>(num2 + WorldGen.genRand.Next(-1, 2), -10, 10);
                float num4 = (float)Math.Sqrt(1.0 - (double)num3 * (double)num3 * (double)num3 * (double)num3);
                int   num5 = desert1.Bottom - (int)((double)num4 * (double)desert1.Height) + num1;
                if ((double)Math.Abs(num3) < 1.0)
                {
                    float num6 = Utils.UnclampedSmoothStep(0.5f, 0.8f, Math.Abs(num3));
                    float num7 = num6 * num6 * num6;
                    int   num8 = Math.Min(10 + (int)((double)desert1.Top - (double)num7 * 20.0) + num2, num5);
                    for (int index2 = (int)surface[index1 + desert1.X] - 1; index2 < num8; ++index2)
                    {
                        int index3 = index1 + desert1.X;
                        int index4 = index2;
                        Main.tile[index3, index4].active(false);
                        Main.tile[index3, index4].wall = (ushort)0;
                    }
                }
                SandMound.PlaceSandColumn(index1 + desert1.X, num5, desert2.Bottom - num5);
            }
        }
Exemplo n.º 5
0
 public void UpdateSurfaceMap()
 {
     Surface = SurfaceMap.FromArea(CombinedArea.Left - 5, CombinedArea.Width + 10);
 }
Exemplo n.º 6
0
 public void UpdateSurfaceMap()
 {
     this.Surface = SurfaceMap.FromArea(this.CombinedArea.Left - 5, this.CombinedArea.Width + 10);
 }