Beispiel #1
0
        public static void Place(DesertDescription description)
        {
            ClusterGroup clusters = ClusterGroup.FromDescription(description);

            PlaceClusters(description, clusters);
            AddTileVariance(description);
        }
Beispiel #2
0
        public static void Place(DesertDescription description)
        {
            int   num      = description.Desert.Center.X + WorldGen.genRand.Next(-40, 41);
            Point position = new Point(num, description.Surface[num]);

            PlaceAt(description, position);
        }
Beispiel #3
0
        public static void Place(DesertDescription description)
        {
            int   x        = description.Desert.Center.X + WorldGen.genRand.Next(-40, 41);
            Point position = new Point(x, (int)description.Surface[x]);

            ChambersEntrance.PlaceAt(description, position);
        }
Beispiel #4
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
            });
        }
        private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
        {
            ShapeData data   = new ShapeData();
            Point     origin = new Point(position.X, position.Y + 6);

            WorldUtils.Gen(origin, new Shapes.Tail(holeRadius * 2, new Vector2(0f, (float)(-holeRadius) * 1.5f)), Actions.Chain(new Actions.SetTile(53).Output(data)));
            GenShapeActionPair genShapeActionPair  = new GenShapeActionPair(new Shapes.Rectangle(1, 1), Actions.Chain(new Modifiers.Blotches(), new Modifiers.IsSolid(), new Actions.Clear(), new Actions.PlaceWall(187)));
            GenShapeActionPair genShapeActionPair2 = new GenShapeActionPair(new Shapes.Rectangle(1, 1), Actions.Chain(new Modifiers.IsSolid(), new Actions.Clear(), new Actions.PlaceWall(187)));
            GenShapeActionPair pair  = new GenShapeActionPair(new Shapes.Circle(2, 3), Actions.Chain(new Modifiers.IsSolid(), new Actions.SetTile(397), new Actions.PlaceWall(187)));
            GenShapeActionPair pair2 = new GenShapeActionPair(new Shapes.Circle(holeRadius, 3), Actions.Chain(new Modifiers.SkipWalls(187), new Actions.SetTile(53)));
            GenShapeActionPair pair3 = new GenShapeActionPair(new Shapes.Circle(holeRadius - 2, 3), Actions.Chain(new Actions.PlaceWall(187)));
            int num = position.X;

            for (int i = position.Y - holeRadius - 3; i < description.Hive.Top + (position.Y - description.Desert.Top) * 2 + 12; i++)
            {
                WorldUtils.Gen(new Point(num, i), (i < position.Y) ? genShapeActionPair2 : genShapeActionPair);
                WorldUtils.Gen(new Point(num, i), pair);
                if (i % 3 == 0 && i >= position.Y)
                {
                    num += WorldGen.genRand.Next(-1, 2);
                    WorldUtils.Gen(new Point(num, i), genShapeActionPair);
                    if (i >= position.Y + 5)
                    {
                        WorldUtils.Gen(new Point(num, i), pair2);
                        WorldUtils.Gen(new Point(num, i), pair3);
                    }
                    WorldUtils.Gen(new Point(num, i), pair);
                }
            }
            WorldUtils.Gen(new Point(origin.X, origin.Y - (int)((float)holeRadius * 1.5f) + 3), new Shapes.Circle(holeRadius / 2, holeRadius / 3), Actions.Chain(Actions.Chain(new Actions.ClearTile(), new Modifiers.Expand(1), new Actions.PlaceWall(0))));
            WorldUtils.Gen(origin, new ModShapes.All(data), new Actions.Smooth());
        }
        public static void Place(DesertDescription description)
        {
            int   holeRadius = WorldGen.genRand.Next(6, 9);
            Point center     = description.CombinedArea.Center;

            center.Y = description.Surface[center.X];
            PlaceAt(description, center, holeRadius);
        }
Beispiel #7
0
 private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
 {
     for (int index = -holeRadius - 3; index < holeRadius + 3; ++index)
     {
         int j = (int)description.Surface[index + position.X];
         while (true)
         {
             int       num1      = j;
             Rectangle rectangle = description.Hive;
             int       num2      = rectangle.Top + 10;
             if (num1 <= num2)
             {
                 double num3 = (double)(j - (int)description.Surface[index + position.X]);
                 rectangle = description.Hive;
                 int top1 = rectangle.Top;
                 rectangle = description.Desert;
                 int    top2      = rectangle.Top;
                 double num4      = (double)(top1 - top2);
                 float  yProgress = MathHelper.Clamp((float)(num3 / num4), 0.0f, 1f);
                 int    num5      = (int)((double)PitEntrance.GetHoleRadiusScaleAt(yProgress) * (double)holeRadius);
                 if (Math.Abs(index) < num5)
                 {
                     Main.tile[index + position.X, j].ClearEverything();
                 }
                 else if (Math.Abs(index) < num5 + 3 && (double)yProgress > 0.349999994039536)
                 {
                     Main.tile[index + position.X, j].ResetToType((ushort)397);
                 }
                 float num6 = Math.Abs((float)index / (float)holeRadius);
                 float num7 = num6 * num6;
                 if (Math.Abs(index) < num5 + 3 && (double)(j - position.Y) > 15.0 - 3.0 * (double)num7)
                 {
                     Main.tile[index + position.X, j].wall = (ushort)187;
                     WorldGen.SquareWallFrame(index + position.X, j - 1, true);
                     WorldGen.SquareWallFrame(index + position.X, j, true);
                 }
                 ++j;
             }
             else
             {
                 break;
             }
         }
     }
     holeRadius += 4;
     for (int index1 = -holeRadius; index1 < holeRadius; ++index1)
     {
         int num1 = holeRadius - Math.Abs(index1);
         int num2 = Math.Min(10, num1 * num1);
         for (int index2 = 0; index2 < num2; ++index2)
         {
             Main.tile[index1 + position.X, index2 + (int)description.Surface[index1 + position.X]].ClearEverything();
         }
     }
 }
Beispiel #8
0
        public static void Place(DesertDescription description)
        {
            int num = WorldGen.genRand.Next(2, 4);

            for (int index = 0; index < num; ++index)
            {
                int holeRadius = WorldGen.genRand.Next(13, 16);
                int x          = (int)((double)(index + 1) / (double)(num + 1) * (double)description.Surface.Width) + description.Desert.Left;
                int y          = (int)description.Surface[x];
                LarvaHoleEntrance.PlaceAt(description, new Point(x, y), holeRadius);
            }
        }
Beispiel #9
0
        private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
        {
            ShapeData data   = new ShapeData();
            Point     origin = new Point(position.X, position.Y + 6);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Tail((float)(holeRadius * 2), new Vector2(0.0f, (float)-holeRadius * 1.5f)), Actions.Chain(new Actions.SetTile((ushort)53, false, true).Output(data)));
            GenShapeActionPair pair1 = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair genShapeActionPair = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair pair2 = new GenShapeActionPair((GenShape) new Shapes.Circle(2, 3), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort)397, false, true), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair pair3 = new GenShapeActionPair((GenShape) new Shapes.Circle(holeRadius, 3), Actions.Chain((GenAction) new Modifiers.SkipWalls(new ushort[1]
            {
                (ushort)187
            }), (GenAction) new Actions.SetTile((ushort)53, false, true)));
            GenShapeActionPair pair4 = new GenShapeActionPair((GenShape) new Shapes.Circle(holeRadius - 2, 3), Actions.Chain((GenAction) new Actions.PlaceWall((ushort)187, true)));
            int x  = position.X;
            int y1 = position.Y - holeRadius - 3;

            while (true)
            {
                int num1 = y1;
                Microsoft.Xna.Framework.Rectangle rectangle = description.Hive;
                int top1 = rectangle.Top;
                int y2   = position.Y;
                rectangle = description.Desert;
                int top2 = rectangle.Top;
                int num2 = (y2 - top2) * 2;
                int num3 = top1 + num2 + 12;
                if (num1 < num3)
                {
                    WorldUtils.Gen(new Point(x, y1), y1 < position.Y ? genShapeActionPair : pair1);
                    WorldUtils.Gen(new Point(x, y1), pair2);
                    if (y1 % 3 == 0 && y1 >= position.Y)
                    {
                        x += WorldGen.genRand.Next(-1, 2);
                        WorldUtils.Gen(new Point(x, y1), pair1);
                        if (y1 >= position.Y + 5)
                        {
                            WorldUtils.Gen(new Point(x, y1), pair3);
                            WorldUtils.Gen(new Point(x, y1), pair4);
                        }
                        WorldUtils.Gen(new Point(x, y1), pair2);
                    }
                    ++y1;
                }
                else
                {
                    break;
                }
            }
            WorldUtils.Gen(new Point(origin.X, origin.Y - (int)((double)holeRadius * 1.5) + 3), (GenShape) new Shapes.Circle(holeRadius / 2, holeRadius / 3), Actions.Chain(Actions.Chain((GenAction) new Actions.ClearTile(false), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort)0, true))));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), (GenAction) new Actions.Smooth(false));
        }
        public static void Place(DesertDescription description)
        {
            int num = WorldGen.genRand.Next(2, 4);

            for (int i = 0; i < num; i++)
            {
                int holeRadius = WorldGen.genRand.Next(15, 18);
                int num2       = (int)((float)(i + 1) / (float)(num + 1) * (float)description.Surface.Width);
                num2 += description.Desert.Left;
                int y = description.Surface[num2];
                PlaceAt(description, new Point(num2, y), holeRadius);
            }
        }
Beispiel #11
0
        private static void PlaceAt(DesertDescription description, Point position)
        {
            ShapeData shapeData = new ShapeData();
            Point     origin    = new Point(position.X, position.Y + 2);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(24, 12), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), new Actions.SetTile((ushort)53, false, true).Output(shapeData)));
            UnifiedRandom genRand   = WorldGen.genRand;
            ShapeData     data      = new ShapeData();
            int           num1      = description.Hive.Top - position.Y;
            int           direction = genRand.Next(2) == 0 ? -1 : 1;
            List <ChambersEntrance.PathConnection> pathConnectionList = new List <ChambersEntrance.PathConnection>()
            {
                new ChambersEntrance.PathConnection(new Point(position.X + -direction * 26, position.Y - 8), direction)
            };
            int num2 = genRand.Next(2, 4);

            for (int index = 0; index < num2; ++index)
            {
                int y    = (int)((double)(index + 1) / (double)num2 * (double)num1) + genRand.Next(-8, 9);
                int x    = direction * genRand.Next(20, 41);
                int num3 = genRand.Next(18, 29);
                WorldUtils.Gen(position, (GenShape) new Shapes.Circle(num3 / 2, 3), Actions.Chain((GenAction) new Modifiers.Offset(x, y), (GenAction) new Modifiers.Blotches(2, 0.3), new Actions.Clear().Output(data), (GenAction) new Actions.PlaceWall((ushort)187, true)));
                pathConnectionList.Add(new ChambersEntrance.PathConnection(new Point(x + num3 / 2 * -direction + position.X, y + position.Y), -direction));
                direction *= -1;
            }
            WorldUtils.Gen(position, (GenShape) new ModShapes.OuterOutline(data, true, false), Actions.Chain((GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)53
            }), (GenAction) new Actions.SetTile((ushort)397, false, true), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair pair = new GenShapeActionPair((GenShape) new Shapes.Rectangle(2, 4), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Clear(), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort)187, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)53
            }), (GenAction) new Actions.SetTile((ushort)397, false, true)));

            for (int index = 1; index < pathConnectionList.Count; ++index)
            {
                ChambersEntrance.PathConnection pathConnection1 = pathConnectionList[index - 1];
                ChambersEntrance.PathConnection pathConnection2 = pathConnectionList[index];
                float num3 = Math.Abs(pathConnection2.Position.X - pathConnection1.Position.X) * 1.5f;
                for (float amount = 0.0f; (double)amount <= 1.0; amount += 0.02f)
                {
                    Vector2 vector2_1 = new Vector2(pathConnection1.Position.X + pathConnection1.Direction * num3 * amount, pathConnection1.Position.Y);
                    Vector2 vector2_2 = new Vector2(pathConnection2.Position.X + (float)((double)pathConnection2.Direction * (double)num3 * (1.0 - (double)amount)), pathConnection2.Position.Y);
                    Vector2 vector2_3 = Vector2.Lerp(pathConnection1.Position, pathConnection2.Position, amount);
                    Vector2 vector2_4 = vector2_3;
                    double  num4      = (double)amount;
                    WorldUtils.Gen(Vector2.Lerp(Vector2.Lerp(vector2_1, vector2_4, (float)num4), Vector2.Lerp(vector2_3, vector2_2, amount), amount).ToPoint(), pair);
                }
            }
            WorldUtils.Gen(origin, (GenShape) new Shapes.Rectangle(new Microsoft.Xna.Framework.Rectangle(-29, -12, 58, 12)), Actions.Chain((GenAction) new Modifiers.NotInShape(shapeData), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort)0, true)));
        }
Beispiel #12
0
        private static void PlaceAt(DesertDescription description, Point position)
        {
            ShapeData shapeData = new ShapeData();
            Point     origin    = new Point(position.X, position.Y + 2);

            WorldUtils.Gen(origin, new Shapes.Circle(24, 12), Actions.Chain(new Modifiers.Blotches(), new Actions.SetTile(53).Output(shapeData)));
            UnifiedRandom         genRand = WorldGen.genRand;
            ShapeData             data    = new ShapeData();
            int                   num     = description.Hive.Top - position.Y;
            int                   num2    = (genRand.Next(2) != 0) ? 1 : (-1);
            List <PathConnection> list    = new List <PathConnection>
            {
                new PathConnection(new Point(position.X + -num2 * 26, position.Y - 8), num2)
            };
            int num3 = genRand.Next(2, 4);

            for (int i = 0; i < num3; i++)
            {
                int num4 = (int)((float)(i + 1) / (float)num3 * (float)num) + genRand.Next(-8, 9);
                int num5 = num2 * genRand.Next(20, 41);
                int num6 = genRand.Next(18, 29);
                WorldUtils.Gen(position, new Shapes.Circle(num6 / 2, 3), Actions.Chain(new Modifiers.Offset(num5, num4), new Modifiers.Blotches(), new Actions.Clear().Output(data), new Actions.PlaceWall(187)));
                list.Add(new PathConnection(new Point(num5 + num6 / 2 * -num2 + position.X, num4 + position.Y), -num2));
                num2 *= -1;
            }
            WorldUtils.Gen(position, new ModShapes.OuterOutline(data), Actions.Chain(new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397), new Actions.PlaceWall(187)));
            GenShapeActionPair pair = new GenShapeActionPair(new Shapes.Rectangle(2, 4), Actions.Chain(new Modifiers.IsSolid(), new Modifiers.Blotches(), new Actions.Clear(), new Modifiers.Expand(1), new Actions.PlaceWall(187), new Modifiers.OnlyTiles(53), new Actions.SetTile(397)));

            for (int j = 1; j < list.Count; j++)
            {
                PathConnection pathConnection  = list[j - 1];
                PathConnection pathConnection2 = list[j];
                float          num7            = Math.Abs(pathConnection2.Position.X - pathConnection.Position.X) * 1.5f;
                for (float num8 = 0f; num8 <= 1f; num8 += 0.02f)
                {
                    Vector2 value  = new Vector2(pathConnection.Position.X + pathConnection.Direction * num7 * num8, pathConnection.Position.Y);
                    Vector2 value2 = new Vector2(pathConnection2.Position.X + pathConnection2.Direction * num7 * (1f - num8), pathConnection2.Position.Y);
                    Vector2 vector = Vector2.Lerp(pathConnection.Position, pathConnection2.Position, num8);
                    Vector2 value3 = Vector2.Lerp(value, vector, num8);
                    Vector2 value4 = Vector2.Lerp(vector, value2, num8);
                    WorldUtils.Gen(Vector2.Lerp(value3, value4, num8).ToPoint(), pair);
                }
            }
            WorldUtils.Gen(origin, new Shapes.Rectangle(new Rectangle(-29, -12, 58, 12)), Actions.Chain(new Modifiers.NotInShape(shapeData), new Modifiers.Expand(1), new Actions.PlaceWall(0)));
        }
Beispiel #13
0
        private static void PlaceClusters(DesertDescription description, ClusterGroup clusters)
        {
            Rectangle hive = description.Hive;

            hive.Inflate(20, 20);
            PostPlacementEffect[,] array = new PostPlacementEffect[hive.Width, hive.Height];
            PlaceClustersArea(description, clusters, hive, array, Point.Zero);
            for (int i = hive.Left; i < hive.Right; i++)
            {
                for (int j = hive.Top; j < hive.Bottom; j++)
                {
                    PostPlacementEffect postPlacementEffect = array[i - hive.Left, j - hive.Top];
                    if (postPlacementEffect.HasFlag(PostPlacementEffect.Smooth))
                    {
                        Tile.SmoothSlope(i, j, applyToNeighbors: false);
                    }
                }
            }
        }
        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);
            }
        }
Beispiel #15
0
        private static void PlaceClusters(
            DesertDescription description,
            DesertHive.ClusterGroup clusters)
        {
            Rectangle hive = description.Hive;

            hive.Inflate(20, 20);
            DesertHive.PostPlacementEffect[,] postEffectMap = new DesertHive.PostPlacementEffect[hive.Width, hive.Height];
            DesertHive.PlaceClustersArea(description, clusters, hive, postEffectMap, Point.Zero);
            for (int left = hive.Left; left < hive.Right; ++left)
            {
                for (int top = hive.Top; top < hive.Bottom; ++top)
                {
                    if (postEffectMap[left - hive.Left, top - hive.Top].HasFlag((Enum)DesertHive.PostPlacementEffect.Smooth))
                    {
                        Tile.SmoothSlope(left, top, false, false);
                    }
                }
            }
        }
Beispiel #16
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);
            }
        }
 private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
 {
     for (int i = -holeRadius - 3; i < holeRadius + 3; i++)
     {
         for (int j = description.Surface[i + position.X]; j <= description.Hive.Top + 10; j++)
         {
             float value = (float)(j - description.Surface[i + position.X]) / (float)(description.Hive.Top - description.Desert.Top);
             value = MathHelper.Clamp(value, 0f, 1f);
             int num = (int)(GetHoleRadiusScaleAt(value) * (float)holeRadius);
             if (Math.Abs(i) < num)
             {
                 Main.tile[i + position.X, j].ClearEverything();
             }
             else if (Math.Abs(i) < num + 3 && value > 0.35f)
             {
                 Main.tile[i + position.X, j].ResetToType(397);
             }
             float num2 = Math.Abs((float)i / (float)holeRadius);
             num2 *= num2;
             if (Math.Abs(i) < num + 3 && (float)(j - position.Y) > 15f - 3f * num2)
             {
                 Main.tile[i + position.X, j].wall = 187;
                 WorldGen.SquareWallFrame(i + position.X, j - 1);
                 WorldGen.SquareWallFrame(i + position.X, j);
             }
         }
     }
     holeRadius += 4;
     for (int k = -holeRadius; k < holeRadius; k++)
     {
         int num3 = holeRadius - Math.Abs(k);
         num3 = Math.Min(10, num3 * num3);
         for (int l = 0; l < num3; l++)
         {
             Main.tile[k + position.X, l + description.Surface[k + position.X]].ClearEverything();
         }
     }
 }
Beispiel #18
0
        private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
        {
            ShapeData data = new ShapeData();

            WorldUtils.Gen(position, new Shapes.Rectangle(new Rectangle(-holeRadius, -holeRadius * 2, holeRadius * 2, holeRadius * 2)), new Actions.Clear().Output(data));
            WorldUtils.Gen(position, new Shapes.Tail(holeRadius * 2, new Vector2(0f, (float)holeRadius * 1.5f)), Actions.Chain(new Actions.Clear().Output(data)));
            WorldUtils.Gen(position, new ModShapes.All(data), Actions.Chain(new Modifiers.Offset(0, 1), new Modifiers.Expand(1), new Modifiers.IsSolid(), new Actions.Smooth(applyToNeighbors: true)));
            GenShapeActionPair pair  = new GenShapeActionPair(new Shapes.Rectangle(1, 1), Actions.Chain(new Modifiers.Blotches(), new Modifiers.IsSolid(), new Actions.Clear(), new Actions.PlaceWall(187)));
            GenShapeActionPair pair2 = new GenShapeActionPair(new Shapes.Circle(2, 3), Actions.Chain(new Modifiers.IsSolid(), new Actions.SetTile(397), new Actions.PlaceWall(187)));
            int num = position.X;

            for (int i = position.Y + (int)((float)holeRadius * 1.5f); i < description.Hive.Top + (position.Y - description.Desert.Top) * 2 + 12; i++)
            {
                WorldUtils.Gen(new Point(num, i), pair);
                WorldUtils.Gen(new Point(num, i), pair2);
                if (i % 3 == 0)
                {
                    num += WorldGen.genRand.Next(-1, 2);
                    WorldUtils.Gen(new Point(num, i), pair);
                    WorldUtils.Gen(new Point(num, i), pair2);
                }
            }
            WorldUtils.Gen(new Point(position.X, position.Y + 2), new ModShapes.All(data), new Actions.PlaceWall(0));
        }
Beispiel #19
0
 private static void AddTileVariance(DesertDescription description)
 {
     for (int i = -20; i < description.Hive.Width + 20; i++)
     {
         for (int j = -20; j < description.Hive.Height + 20; j++)
         {
             int num  = i + description.Hive.X;
             int num2 = j + description.Hive.Y;
             if (WorldGen.InWorld(num, num2, 1))
             {
                 Tile tile      = Main.tile[num, num2];
                 Tile testTile  = Main.tile[num, num2 + 1];
                 Tile testTile2 = Main.tile[num, num2 + 2];
                 if (tile.type == 53 && (!WorldGen.SolidTile(testTile) || !WorldGen.SolidTile(testTile2)))
                 {
                     tile.type = 397;
                 }
             }
         }
     }
     for (int k = -20; k < description.Hive.Width + 20; k++)
     {
         for (int l = -20; l < description.Hive.Height + 20; l++)
         {
             int num3 = k + description.Hive.X;
             int num4 = l + description.Hive.Y;
             if (!WorldGen.InWorld(num3, num4, 1))
             {
                 continue;
             }
             Tile tile2 = Main.tile[num3, num4];
             if (!tile2.active() || tile2.type != 396)
             {
                 continue;
             }
             bool flag = true;
             for (int num5 = -1; num5 >= -3; num5--)
             {
                 if (Main.tile[num3, num4 + num5].active())
                 {
                     flag = false;
                     break;
                 }
             }
             bool flag2 = true;
             for (int m = 1; m <= 3; m++)
             {
                 if (Main.tile[num3, num4 + m].active())
                 {
                     flag2 = false;
                     break;
                 }
             }
             if (flag && WorldGen.genRand.Next(5) == 0)
             {
                 WorldGen.PlaceTile(num3, num4 - 1, 485, mute: true, forced: true, -1, WorldGen.genRand.Next(4));
             }
             else if (flag && WorldGen.genRand.Next(5) == 0)
             {
                 WorldGen.PlaceTile(num3, num4 - 1, 484, mute: true, forced: true);
             }
             else if ((flag ^ flag2) && WorldGen.genRand.Next(5) == 0)
             {
                 WorldGen.PlaceTile(num3, num4 + ((!flag) ? 1 : (-1)), 165, mute: true, forced: true);
             }
             else if (flag && WorldGen.genRand.Next(5) == 0)
             {
                 WorldGen.PlaceTile(num3, num4 - 1, 187, mute: true, forced: true, -1, 29 + WorldGen.genRand.Next(6));
             }
         }
     }
 }
Beispiel #20
0
        private static void PlaceClustersArea(DesertDescription description, ClusterGroup clusters, Rectangle area, PostPlacementEffect[,] postEffectMap, Point postEffectMapOffset)
        {
            FastRandom fastRandom = new FastRandom(Main.ActiveWorldFileData.Seed).WithModifier(57005uL);
            Vector2    value      = new Vector2(description.Hive.Width, description.Hive.Height);
            Vector2    value2     = new Vector2(clusters.Width, clusters.Height);
            Vector2    value3     = description.BlockScale / 2f;

            for (int i = area.Left; i < area.Right; i++)
            {
                for (int j = area.Top; j < area.Bottom; j++)
                {
                    if (!WorldGen.InWorld(i, j, 1))
                    {
                        continue;
                    }
                    float  num  = 0f;
                    int    num2 = -1;
                    float  num3 = 0f;
                    ushort type = 53;
                    if (fastRandom.Next(3) == 0)
                    {
                        type = 397;
                    }
                    int     num4   = i - description.Hive.X;
                    int     num5   = j - description.Hive.Y;
                    Vector2 value4 = (new Vector2(num4, num5) - value3) / value * value2;
                    for (int k = 0; k < clusters.Count; k++)
                    {
                        Cluster cluster = clusters[k];
                        if (Math.Abs(cluster[0].Position.X - value4.X) > 10f || Math.Abs(cluster[0].Position.Y - value4.Y) > 10f)
                        {
                            continue;
                        }
                        float num6 = 0f;
                        foreach (Block item in cluster)
                        {
                            num6 += 1f / Vector2.DistanceSquared(item.Position, value4);
                        }
                        if (num6 > num)
                        {
                            if (num > num3)
                            {
                                num3 = num;
                            }
                            num  = num6;
                            num2 = k;
                        }
                        else if (num6 > num3)
                        {
                            num3 = num6;
                        }
                    }
                    float num7 = num + num3;
                    Tile  tile = Main.tile[i, j];
                    bool  flag = ((new Vector2(num4, num5) - value3) / value * 2f - Vector2.One).Length() >= 0.8f;
                    PostPlacementEffect postPlacementEffect = PostPlacementEffect.None;
                    if (num7 > 3.5f)
                    {
                        postPlacementEffect = PostPlacementEffect.Smooth;
                        tile.ClearEverything();
                        tile.wall = 187;
                        if (num2 % 15 == 2)
                        {
                            tile.ResetToType(404);
                        }
                    }
                    else if (num7 > 1.8f)
                    {
                        tile.wall = 187;
                        if ((double)j < Main.worldSurface)
                        {
                            tile.liquid = 0;
                        }
                        else
                        {
                            tile.lava(lava: true);
                        }
                        if (!flag || tile.active())
                        {
                            tile.ResetToType(396);
                            postPlacementEffect = PostPlacementEffect.Smooth;
                        }
                    }
                    else if (num7 > 0.7f || !flag)
                    {
                        tile.wall   = 216;
                        tile.liquid = 0;
                        if (!flag || tile.active())
                        {
                            tile.ResetToType(type);
                            postPlacementEffect = PostPlacementEffect.Smooth;
                        }
                    }
                    else if (num7 > 0.25f)
                    {
                        FastRandom fastRandom2 = fastRandom.WithModifier(num4, num5);
                        float      num8        = (num7 - 0.25f) / 0.45f;
                        if (fastRandom2.NextFloat() < num8)
                        {
                            tile.wall = 187;
                            if ((double)j < Main.worldSurface)
                            {
                                tile.liquid = 0;
                            }
                            else
                            {
                                tile.lava(lava: true);
                            }
                            if (tile.active())
                            {
                                tile.ResetToType(type);
                                postPlacementEffect = PostPlacementEffect.Smooth;
                            }
                        }
                    }
                    postEffectMap[i - area.X + postEffectMapOffset.X, j - area.Y + postEffectMapOffset.Y] = postPlacementEffect;
                }
            }
        }
Beispiel #21
0
 public static void Place(DesertDescription description)
 {
     DesertHive.ClusterGroup clusters = DesertHive.ClusterGroup.FromDescription(description);
     DesertHive.PlaceClusters(description, clusters);
     DesertHive.AddTileVariance(description);
 }
Beispiel #22
0
 private static void AddTileVariance(DesertDescription description)
 {
     for (int index1 = -20; index1 < description.Hive.Width + 20; ++index1)
     {
         for (int index2 = -20; index2 < description.Hive.Height + 20; ++index2)
         {
             int x = index1 + description.Hive.X;
             int y = index2 + description.Hive.Y;
             if (WorldGen.InWorld(x, y, 1))
             {
                 Tile tile      = Main.tile[x, y];
                 Tile testTile1 = Main.tile[x, y + 1];
                 Tile testTile2 = Main.tile[x, y + 2];
                 if (tile.type == (ushort)53 && (!WorldGen.SolidTile(testTile1) || !WorldGen.SolidTile(testTile2)))
                 {
                     tile.type = (ushort)397;
                 }
             }
         }
     }
     for (int index1 = -20; index1 < description.Hive.Width + 20; ++index1)
     {
         for (int index2 = -20; index2 < description.Hive.Height + 20; ++index2)
         {
             int index3 = index1 + description.Hive.X;
             int y      = index2 + description.Hive.Y;
             if (WorldGen.InWorld(index3, y, 1))
             {
                 Tile tile = Main.tile[index3, y];
                 if (tile.active() && tile.type == (ushort)396)
                 {
                     bool flag1 = true;
                     for (int index4 = -1; index4 >= -3; --index4)
                     {
                         if (Main.tile[index3, y + index4].active())
                         {
                             flag1 = false;
                             break;
                         }
                     }
                     bool flag2 = true;
                     for (int index4 = 1; index4 <= 3; ++index4)
                     {
                         if (Main.tile[index3, y + index4].active())
                         {
                             flag2 = false;
                             break;
                         }
                     }
                     if (flag1 && WorldGen.genRand.Next(5) == 0)
                     {
                         WorldGen.PlaceTile(index3, y - 1, 485, true, true, -1, WorldGen.genRand.Next(4));
                     }
                     else if (flag1 && WorldGen.genRand.Next(5) == 0)
                     {
                         WorldGen.PlaceTile(index3, y - 1, 484, true, true, -1, 0);
                     }
                     else if (flag1 ^ flag2 && WorldGen.genRand.Next(5) == 0)
                     {
                         WorldGen.PlaceTile(index3, y + (flag1 ? -1 : 1), 165, true, true, -1, 0);
                     }
                     else if (flag1 && WorldGen.genRand.Next(5) == 0)
                     {
                         WorldGen.PlaceTile(index3, y - 1, 187, true, true, -1, 29 + WorldGen.genRand.Next(6));
                     }
                 }
             }
         }
     }
 }
Beispiel #23
0
 public static DesertHive.ClusterGroup FromDescription(DesertDescription description)
 {
     return(new DesertHive.ClusterGroup(description.BlockColumnCount, description.BlockRowCount));
 }
Beispiel #24
0
        private static void PlaceClustersArea(
            DesertDescription description,
            DesertHive.ClusterGroup clusters,
            Rectangle area,
            DesertHive.PostPlacementEffect[,] postEffectMap,
            Point postEffectMapOffset)
        {
            FastRandom fastRandom = new FastRandom(Main.ActiveWorldFileData.Seed).WithModifier(57005UL);
            Vector2    vector2_1  = new Vector2((float)description.Hive.Width, (float)description.Hive.Height);
            Vector2    vector2_2  = new Vector2((float)clusters.Width, (float)clusters.Height);
            Vector2    vector2_3  = description.BlockScale / 2f;

            for (int left = area.Left; left < area.Right; ++left)
            {
                for (int top = area.Top; top < area.Bottom; ++top)
                {
                    if (WorldGen.InWorld(left, top, 1))
                    {
                        float  num1 = 0.0f;
                        int    num2 = -1;
                        float  num3 = 0.0f;
                        ushort type = 53;
                        if (fastRandom.Next(3) == 0)
                        {
                            type = (ushort)397;
                        }
                        int     x         = left - description.Hive.X;
                        int     y         = top - description.Hive.Y;
                        Vector2 vector2_4 = (new Vector2((float)x, (float)y) - vector2_3) / vector2_1 * vector2_2;
                        for (int index = 0; index < clusters.Count; ++index)
                        {
                            DesertHive.Cluster cluster = clusters[index];
                            if ((double)Math.Abs(cluster[0].Position.X - vector2_4.X) <= 10.0 && (double)Math.Abs(cluster[0].Position.Y - vector2_4.Y) <= 10.0)
                            {
                                float num4 = 0.0f;
                                foreach (DesertHive.Block block in (List <DesertHive.Block>)cluster)
                                {
                                    num4 += 1f / Vector2.DistanceSquared(block.Position, vector2_4);
                                }
                                if ((double)num4 > (double)num1)
                                {
                                    if ((double)num1 > (double)num3)
                                    {
                                        num3 = num1;
                                    }
                                    num1 = num4;
                                    num2 = index;
                                }
                                else if ((double)num4 > (double)num3)
                                {
                                    num3 = num4;
                                }
                            }
                        }
                        float num5 = num1 + num3;
                        Tile  tile = Main.tile[left, top];
                        bool  flag = (double)((new Vector2((float)x, (float)y) - vector2_3) / vector2_1 * 2f - Vector2.One).Length() >= 0.800000011920929;
                        DesertHive.PostPlacementEffect postPlacementEffect = DesertHive.PostPlacementEffect.None;
                        if ((double)num5 > 3.5)
                        {
                            postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
                            tile.ClearEverything();
                            tile.wall = (ushort)187;
                            if (num2 % 15 == 2)
                            {
                                tile.ResetToType((ushort)404);
                            }
                        }
                        else if ((double)num5 > 1.79999995231628)
                        {
                            tile.wall = (ushort)187;
                            if ((double)top < Main.worldSurface)
                            {
                                tile.liquid = (byte)0;
                            }
                            else
                            {
                                tile.lava(true);
                            }
                            if (!flag || tile.active())
                            {
                                tile.ResetToType((ushort)396);
                                postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
                            }
                        }
                        else if ((double)num5 > 0.699999988079071 || !flag)
                        {
                            tile.wall   = (ushort)216;
                            tile.liquid = (byte)0;
                            if (!flag || tile.active())
                            {
                                tile.ResetToType(type);
                                postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
                            }
                        }
                        else if ((double)num5 > 0.25 && (double)fastRandom.WithModifier(x, y).NextFloat() < ((double)num5 - 0.25) / 0.449999988079071)
                        {
                            tile.wall = (ushort)187;
                            if ((double)top < Main.worldSurface)
                            {
                                tile.liquid = (byte)0;
                            }
                            else
                            {
                                tile.lava(true);
                            }
                            if (tile.active())
                            {
                                tile.ResetToType(type);
                                postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
                            }
                        }
                        postEffectMap[left - area.X + postEffectMapOffset.X, top - area.Y + postEffectMapOffset.Y] = postPlacementEffect;
                    }
                }
            }
        }