Beispiel #1
0
            public static Point BrineStart(int i, int j, float sizeMult = 1f)
            {
                ushort stoneID     = (ushort)ModContent.TileType <Sulphur_Stone>();
                ushort stoneWallID = WallID.BlueDungeonSlab;                //(ushort)ModContent.WallType<Riven_Flesh_Wall>();
                int    i2          = i + (int)(genRand.Next(-22, 22) * sizeMult);
                int    j2          = j + (int)(44 * sizeMult);

                for (int x = i2 - (int)(66 * sizeMult + 10); x < i2 + (int)(66 * sizeMult + 10); x++)
                {
                    for (int y = j2 + (int)(56 * sizeMult + 8); y >= j2 - (int)(56 * sizeMult + 8); y--)
                    {
                        float j3   = (Math.Min(j2, y) + j2 * 2) / 3f;
                        float sq   = Math.Max(Math.Abs(y - j3) * 1.5f, Math.Abs(x - i2));
                        float pyth = (((y - j3) * (y - j3) * 1.5f) + (x - i2) * (x - i2));
                        //define the distance between the point and center as a combination of Euclidian distance (dist = sqrt(xdist² + ydist²)) and Chebyshev distance (dist = max(xdist, ydist))
                        float diff = (float)Math.Sqrt((sq * sq + (pyth * 3)) * 0.25f * (GenRunners.GetWallDistOffset(x) * 0.0316076058772687986171132238548f + 1));
                        if (diff > 70 * sizeMult)
                        {
                            continue;
                        }

                        switch (Main.tile[x, y].type)
                        {
                        case TileID.IridescentBrick:
                        case TileID.TinBrick:
                        case TileID.GoldBrick:
                        case TileID.Mudstone:
                            if (Main.tileContainer[Main.tile[x, y - 1].type] || genRand.Next(5) > 0)
                            {
                                break;
                            }
                            goto default;

                        case TileID.LivingMahogany:
                            Main.tile[x, y].type = TileID.Ash;
                            break;

                        default:
                            if (Main.tileContainer[Main.tile[x, y].type])
                            {
                                break;
                            }
                            Main.tile[x, y].ResetToType(stoneID);
                            if (diff < 70 * sizeMult - 10 || ((y - j) * (y - j)) + ((x - i) * (x - i) * 0.5f) < 700 * sizeMult * sizeMult)                              //(x - i) *
                            {
                                if (Main.tileContainer[Main.tile[x, y - 1].type])
                                {
                                    break;
                                }
                                Main.tile[x, y].active(false);
                                //if (y > j2 - (sizeMult * 32)) {
                                Main.tile[x, y].liquid = 255;
                                //}
                            }
                            break;
                        }
                        switch (Main.tile[x, y].wall)
                        {
                        case WallID.IridescentBrick:
                        case WallID.TinBrick:
                        case WallID.GoldBrick:
                        case WallID.MudstoneBrick:
                            if (genRand.Next(5) == 0)
                            {
                                goto default;
                            }
                            break;

                        default:
                            Main.tile[x, y].wall = stoneWallID;
                            break;
                        }
                    }
                }
                int     c        = 0;
                float   size     = 70;
                int     wallSize = 10;
                Vector2 topLeft  = new Vector2(i2, (float)worldSurfaceHigh);
                Vector2 topRight = new Vector2(i2, (float)worldSurfaceHigh);
                int     minX     = int.MaxValue;
                int     maxX     = int.MinValue;

                for (int y = j2 - (int)(50 * sizeMult + 8); y > worldSurfaceLow; y--)
                {
                    c++;
                    int changed = 0;
                    for (int x = i2 - (int)(66 * sizeMult + 10); x < i2 + (int)(66 * sizeMult + 10); x++)
                    {
                        float j3   = (Math.Min(j2 - c, y) + (j2 - c) * 2) / 3f;
                        float sq   = Math.Max(Math.Abs(y - j3) * 1.5f, Math.Abs(x - i2));
                        float pyth = ((y - j3) * (y - j3) * 1.5f) + (x - i2) * (x - i2);
                        float diff = (float)Math.Sqrt((sq * sq + (pyth * 3)) * 0.25f * (GenRunners.GetWallDistOffset((x > i2?c:-c)) * 0.0105358686257562662057044079516f + 1));
                        if (diff > size * sizeMult)
                        {
                            continue;
                        }
                        bool change = false;
                        switch (Main.tile[x, y].type)
                        {
                        case TileID.IridescentBrick:
                        case TileID.TinBrick:
                        case TileID.GoldBrick:
                        case TileID.Mudstone:
                            if (Main.tileContainer[Main.tile[x, y - 1].type] || genRand.Next(5) > 0)
                            {
                                break;
                            }
                            goto default;

                        case TileID.LivingMahogany:
                            Main.tile[x, y].type = TileID.Ash;
                            break;

                        default:
                            if (Main.tileContainer[Main.tile[x, y].type])
                            {
                                break;
                            }
                            if (y > worldSurfaceHigh || (Main.tile[x, y].active() && Main.tileSolid[Main.tile[x, y].type]))
                            {
                                Main.tile[x, y].ResetToType(stoneID);
                                change = true;
                            }
                            if (diff < size * sizeMult - wallSize)                              //(x - i) *
                            {
                                if (Main.tileContainer[Main.tile[x, y - 1].type])
                                {
                                    break;
                                }
                                if (Main.tile[x, y].active())
                                {
                                    change = true;
                                }
                                Main.tile[x, y].active(false);
                                if (y > worldSurfaceHigh)
                                {
                                    Main.tile[x, y].liquid = 255;
                                }
                            }
                            if (y < worldSurfaceHigh && Main.tile[x, y].active() && change)
                            {
                                if (x > i2)//right side
                                {
                                    if (x > maxX)
                                    {
                                        maxX = x;
                                    }
                                    if (y <= topRight.Y)
                                    {
                                        topRight = new Vector2(x, y);
                                    }
                                }
                                else    //left side
                                {
                                    if (x < minX)
                                    {
                                        minX = x;
                                    }
                                    if (y < topLeft.Y)
                                    {
                                        topLeft = new Vector2(x, y);
                                    }
                                }
                            }
                            break;
                        }
                        switch (Main.tile[x, y].wall)
                        {
                        case WallID.IridescentBrick:
                        case WallID.TinBrick:
                        case WallID.GoldBrick:
                        case WallID.MudstoneBrick:
                            if (genRand.Next(5) == 0)
                            {
                                goto default;
                            }
                            break;

                        default:
                            if (y > worldSurfaceHigh)
                            {
                                Main.tile[x, y].wall = stoneWallID;
                            }
                            break;
                        }
                        if (change)
                        {
                            changed++;
                        }
                    }
                    if (y < worldSurfaceHigh)
                    {
                        size -= 0.03f;
                    }
                    if (changed < 23 * sizeMult + 10)
                    {
                        break;
                    }
                }
                int   top   = (int)Math.Max(topLeft.Y, topRight.Y);
                float slope = (topLeft.Y - topRight.Y) / (topRight.X - topLeft.X);
                float minY;
                int   prog = 0;

                for (int x = minX; x < maxX; x++)
                {
                    minY = top - slope * prog + GenRunners.GetWallDistOffset(x + top) * 0.4f;
                    if (x >= topLeft.X && x <= topRight.X)
                    {
                        prog++;
                    }
                    for (int y = (int)(worldSurfaceHigh + 1); y >= minY; y--)
                    {
                        Main.tile[x, y].wall = stoneWallID;
                    }
                }

                return(new Point(i2, j2));
            }
Beispiel #2
0
            public static void DefiledRib(float i, float j, float size = 16f, float thickness = 1)
            {
                ushort stoneID = (ushort)ModContent.TileType <Defiled_Stone>();

                for (int x = (int)Math.Floor(i - size); x < (int)Math.Ceiling(i + size); x++)
                {
                    for (int y = (int)Math.Ceiling(j + size); y >= (int)Math.Floor(j - size); y--)
                    {
                        if (Main.tile[x, y].active() && Main.tileSolid[Main.tile[x, y].type])
                        {
                            continue;
                        }
                        float diff = (float)Math.Sqrt((((y - j) * (y - j)) + (x - i) * (x - i)) * (GenRunners.GetWallDistOffset((float)Math.Atan2(y - j, x - i) * 4 + x + y) * 0.0316076058772687986171132238548f + 1));
                        if (diff > size + thickness || diff < size - thickness)
                        {
                            continue;
                        }
                        Main.tile[x, y].ResetToType(stoneID);
                    }
                }
            }
Beispiel #3
0
            public static (Vector2 position, Vector2 velocity) DefiledVeinRunner(int i, int j, double strength, Vector2 speed, double length, ushort wallBlockType, float wallThickness, float twist = 0, bool randomtwist = false, int wallType = -1)
            {
                Vector2 pos = new Vector2(i, j);
                Tile    tile;

                if (randomtwist)
                {
                    twist = Math.Abs(twist);
                }
                int    X0           = int.MaxValue;
                int    X1           = 0;
                int    Y0           = int.MaxValue;
                int    Y1           = 0;
                double baseStrength = strength;

                strength = Math.Pow(strength, 2);
                float basewallThickness = wallThickness;

                wallThickness *= wallThickness;
                double  decay     = speed.Length();
                Vector2 direction = speed / (float)decay;
                bool    hasWall   = wallType != -1;
                ushort  _wallType = hasWall ? (ushort)wallType : (ushort)0;

                while (length > 0)
                {
                    length -= decay;
                    int minX = (int)(pos.X - (strength + wallThickness) * 0.5);
                    int maxX = (int)(pos.X + (strength + wallThickness) * 0.5);
                    int minY = (int)(pos.Y - (strength + wallThickness) * 0.5);
                    int maxY = (int)(pos.Y + (strength + wallThickness) * 0.5);
                    if (minX < 1)
                    {
                        minX = 1;
                    }
                    if (maxX > Main.maxTilesX - 1)
                    {
                        maxX = Main.maxTilesX - 1;
                    }
                    if (minY < 1)
                    {
                        minY = 1;
                    }
                    if (maxY > Main.maxTilesY - 1)
                    {
                        maxY = Main.maxTilesY - 1;
                    }
                    for (int l = minX; l < maxX; l++)
                    {
                        for (int k = minY; k < maxY; k++)
                        {
                            float  el   = l + (GenRunners.GetWallDistOffset((float)length + k) + 0.5f) / 2.5f;
                            float  ek   = k + (GenRunners.GetWallDistOffset((float)length + l) + 0.5f) / 2.5f;
                            double dist = Math.Pow(Math.Abs(el - pos.X), 2) + Math.Pow(Math.Abs(ek - pos.Y), 2);
                            tile = Main.tile[l, k];
                            bool openAir = (k < Main.worldSurface && tile.wall == WallID.None);
                            if (dist > strength)
                            {
                                double d = Math.Sqrt(dist);
                                if (!openAir && d < baseStrength + basewallThickness && TileID.Sets.CanBeClearedDuringGeneration[tile.type] && tile.wall != _wallType)
                                {
                                    if (!Main.tileContainer[tile.type])
                                    {
                                        tile.active(active: true);
                                        tile.ResetToType(wallBlockType);
                                    }
                                    //WorldGen.SquareTileFrame(l, k);
                                    if (hasWall)
                                    {
                                        tile.wall = _wallType;
                                    }
                                }
                                continue;
                            }
                            if (TileID.Sets.CanBeClearedDuringGeneration[tile.type])
                            {
                                if (!Main.tileContainer[tile.type] && !Main.tileContainer[Main.tile[l, k - 1].type])
                                {
                                    Main.tile[l, k].active(active: false);
                                }
                                //WorldGen.SquareTileFrame(l, k);
                                if (hasWall && !openAir)
                                {
                                    tile.wall = _wallType;
                                }
                                if (l > X1)
                                {
                                    X1 = l;
                                }
                                else if (l < X0)
                                {
                                    X0 = l;
                                }
                                if (k > Y1)
                                {
                                    Y1 = k;
                                }
                                else if (k < Y0)
                                {
                                    Y0 = k;
                                }
                            }
                        }
                    }
                    pos += speed;
                    if (randomtwist || twist != 0.0)
                    {
                        speed = randomtwist ? speed.RotatedBy(genRand.NextFloat(-twist, twist)) : speed.RotatedBy(twist);
                    }
                }
                if (X0 < 1)
                {
                    X0 = 1;
                }
                if (Y0 > Main.maxTilesX - 1)
                {
                    Y0 = Main.maxTilesX - 1;
                }
                if (X1 < 1)
                {
                    X1 = 1;
                }
                if (Y1 > Main.maxTilesY - 1)
                {
                    Y1 = Main.maxTilesY - 1;
                }
                RangeFrame(X0, Y0, X1, Y1);
                NetMessage.SendTileRange(Main.myPlayer, X0, Y0, X1 - X0, Y1 - Y1);
                return(pos, speed);
            }
Beispiel #4
0
            public static void DefiledRibs(float i, float j, float sizeMult = 1f)
            {
                ushort stoneID = (ushort)ModContent.TileType <Defiled_Stone>();

                for (int x = (int)Math.Floor(i - (28 * sizeMult + 5)); x < (int)Math.Ceiling(i + (28 * sizeMult + 5)); x++)
                {
                    for (int y = (int)Math.Ceiling(j + (28 * sizeMult + 4)); y >= (int)Math.Floor(j - (28 * sizeMult + 4)); y--)
                    {
                        float diff = (float)Math.Sqrt((((y - j) * (y - j)) + (x - i) * (x - i)) * (GenRunners.GetWallDistOffset((float)Math.Atan2(y - j, x - i) * 4 + x + y) * 0.0316076058772687986171132238548f + 1));
                        if (diff > 16 * sizeMult)
                        {
                            continue;
                        }
                        if (Math.Cos(diff * 0.7f) <= 0.1f)
                        {
                            Main.tile[x, y].ResetToType(stoneID);
                        }
                        else
                        {
                            Main.tile[x, y].active(false);
                        }
                    }
                }
            }