Пример #1
0
        public static int TryPlacingPortal(Projectile theBolt, Vector2 velocity, Vector2 theCrashVelocity)
        {
            // ISSUE: explicit reference operation
            Vector2 vector2_1       = Vector2.op_Division(velocity, ((Vector2)@velocity).Length());
            Point   tileCoordinates = PortalHelper.FindCollision(theBolt.position, Vector2.op_Addition(Vector2.op_Addition(theBolt.position, velocity), Vector2.op_Multiply(vector2_1, 32f))).ToTileCoordinates();
            Tile    tile            = Main.tile[(int)tileCoordinates.X, (int)tileCoordinates.Y];
            Vector2 vector2_2       = new Vector2((float)(tileCoordinates.X * 16 + 8), (float)(tileCoordinates.Y * 16 + 8));

            if (!WorldGen.SolidOrSlopedTile(tile))
            {
                return(-1);
            }
            int  num  = (int)tile.slope();
            bool flag = tile.halfBrick();

            for (int index = 0; index < (flag ? 2 : PortalHelper.EDGES.Length); ++index)
            {
                Point bestPosition;
                if ((double)Vector2.Dot(PortalHelper.EDGES[index], vector2_1) > 0.0 && PortalHelper.FindValidLine(tileCoordinates, (int)PortalHelper.EDGES[index].Y, (int)-PortalHelper.EDGES[index].X, out bestPosition))
                {
                    return(PortalHelper.AddPortal(Vector2.op_Subtraction(new Vector2((float)(bestPosition.X * 16 + 8), (float)(bestPosition.Y * 16 + 8)), Vector2.op_Multiply(PortalHelper.EDGES[index], flag ? 0.0f : 8f)), (float)Math.Atan2((double)PortalHelper.EDGES[index].Y, (double)PortalHelper.EDGES[index].X) + 1.570796f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            if (num != 0)
            {
                Vector2 vector2_3 = PortalHelper.SLOPE_EDGES[num - 1];
                Point   bestPosition;
                if ((double)Vector2.Dot(vector2_3, Vector2.op_UnaryNegation(vector2_1)) > 0.0 && PortalHelper.FindValidLine(tileCoordinates, (int)-PortalHelper.SLOPE_OFFSETS[num - 1].Y, (int)PortalHelper.SLOPE_OFFSETS[num - 1].X, out bestPosition))
                {
                    return(PortalHelper.AddPortal(new Vector2((float)(bestPosition.X * 16 + 8), (float)(bestPosition.Y * 16 + 8)), (float)Math.Atan2((double)vector2_3.Y, (double)vector2_3.X) - 1.570796f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            return(-1);
        }
Пример #2
0
        public static int TryPlacingPortal(Projectile theBolt, Vector2 velocity, Vector2 theCrashVelocity)
        {
            Vector2 vector2_1       = velocity / velocity.Length();
            Point   tileCoordinates = PortalHelper.FindCollision(theBolt.position, theBolt.position + velocity + vector2_1 * 32f).ToTileCoordinates();
            Tile    tile            = Main.tile[tileCoordinates.X, tileCoordinates.Y];
            Vector2 position        = new Vector2((float)(tileCoordinates.X * 16 + 8), (float)(tileCoordinates.Y * 16 + 8));

            if (!WorldGen.SolidOrSlopedTile(tile))
            {
                return(-1);
            }
            int  num  = (int)tile.slope();
            bool flag = tile.halfBrick();

            for (int index = 0; index < (flag ? 2 : PortalHelper.EDGES.Length); ++index)
            {
                Point bestPosition;
                if ((double)Vector2.Dot(PortalHelper.EDGES[index], vector2_1) > 0.0 && PortalHelper.FindValidLine(tileCoordinates, (int)PortalHelper.EDGES[index].Y, (int)-(double)PortalHelper.EDGES[index].X, out bestPosition))
                {
                    position = new Vector2((float)(bestPosition.X * 16 + 8), (float)(bestPosition.Y * 16 + 8));
                    return(PortalHelper.AddPortal(position - PortalHelper.EDGES[index] * (flag ? 0.0f : 8f), (float)Math.Atan2((double)PortalHelper.EDGES[index].Y, (double)PortalHelper.EDGES[index].X) + 1.570796f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            if (num != 0)
            {
                Vector2 vector2_2 = PortalHelper.SLOPE_EDGES[num - 1];
                Point   bestPosition;
                if ((double)Vector2.Dot(vector2_2, -vector2_1) > 0.0 && PortalHelper.FindValidLine(tileCoordinates, -PortalHelper.SLOPE_OFFSETS[num - 1].Y, PortalHelper.SLOPE_OFFSETS[num - 1].X, out bestPosition))
                {
                    position = new Vector2((float)(bestPosition.X * 16 + 8), (float)(bestPosition.Y * 16 + 8));
                    return(PortalHelper.AddPortal(position, (float)Math.Atan2((double)vector2_2.Y, (double)vector2_2.X) - 1.570796f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            return(-1);
        }
Пример #3
0
        private static bool FindValidLine(Point position, int xOffset, int yOffset, out Point bestPosition)
        {
            bestPosition = position;
            if (PortalHelper.IsValidLine(position, xOffset, yOffset))
            {
                return(true);
            }
            Point position1;

            // ISSUE: explicit reference operation
            ((Point)@position1).\u002Ector(position.X - xOffset, position.Y - yOffset);
            if (PortalHelper.IsValidLine(position1, xOffset, yOffset))
            {
                bestPosition = position1;
                return(true);
            }
            Point position2;

            // ISSUE: explicit reference operation
            ((Point)@position2).\u002Ector(position.X + xOffset, position.Y + yOffset);
            if (!PortalHelper.IsValidLine(position2, xOffset, yOffset))
            {
                return(false);
            }
            bestPosition = position2;
            return(true);
        }
Пример #4
0
        private static bool FindValidLine(
            Point position,
            int xOffset,
            int yOffset,
            out Point bestPosition)
        {
            bestPosition = position;
            if (PortalHelper.IsValidLine(position, xOffset, yOffset))
            {
                return(true);
            }
            Point position1 = new Point(position.X - xOffset, position.Y - yOffset);

            if (PortalHelper.IsValidLine(position1, xOffset, yOffset))
            {
                bestPosition = position1;
                return(true);
            }
            Point position2 = new Point(position.X + xOffset, position.Y + yOffset);

            if (!PortalHelper.IsValidLine(position2, xOffset, yOffset))
            {
                return(false);
            }
            bestPosition = position2;
            return(true);
        }
Пример #5
0
        private static void RemoveIntersectingPortals(Vector2 position, float angle)
        {
            Vector2 start1;
            Vector2 end1;

            PortalHelper.GetPortalEdges(position, angle, out start1, out end1);
            for (int number = 0; number < 1000; ++number)
            {
                Projectile projectile = Main.projectile[number];
                if (projectile.active && projectile.type == 602)
                {
                    Vector2 start2;
                    Vector2 end2;
                    PortalHelper.GetPortalEdges(projectile.Center, projectile.ai[0], out start2, out end2);
                    if (Collision.CheckLinevLine(start1, end1, start2, end2).Length > 0)
                    {
                        if (projectile.owner != Main.myPlayer && Main.netMode != 2)
                        {
                            NetMessage.SendData(95, -1, -1, (NetworkText)null, number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                        }
                        projectile.Kill();
                        if (Main.netMode == 2)
                        {
                            NetMessage.SendData(29, -1, -1, (NetworkText)null, projectile.whoAmI, (float)projectile.owner, 0.0f, 0.0f, 0, 0, 0);
                        }
                    }
                }
            }
        }
Пример #6
0
        // Token: 0x06000F27 RID: 3879 RVA: 0x003F1BE0 File Offset: 0x003EFDE0
        private static void RemoveIntersectingPortals(Vector2 position, float angle)
        {
            Vector2 a;
            Vector2 a2;

            PortalHelper.GetPortalEdges(position, angle, out a, out a2);
            for (int i = 0; i < 1000; i++)
            {
                Projectile projectile = Main.projectile[i];
                if (projectile.active && projectile.type == 602)
                {
                    Vector2 b;
                    Vector2 b2;
                    PortalHelper.GetPortalEdges(projectile.Center, projectile.ai[0], out b, out b2);
                    if (Collision.CheckLinevLine(a, a2, b, b2).Length != 0)
                    {
                        if (projectile.owner != Main.myPlayer && Main.netMode != 2)
                        {
                            NetMessage.SendData(95, -1, -1, null, i, 0f, 0f, 0f, 0, 0, 0);
                        }
                        projectile.Kill();
                        if (Main.netMode == 2)
                        {
                            NetMessage.SendData(29, -1, -1, null, projectile.whoAmI, (float)projectile.owner, 0f, 0f, 0, 0, 0);
                        }
                    }
                }
            }
        }
Пример #7
0
        // Token: 0x06000F20 RID: 3872 RVA: 0x003F16D4 File Offset: 0x003EF8D4
        public static int TryPlacingPortal(Projectile theBolt, Vector2 velocity, Vector2 theCrashVelocity)
        {
            Vector2 vector = velocity / velocity.Length();
            Point   point  = PortalHelper.FindCollision(theBolt.position, theBolt.position + velocity + vector * 32f).ToTileCoordinates();
            Tile    tile   = Main.tile[point.X, point.Y];

            new Vector2((float)(point.X * 16 + 8), (float)(point.Y * 16 + 8));
            if (!WorldGen.SolidOrSlopedTile(tile))
            {
                return(-1);
            }
            int  num  = (int)tile.slope();
            bool flag = tile.halfBrick();

            for (int i = 0; i < (flag ? 2 : PortalHelper.EDGES.Length); i++)
            {
                Point point2;
                if (Vector2.Dot(PortalHelper.EDGES[i], vector) > 0f && PortalHelper.FindValidLine(point, (int)PortalHelper.EDGES[i].Y, (int)(-(int)PortalHelper.EDGES[i].X), out point2))
                {
                    return(PortalHelper.AddPortal(new Vector2((float)(point2.X * 16 + 8), (float)(point2.Y * 16 + 8)) - PortalHelper.EDGES[i] * (flag ? 0f : 8f), (float)Math.Atan2((double)PortalHelper.EDGES[i].Y, (double)PortalHelper.EDGES[i].X) + 1.57079637f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            if (num != 0)
            {
                Vector2 vector2 = PortalHelper.SLOPE_EDGES[num - 1];
                Point   point3;
                if (Vector2.Dot(vector2, -vector) > 0f && PortalHelper.FindValidLine(point, -PortalHelper.SLOPE_OFFSETS[num - 1].Y, PortalHelper.SLOPE_OFFSETS[num - 1].X, out point3))
                {
                    return(PortalHelper.AddPortal(new Vector2((float)(point3.X * 16 + 8), (float)(point3.Y * 16 + 8)), (float)Math.Atan2((double)vector2.Y, (double)vector2.X) - 1.57079637f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            return(-1);
        }
Пример #8
0
 private static bool IsValidLine(Point position, int xOffset, int yOffset)
 {
     Tile tile1 = Main.tile[position.X, position.Y];
       Tile tile2 = Main.tile[position.X - xOffset, position.Y - yOffset];
       Tile tile3 = Main.tile[position.X + xOffset, position.Y + yOffset];
       return !PortalHelper.BlockPortals(Main.tile[position.X + yOffset, position.Y - xOffset]) && !PortalHelper.BlockPortals(Main.tile[position.X + yOffset - xOffset, position.Y - xOffset - yOffset]) && (!PortalHelper.BlockPortals(Main.tile[position.X + yOffset + xOffset, position.Y - xOffset + yOffset]) && WorldGen.SolidOrSlopedTile(tile1)) && (WorldGen.SolidOrSlopedTile(tile2) && WorldGen.SolidOrSlopedTile(tile3) && (tile2.HasSameSlope(tile1) && tile3.HasSameSlope(tile1)));
 }
Пример #9
0
        private static void RemoveIntersectingPortals(Vector2 position, float angle)
        {
            Vector2 vector2;
            Vector2 vector21;
            Vector2 vector22;
            Vector2 vector23;

            PortalHelper.GetPortalEdges(position, angle, out vector2, out vector21);
            for (int i = 0; i < 1000; i++)
            {
                Projectile projectile = Main.projectile[i];
                if (projectile.active && projectile.type == 602)
                {
                    PortalHelper.GetPortalEdges(projectile.Center, projectile.ai[0], out vector22, out vector23);
                    if ((int)Collision.CheckLinevLine(vector2, vector21, vector22, vector23).Length > 0)
                    {
                        if (projectile.owner != Main.myPlayer)
                        {
                            NetMessage.SendData(95, -1, -1, "", i, 0f, 0f, 0f, 0, 0, 0);
                        }
                        projectile.Kill();
                    }
                }
            }
        }
Пример #10
0
        private static bool IsValidLine(Point position, int xOffset, int yOffset)
        {
            Tile tile = Main.tile[position.X, position.Y];
            Tile t1   = Main.tile[position.X - xOffset, position.Y - yOffset];
            Tile t2   = Main.tile[position.X + xOffset, position.Y + yOffset];

            return(!PortalHelper.BlockPortals(Main.tile[position.X + yOffset, position.Y - xOffset]) && !PortalHelper.BlockPortals(Main.tile[position.X + yOffset - xOffset, position.Y - xOffset - yOffset]) && (!PortalHelper.BlockPortals(Main.tile[position.X + yOffset + xOffset, position.Y - xOffset + yOffset]) && PortalHelper.CanPlacePortalOn(tile)) && (PortalHelper.CanPlacePortalOn(t1) && PortalHelper.CanPlacePortalOn(t2) && (t1.HasSameSlope(tile) && t2.HasSameSlope(tile))));
        }
Пример #11
0
 private static int AddPortal(Vector2 position, float angle, int form, int direction)
 {
     if (!PortalHelper.SupportedTilesAreFine(position, angle))
     return -1;
       PortalHelper.RemoveMyOldPortal(form);
       PortalHelper.RemoveIntersectingPortals(position, angle);
       int index = Projectile.NewProjectile(position.X, position.Y, 0.0f, 0.0f, 602, 0, 0.0f, Main.myPlayer, angle, (float) form);
       Main.projectile[index].direction = direction;
       Main.projectile[index].netUpdate = true;
       return index;
 }
Пример #12
0
        private static bool IsValidLine(Point position, int xOffset, int yOffset)
        {
            Tile tile  = Main.tile[position.X, position.Y];
            Tile tile1 = Main.tile[position.X - xOffset, position.Y - yOffset];
            Tile tile2 = Main.tile[position.X + xOffset, position.Y + yOffset];

            if (PortalHelper.BlockPortals(Main.tile[position.X + yOffset, position.Y - xOffset]) || PortalHelper.BlockPortals(Main.tile[position.X + yOffset - xOffset, position.Y - xOffset - yOffset]) || PortalHelper.BlockPortals(Main.tile[position.X + yOffset + xOffset, position.Y - xOffset + yOffset]))
            {
                return(false);
            }
            if (WorldGen.SolidOrSlopedTile(tile) && WorldGen.SolidOrSlopedTile(tile1) && WorldGen.SolidOrSlopedTile(tile2) && tile1.HasSameSlope(tile) && tile2.HasSameSlope(tile))
            {
                return(true);
            }
            return(false);
        }
Пример #13
0
        public static int TryPlacingPortal(Projectile theBolt, Vector2 velocity, Vector2 theCrashVelocity)
        {
            Point   point;
            Point   point1;
            Vector2 vector2         = velocity / velocity.Length();
            Vector2 vector21        = PortalHelper.FindCollision(theBolt.position, (theBolt.position + velocity) + (vector2 * 32f));
            Point   tileCoordinates = vector21.ToTileCoordinates();
            Tile    tile            = Main.tile[tileCoordinates.X, tileCoordinates.Y];
            Vector2 vector22        = new Vector2((float)(tileCoordinates.X * 16 + 8), (float)(tileCoordinates.Y * 16 + 8));

            if (!WorldGen.SolidOrSlopedTile(tile))
            {
                return(-1);
            }
            int  num  = tile.slope();
            bool flag = tile.halfBrick();
            int  num1 = 0;

            while (true)
            {
                if (num1 >= (flag ? 2 : (int)PortalHelper.EDGES.Length))
                {
                    break;
                }
                if (Vector2.Dot(PortalHelper.EDGES[num1], vector2) > 0f && PortalHelper.FindValidLine(tileCoordinates, (int)PortalHelper.EDGES[num1].Y, (int)(-PortalHelper.EDGES[num1].X), out point))
                {
                    vector22 = new Vector2((float)(point.X * 16 + 8), (float)(point.Y * 16 + 8));
                    return(PortalHelper.AddPortal(vector22 - (PortalHelper.EDGES[num1] * (flag ? 0f : 8f)), (float)Math.Atan2((double)PortalHelper.EDGES[num1].Y, (double)PortalHelper.EDGES[num1].X) + 1.57079637f, (int)theBolt.ai[0], theBolt.direction));
                }
                num1++;
            }
            if (num != 0)
            {
                Vector2 sLOPEEDGES = PortalHelper.SLOPE_EDGES[num - 1];
                if (Vector2.Dot(sLOPEEDGES, -vector2) > 0f && PortalHelper.FindValidLine(tileCoordinates, -PortalHelper.SLOPE_OFFSETS[num - 1].Y, PortalHelper.SLOPE_OFFSETS[num - 1].X, out point1))
                {
                    vector22 = new Vector2((float)(point1.X * 16 + 8), (float)(point1.Y * 16 + 8));
                    return(PortalHelper.AddPortal(vector22, (float)Math.Atan2((double)sLOPEEDGES.Y, (double)sLOPEEDGES.X) - 1.57079637f, (int)theBolt.ai[0], theBolt.direction));
                }
            }
            return(-1);
        }
Пример #14
0
        public static void TryGoingThroughPortals(Entity ent)
        {
            float   collisionPoint = 0.0f;
            Vector2 velocity       = ent.velocity;
            int     width          = ent.width;
            int     height         = ent.height;
            int     gravDir        = 1;

            if (ent is Player)
            {
                gravDir = (int)((Player)ent).gravDir;
            }
            for (int index1 = 0; index1 < PortalHelper.FoundPortals.GetLength(0); ++index1)
            {
                if (PortalHelper.FoundPortals[index1, 0] != -1 && PortalHelper.FoundPortals[index1, 1] != -1 && (!(ent is Player) || index1 < PortalHelper.PortalCooldownForPlayers.Length && PortalHelper.PortalCooldownForPlayers[index1] <= 0) && (!(ent is NPC) || index1 < PortalHelper.PortalCooldownForNPCs.Length && PortalHelper.PortalCooldownForNPCs[index1] <= 0))
                {
                    for (int index2 = 0; index2 < 2; ++index2)
                    {
                        Projectile projectile1 = Main.projectile[PortalHelper.FoundPortals[index1, index2]];
                        Vector2    start;
                        Vector2    end;
                        PortalHelper.GetPortalEdges(projectile1.Center, projectile1.ai[0], out start, out end);
                        if (Collision.CheckAABBvLineCollision(ent.position + ent.velocity, ent.Size, start, end, 2f, ref collisionPoint))
                        {
                            Projectile projectile2 = Main.projectile[PortalHelper.FoundPortals[index1, 1 - index2]];
                            float      num1        = ent.Hitbox.Distance(projectile1.Center);
                            int        bonusX;
                            int        bonusY;
                            Vector2    newPos    = PortalHelper.GetPortalOutingPoint(ent.Size, projectile2.Center, projectile2.ai[0], out bonusX, out bonusY) + Vector2.Normalize(new Vector2((float)bonusX, (float)bonusY)) * num1;
                            Vector2    Velocity1 = Vector2.UnitX * 16f;
                            if (!(Collision.TileCollision(newPos - Velocity1, Velocity1, width, height, true, true, gravDir) != Velocity1))
                            {
                                Vector2 Velocity2 = -Vector2.UnitX * 16f;
                                if (!(Collision.TileCollision(newPos - Velocity2, Velocity2, width, height, true, true, gravDir) != Velocity2))
                                {
                                    Vector2 Velocity3 = Vector2.UnitY * 16f;
                                    if (!(Collision.TileCollision(newPos - Velocity3, Velocity3, width, height, true, true, gravDir) != Velocity3))
                                    {
                                        Vector2 Velocity4 = -Vector2.UnitY * 16f;
                                        if (!(Collision.TileCollision(newPos - Velocity4, Velocity4, width, height, true, true, gravDir) != Velocity4))
                                        {
                                            float num2 = 0.1f;
                                            if (bonusY == -gravDir)
                                            {
                                                num2 = 0.1f;
                                            }
                                            if (ent.velocity == Vector2.Zero)
                                            {
                                                ent.velocity = (projectile1.ai[0] - 1.570796f).ToRotationVector2() * num2;
                                            }
                                            if ((double)ent.velocity.Length() < (double)num2)
                                            {
                                                ent.velocity.Normalize();
                                                ent.velocity *= num2;
                                            }
                                            Vector2 vec = Vector2.Normalize(new Vector2((float)bonusX, (float)bonusY));
                                            if (vec.HasNaNs() || vec == Vector2.Zero)
                                            {
                                                vec = Vector2.UnitX * (float)ent.direction;
                                            }
                                            ent.velocity = vec * ent.velocity.Length();
                                            if (bonusY == -gravDir && Math.Sign(ent.velocity.Y) != -gravDir || (double)Math.Abs(ent.velocity.Y) < 0.100000001490116)
                                            {
                                                ent.velocity.Y = (float)-gravDir * 0.1f;
                                            }
                                            int extraInfo = (int)((double)(projectile2.owner * 2) + (double)projectile2.ai[1]);
                                            int num3      = extraInfo + (extraInfo % 2 == 0 ? 1 : -1);
                                            if (ent is Player)
                                            {
                                                Player player = (Player)ent;
                                                player.lastPortalColorIndex = num3;
                                                player.Teleport(newPos, 4, extraInfo);
                                                if (Main.netMode == 1)
                                                {
                                                    NetMessage.SendData(96, -1, -1, (NetworkText)null, player.whoAmI, newPos.X, newPos.Y, (float)extraInfo, 0, 0, 0);
                                                    NetMessage.SendData(13, -1, -1, (NetworkText)null, player.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                                                }
                                                PortalHelper.PortalCooldownForPlayers[index1] = 10;
                                                return;
                                            }
                                            if (!(ent is NPC))
                                            {
                                                return;
                                            }
                                            NPC npc = (NPC)ent;
                                            npc.lastPortalColorIndex = num3;
                                            npc.Teleport(newPos, 4, extraInfo);
                                            if (Main.netMode == 1)
                                            {
                                                NetMessage.SendData(100, -1, -1, (NetworkText)null, npc.whoAmI, newPos.X, newPos.Y, (float)extraInfo, 0, 0, 0);
                                                NetMessage.SendData(23, -1, -1, (NetworkText)null, npc.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                                            }
                                            PortalHelper.PortalCooldownForPlayers[index1] = 10;
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #15
0
        public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle)
        {
            Point tileCoordinates = portalCenter.ToTileCoordinates();
            int   num1            = (int)Math.Round((double)MathHelper.WrapAngle(portalAngle) / 0.785398185253143);
            int   num2;
            int   num3;

            switch (num1)
            {
            case 2:
            case -2:
                num2 = num1 == 2 ? -1 : 1;
                num3 = 0;
                break;

            case 0:
            case 4:
                num2 = 0;
                num3 = num1 == 0 ? 1 : -1;
                break;

            case -3:
            case 3:
                num2 = num1 == -3 ? 1 : -1;
                num3 = -1;
                break;

            case 1:
            case -1:
                num2 = num1 == -1 ? 1 : -1;
                num3 = 1;
                break;

            default:
                Main.NewText("Broken portal! (over4s = " + (object)num1 + " , " + (object)portalAngle + ")", byte.MaxValue, byte.MaxValue, byte.MaxValue, false);
                return(false);
            }
            if (num2 != 0 && num3 != 0)
            {
                int num4 = 3;
                if (num2 == -1 && num3 == 1)
                {
                    num4 = 5;
                }
                if (num2 == 1 && num3 == -1)
                {
                    num4 = 2;
                }
                if (num2 == 1 && num3 == 1)
                {
                    num4 = 4;
                }
                int slope = num4 - 1;
                if (PortalHelper.SupportedSlope(tileCoordinates.X, tileCoordinates.Y, slope) && PortalHelper.SupportedSlope(tileCoordinates.X + num2, tileCoordinates.Y - num3, slope))
                {
                    return(PortalHelper.SupportedSlope(tileCoordinates.X - num2, tileCoordinates.Y + num3, slope));
                }
                return(false);
            }
            if (num2 != 0)
            {
                if (num2 == 1)
                {
                    --tileCoordinates.X;
                }
                if (PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y - 1))
                {
                    return(PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y + 1));
                }
                return(false);
            }
            if (num3 == 0)
            {
                return(true);
            }
            if (num3 == 1)
            {
                --tileCoordinates.Y;
            }
            if (PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X + 1, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X - 1, tileCoordinates.Y))
            {
                return(true);
            }
            if (PortalHelper.SupportedHalfbrick(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedHalfbrick(tileCoordinates.X + 1, tileCoordinates.Y))
            {
                return(PortalHelper.SupportedHalfbrick(tileCoordinates.X - 1, tileCoordinates.Y));
            }
            return(false);
        }
Пример #16
0
 public static Color GetPortalColor(int colorIndex)
 {
     return(PortalHelper.GetPortalColor(colorIndex / 2, colorIndex % 2));
 }
Пример #17
0
        // Token: 0x06000F2E RID: 3886 RVA: 0x003F205C File Offset: 0x003F025C
        public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle)
        {
            Point point = portalCenter.ToTileCoordinates();
            int   num   = (int)Math.Round((double)(MathHelper.WrapAngle(portalAngle) / 0.7853982f));
            int   num2;
            int   num3;

            if (num == 2 || num == -2)
            {
                num2 = ((num == 2) ? -1 : 1);
                num3 = 0;
            }
            else if (num == 0 || num == 4)
            {
                num2 = 0;
                num3 = ((num == 0) ? 1 : -1);
            }
            else if (num == -3 || num == 3)
            {
                num2 = ((num == -3) ? 1 : -1);
                num3 = -1;
            }
            else
            {
                if (num != 1 && num != -1)
                {
                    Main.NewText(string.Concat(new object[]
                    {
                        "Broken portal! (over4s = ",
                        num,
                        " , ",
                        portalAngle,
                        ")"
                    }), 255, 255, 255, false);
                    return(false);
                }
                num2 = ((num == -1) ? 1 : -1);
                num3 = 1;
            }
            if (num2 != 0 && num3 != 0)
            {
                int num4 = 3;
                if (num2 == -1 && num3 == 1)
                {
                    num4 = 5;
                }
                if (num2 == 1 && num3 == -1)
                {
                    num4 = 2;
                }
                if (num2 == 1 && num3 == 1)
                {
                    num4 = 4;
                }
                num4--;
                return(PortalHelper.SupportedSlope(point.X, point.Y, num4) && PortalHelper.SupportedSlope(point.X + num2, point.Y - num3, num4) && PortalHelper.SupportedSlope(point.X - num2, point.Y + num3, num4));
            }
            if (num2 != 0)
            {
                if (num2 == 1)
                {
                    point.X--;
                }
                return(PortalHelper.SupportedNormal(point.X, point.Y) && PortalHelper.SupportedNormal(point.X, point.Y - 1) && PortalHelper.SupportedNormal(point.X, point.Y + 1));
            }
            if (num3 != 0)
            {
                if (num3 == 1)
                {
                    point.Y--;
                }
                return((PortalHelper.SupportedNormal(point.X, point.Y) && PortalHelper.SupportedNormal(point.X + 1, point.Y) && PortalHelper.SupportedNormal(point.X - 1, point.Y)) || (PortalHelper.SupportedHalfbrick(point.X, point.Y) && PortalHelper.SupportedHalfbrick(point.X + 1, point.Y) && PortalHelper.SupportedHalfbrick(point.X - 1, point.Y)));
            }
            return(true);
        }
Пример #18
0
        // Token: 0x06000F1F RID: 3871 RVA: 0x003F1218 File Offset: 0x003EF418
        public static void TryGoingThroughPortals(Entity ent)
        {
            float   num      = 0f;
            Vector2 arg_0C_0 = ent.velocity;
            int     width    = ent.width;
            int     height   = ent.height;
            int     num2     = 1;

            if (ent is Player)
            {
                num2 = (int)((Player)ent).gravDir;
            }
            for (int i = 0; i < PortalHelper.FoundPortals.GetLength(0); i++)
            {
                if (PortalHelper.FoundPortals[i, 0] != -1 && PortalHelper.FoundPortals[i, 1] != -1 && (!(ent is Player) || (i < PortalHelper.PortalCooldownForPlayers.Length && PortalHelper.PortalCooldownForPlayers[i] <= 0)) && (!(ent is NPC) || (i < PortalHelper.PortalCooldownForNPCs.Length && PortalHelper.PortalCooldownForNPCs[i] <= 0)))
                {
                    for (int j = 0; j < 2; j++)
                    {
                        Projectile projectile = Main.projectile[PortalHelper.FoundPortals[i, j]];
                        Vector2    lineStart;
                        Vector2    lineEnd;
                        PortalHelper.GetPortalEdges(projectile.Center, projectile.ai[0], out lineStart, out lineEnd);
                        if (Collision.CheckAABBvLineCollision(ent.position + ent.velocity, ent.Size, lineStart, lineEnd, 2f, ref num))
                        {
                            Projectile projectile2 = Main.projectile[PortalHelper.FoundPortals[i, 1 - j]];
                            float      scaleFactor = ent.Hitbox.Distance(projectile.Center);
                            int        num3;
                            int        num4;
                            Vector2    vector  = PortalHelper.GetPortalOutingPoint(ent.Size, projectile2.Center, projectile2.ai[0], out num3, out num4) + Vector2.Normalize(new Vector2((float)num3, (float)num4)) * scaleFactor;
                            Vector2    vector2 = Vector2.UnitX * 16f;
                            if (!(Collision.TileCollision(vector - vector2, vector2, width, height, true, true, num2) != vector2))
                            {
                                vector2 = -Vector2.UnitX * 16f;
                                if (!(Collision.TileCollision(vector - vector2, vector2, width, height, true, true, num2) != vector2))
                                {
                                    vector2 = Vector2.UnitY * 16f;
                                    if (!(Collision.TileCollision(vector - vector2, vector2, width, height, true, true, num2) != vector2))
                                    {
                                        vector2 = -Vector2.UnitY * 16f;
                                        if (!(Collision.TileCollision(vector - vector2, vector2, width, height, true, true, num2) != vector2))
                                        {
                                            float num5 = 0.1f;
                                            if (num4 == -num2)
                                            {
                                                num5 = 0.1f;
                                            }
                                            if (ent.velocity == Vector2.Zero)
                                            {
                                                ent.velocity = (projectile.ai[0] - 1.57079637f).ToRotationVector2() * num5;
                                            }
                                            if (ent.velocity.Length() < num5)
                                            {
                                                ent.velocity.Normalize();
                                                ent.velocity *= num5;
                                            }
                                            Vector2 vector3 = Vector2.Normalize(new Vector2((float)num3, (float)num4));
                                            if (vector3.HasNaNs() || vector3 == Vector2.Zero)
                                            {
                                                vector3 = Vector2.UnitX * (float)ent.direction;
                                            }
                                            ent.velocity = vector3 * ent.velocity.Length();
                                            if ((num4 == -num2 && Math.Sign(ent.velocity.Y) != -num2) || Math.Abs(ent.velocity.Y) < 0.1f)
                                            {
                                                ent.velocity.Y = (float)(-(float)num2) * 0.1f;
                                            }
                                            int num6 = (int)((float)(projectile2.owner * 2) + projectile2.ai[1]);
                                            int lastPortalColorIndex = num6 + ((num6 % 2 == 0) ? 1 : -1);
                                            if (ent is Player)
                                            {
                                                Player player = (Player)ent;
                                                player.lastPortalColorIndex = lastPortalColorIndex;
                                                player.Teleport(vector, 4, num6);
                                                if (Main.netMode == 1)
                                                {
                                                    NetMessage.SendData(96, -1, -1, null, player.whoAmI, vector.X, vector.Y, (float)num6, 0, 0, 0);
                                                    NetMessage.SendData(13, -1, -1, null, player.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                }
                                                PortalHelper.PortalCooldownForPlayers[i] = 10;
                                                return;
                                            }
                                            if (ent is NPC)
                                            {
                                                NPC nPC = (NPC)ent;
                                                nPC.lastPortalColorIndex = lastPortalColorIndex;
                                                nPC.Teleport(vector, 4, num6);
                                                if (Main.netMode == 1)
                                                {
                                                    NetMessage.SendData(100, -1, -1, null, nPC.whoAmI, vector.X, vector.Y, (float)num6, 0, 0, 0);
                                                    NetMessage.SendData(23, -1, -1, null, nPC.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                }
                                                PortalHelper.PortalCooldownForPlayers[i] = 10;
                                            }
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #19
0
        public static void TryGoingThroughPortals(Entity ent)
        {
            float   collisionPoint = 0.0f;
            Vector2 velocity       = ent.velocity;
            int     width          = ent.width;
            int     height         = ent.height;
            int     gravDir        = 1;

            if (ent is Player)
            {
                gravDir = (int)((Player)ent).gravDir;
            }
            for (int index1 = 0; index1 < PortalHelper.FoundPortals.GetLength(0); ++index1)
            {
                if (PortalHelper.FoundPortals[index1, 0] != -1 && PortalHelper.FoundPortals[index1, 1] != -1 && (!(ent is Player) || index1 < PortalHelper.PortalCooldownForPlayers.Length && PortalHelper.PortalCooldownForPlayers[index1] <= 0) && (!(ent is NPC) || index1 < PortalHelper.PortalCooldownForNPCs.Length && PortalHelper.PortalCooldownForNPCs[index1] <= 0))
                {
                    for (int index2 = 0; index2 < 2; ++index2)
                    {
                        Projectile projectile1 = Main.projectile[PortalHelper.FoundPortals[index1, index2]];
                        Vector2    start;
                        Vector2    end;
                        PortalHelper.GetPortalEdges(projectile1.Center, projectile1.ai[0], out start, out end);
                        if (Collision.CheckAABBvLineCollision(Vector2.op_Addition(ent.position, ent.velocity), ent.Size, start, end, 2f, ref collisionPoint))
                        {
                            Projectile projectile2 = Main.projectile[PortalHelper.FoundPortals[index1, 1 - index2]];
                            float      num1        = ent.Hitbox.Distance(projectile1.Center);
                            int        bonusX;
                            int        bonusY;
                            Vector2    newPos    = Vector2.op_Addition(PortalHelper.GetPortalOutingPoint(ent.Size, projectile2.Center, projectile2.ai[0], out bonusX, out bonusY), Vector2.op_Multiply(Vector2.Normalize(new Vector2((float)bonusX, (float)bonusY)), num1));
                            Vector2    Velocity1 = Vector2.op_Multiply(Vector2.get_UnitX(), 16f);
                            if (!Vector2.op_Inequality(Collision.TileCollision(Vector2.op_Subtraction(newPos, Velocity1), Velocity1, width, height, true, true, gravDir), Velocity1))
                            {
                                Vector2 Velocity2 = Vector2.op_Multiply(Vector2.op_UnaryNegation(Vector2.get_UnitX()), 16f);
                                if (!Vector2.op_Inequality(Collision.TileCollision(Vector2.op_Subtraction(newPos, Velocity2), Velocity2, width, height, true, true, gravDir), Velocity2))
                                {
                                    Vector2 Velocity3 = Vector2.op_Multiply(Vector2.get_UnitY(), 16f);
                                    if (!Vector2.op_Inequality(Collision.TileCollision(Vector2.op_Subtraction(newPos, Velocity3), Velocity3, width, height, true, true, gravDir), Velocity3))
                                    {
                                        Vector2 Velocity4 = Vector2.op_Multiply(Vector2.op_UnaryNegation(Vector2.get_UnitY()), 16f);
                                        if (!Vector2.op_Inequality(Collision.TileCollision(Vector2.op_Subtraction(newPos, Velocity4), Velocity4, width, height, true, true, gravDir), Velocity4))
                                        {
                                            float num2 = 0.1f;
                                            if (bonusY == -gravDir)
                                            {
                                                num2 = 0.1f;
                                            }
                                            if (Vector2.op_Equality(ent.velocity, Vector2.get_Zero()))
                                            {
                                                ent.velocity = Vector2.op_Multiply((projectile1.ai[0] - 1.570796f).ToRotationVector2(), num2);
                                            }
                                            // ISSUE: explicit reference operation
                                            if ((double)((Vector2)@ent.velocity).Length() < (double)num2)
                                            {
                                                // ISSUE: explicit reference operation
                                                ((Vector2)@ent.velocity).Normalize();
                                                Entity  entity  = ent;
                                                Vector2 vector2 = Vector2.op_Multiply(entity.velocity, num2);
                                                entity.velocity = vector2;
                                            }
                                            Vector2 vec = Vector2.Normalize(new Vector2((float)bonusX, (float)bonusY));
                                            if (vec.HasNaNs() || Vector2.op_Equality(vec, Vector2.get_Zero()))
                                            {
                                                vec = Vector2.op_Multiply(Vector2.get_UnitX(), (float)ent.direction);
                                            }
                                            // ISSUE: explicit reference operation
                                            ent.velocity = Vector2.op_Multiply(vec, ((Vector2)@ent.velocity).Length());
                                            if (bonusY == -gravDir && Math.Sign((float)ent.velocity.Y) != -gravDir || (double)Math.Abs((float)ent.velocity.Y) < 0.100000001490116)
                                            {
                                                ent.velocity.Y = (__Null)((double)-gravDir * 0.100000001490116);
                                            }
                                            int extraInfo = (int)((double)(projectile2.owner * 2) + (double)projectile2.ai[1]);
                                            int num3      = extraInfo + (extraInfo % 2 == 0 ? 1 : -1);
                                            if (ent is Player)
                                            {
                                                Player player = (Player)ent;
                                                player.lastPortalColorIndex = num3;
                                                player.Teleport(newPos, 4, extraInfo);
                                                if (Main.netMode == 1)
                                                {
                                                    NetMessage.SendData(96, -1, -1, (NetworkText)null, player.whoAmI, (float)newPos.X, (float)newPos.Y, (float)extraInfo, 0, 0, 0);
                                                    NetMessage.SendData(13, -1, -1, (NetworkText)null, player.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                                                }
                                                PortalHelper.PortalCooldownForPlayers[index1] = 10;
                                                return;
                                            }
                                            if (!(ent is NPC))
                                            {
                                                return;
                                            }
                                            NPC npc = (NPC)ent;
                                            npc.lastPortalColorIndex = num3;
                                            npc.Teleport(newPos, 4, extraInfo);
                                            if (Main.netMode == 1)
                                            {
                                                NetMessage.SendData(100, -1, -1, (NetworkText)null, npc.whoAmI, (float)newPos.X, (float)newPos.Y, (float)extraInfo, 0, 0, 0);
                                                NetMessage.SendData(23, -1, -1, (NetworkText)null, npc.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                                            }
                                            PortalHelper.PortalCooldownForPlayers[index1] = 10;
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #20
0
        public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle)
        {
            Point tileCoordinates = portalCenter.ToTileCoordinates();
            int   num1            = (int)Math.Round((double)MathHelper.WrapAngle(portalAngle) / 0.785398185253143);
            int   num2;
            int   num3;

            switch (num1)
            {
            case 2:
            case -2:
                num2 = num1 == 2 ? -1 : 1;
                num3 = 0;
                break;

            case 0:
            case 4:
                num2 = 0;
                num3 = num1 == 0 ? 1 : -1;
                break;

            case -3:
            case 3:
                num2 = num1 == -3 ? 1 : -1;
                num3 = -1;
                break;

            case 1:
            case -1:
                num2 = num1 == -1 ? 1 : -1;
                num3 = 1;
                break;

            default:
                Main.NewText("Broken portal! (over4s = " + (object)num1 + " , " + (object)portalAngle + ")", byte.MaxValue, byte.MaxValue, byte.MaxValue, false);
                return(false);
            }
            if (num2 != 0 && num3 != 0)
            {
                int num4 = 3;
                if (num2 == -1 && num3 == 1)
                {
                    num4 = 5;
                }
                if (num2 == 1 && num3 == -1)
                {
                    num4 = 2;
                }
                if (num2 == 1 && num3 == 1)
                {
                    num4 = 4;
                }
                int slope = num4 - 1;
                if (PortalHelper.SupportedSlope((int)tileCoordinates.X, (int)tileCoordinates.Y, slope) && PortalHelper.SupportedSlope(tileCoordinates.X + num2, tileCoordinates.Y - num3, slope))
                {
                    return(PortalHelper.SupportedSlope(tileCoordinates.X - num2, tileCoordinates.Y + num3, slope));
                }
                return(false);
            }
            if (num2 != 0)
            {
                if (num2 == 1)
                {
                    // ISSUE: explicit reference operation
                    // ISSUE: variable of a reference type
                    __Null& local = @tileCoordinates.X;
                    // ISSUE: cast to a reference type
                    // ISSUE: explicit reference operation
                    int num4 = ^ (int&)local - 1;
Пример #21
0
 private static bool CanPlacePortalOn(Tile t)
 {
     return(PortalHelper.DoesTileTypeSupportPortals(t.type) && WorldGen.SolidOrSlopedTile(t));
 }
Пример #22
0
        private static bool SupportedSlope(int x, int y, int slope)
        {
            Tile tile = Main.tile[x, y];

            return(tile != null && tile.nactive() && (!Main.tileCut[(int)tile.type] && !TileID.Sets.BreakableWhenPlacing[(int)tile.type]) && (Main.tileSolid[(int)tile.type] && (int)tile.slope() == slope) && PortalHelper.DoesTileTypeSupportPortals(tile.type));
        }
Пример #23
0
        public static void TryGoingThroughPortals(Entity ent)
        {
            Vector2 vector2;
            Vector2 vector21;
            int     num;
            int     num1;
            float   single   = 0f;
            Vector2 vector22 = ent.velocity;
            int     num2     = ent.width;
            int     num3     = ent.height;
            int     num4     = 1;

            if (ent is Player)
            {
                num4 = (int)((Player)ent).gravDir;
            }
            for (int i = 0; i < PortalHelper.FoundPortals.GetLength(0); i++)
            {
                if (PortalHelper.FoundPortals[i, 0] != -1 && PortalHelper.FoundPortals[i, 1] != -1 && (!(ent is Player) || PortalHelper.PortalCooldownForPlayers[i] <= 0) && (!(ent is NPC) || PortalHelper.PortalCooldownForNPCs[i] <= 0))
                {
                    for (int j = 0; j < 2; j++)
                    {
                        Projectile projectile = Main.projectile[PortalHelper.FoundPortals[i, j]];
                        PortalHelper.GetPortalEdges(projectile.Center, projectile.ai[0], out vector2, out vector21);
                        if (Collision.CheckAABBvLineCollision(ent.position + ent.velocity, ent.Size, vector2, vector21, 2f, ref single))
                        {
                            Projectile projectile1       = Main.projectile[PortalHelper.FoundPortals[i, 1 - j]];
                            float      single1           = ent.Hitbox.Distance(projectile.Center);
                            Vector2    portalOutingPoint = PortalHelper.GetPortalOutingPoint(ent.Size, projectile1.Center, projectile1.ai[0], out num, out num1) + (Vector2.Normalize(new Vector2((float)num, (float)num1)) * single1);
                            Vector2    unitX             = Vector2.UnitX * 16f;
                            if (Collision.TileCollision(portalOutingPoint - unitX, unitX, num2, num3, false, false, num4) == unitX)
                            {
                                unitX = -Vector2.UnitX * 16f;
                                if (Collision.TileCollision(portalOutingPoint - unitX, unitX, num2, num3, false, false, num4) == unitX)
                                {
                                    unitX = Vector2.UnitY * 16f;
                                    if (Collision.TileCollision(portalOutingPoint - unitX, unitX, num2, num3, false, false, num4) == unitX)
                                    {
                                        unitX = -Vector2.UnitY * 16f;
                                        if (Collision.TileCollision(portalOutingPoint - unitX, unitX, num2, num3, false, false, num4) == unitX)
                                        {
                                            float single2 = 0.1f;
                                            if (num1 == -num4)
                                            {
                                                single2 = 0.1f;
                                            }
                                            if (ent.velocity == Vector2.Zero)
                                            {
                                                ent.velocity = (projectile.ai[0] - 1.57079637f).ToRotationVector2() * single2;
                                            }
                                            if (ent.velocity.Length() < single2)
                                            {
                                                ent.velocity.Normalize();
                                                Entity entity = ent;
                                                entity.velocity = entity.velocity * single2;
                                            }
                                            Vector2 unitX1 = Vector2.Normalize(new Vector2((float)num, (float)num1));
                                            if (unitX1.HasNaNs() || unitX1 == Vector2.Zero)
                                            {
                                                unitX1 = Vector2.UnitX * (float)ent.direction;
                                            }
                                            ent.velocity = unitX1 * ent.velocity.Length();
                                            if (num1 == -num4 && Math.Sign(ent.velocity.Y) != -num4 || Math.Abs(ent.velocity.Y) < 0.1f)
                                            {
                                                ent.velocity.Y = (float)(-num4) * 0.1f;
                                            }
                                            int num5 = (int)((float)(projectile1.owner * 2) + projectile1.ai[1]);
                                            int num6 = num5 + (num5 % 2 == 0 ? 1 : -1);
                                            if (ent is Player)
                                            {
                                                Player player = (Player)ent;
                                                player.lastPortalColorIndex = num6;
                                                player.Teleport(portalOutingPoint, 4, num5);
                                                if (Main.netMode == 1)
                                                {
                                                    NetMessage.SendData(96, -1, -1, "", player.whoAmI, portalOutingPoint.X, portalOutingPoint.Y, (float)num5, 0, 0, 0);
                                                    NetMessage.SendData(13, -1, -1, "", player.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                }
                                                PortalHelper.PortalCooldownForPlayers[i] = 10;
                                                return;
                                            }
                                            if (ent is NPC)
                                            {
                                                NPC nPC = (NPC)ent;
                                                nPC.lastPortalColorIndex = num6;
                                                nPC.Teleport(portalOutingPoint, 4, num5);
                                                if (Main.netMode == 1)
                                                {
                                                    NetMessage.SendData(100, -1, -1, "", nPC.whoAmI, portalOutingPoint.X, portalOutingPoint.Y, (float)num5, 0, 0, 0);
                                                    NetMessage.SendData(23, -1, -1, "", nPC.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                }
                                                PortalHelper.PortalCooldownForPlayers[i] = 10;
                                            }
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #24
0
        public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle)
        {
            int   num;
            int   num1;
            Point tileCoordinates = portalCenter.ToTileCoordinates();
            int   num2            = (int)Math.Round((double)(MathHelper.WrapAngle(portalAngle) / 0.7853982f));

            if (num2 == 2 || num2 == -2)
            {
                num  = (num2 == 2 ? -1 : 1);
                num1 = 0;
            }
            else if (num2 == 0 || num2 == 4)
            {
                num  = 0;
                num1 = (num2 == 0 ? 1 : -1);
            }
            else if (num2 == -3 || num2 == 3)
            {
                num  = (num2 == -3 ? 1 : -1);
                num1 = -1;
            }
            else
            {
                if (num2 != 1 && num2 != -1)
                {
                    object[] objArray = new object[] { "Broken portal! (over4s = ", num2, " , ", portalAngle, ")" };
                    Main.NewText(string.Concat(objArray), 255, 255, 255, false);
                    return(false);
                }
                num  = (num2 == -1 ? 1 : -1);
                num1 = 1;
            }
            if (num != 0 && num1 != 0)
            {
                int num3 = 3;
                if (num == -1 && num1 == 1)
                {
                    num3 = 5;
                }
                if (num == 1 && num1 == -1)
                {
                    num3 = 2;
                }
                if (num == 1 && num1 == 1)
                {
                    num3 = 4;
                }
                num3--;
                if (!PortalHelper.SupportedSlope(tileCoordinates.X, tileCoordinates.Y, num3) || !PortalHelper.SupportedSlope(tileCoordinates.X + num, tileCoordinates.Y - num1, num3))
                {
                    return(false);
                }
                return(PortalHelper.SupportedSlope(tileCoordinates.X - num, tileCoordinates.Y + num1, num3));
            }
            if (num != 0)
            {
                if (num == 1)
                {
                    tileCoordinates.X = tileCoordinates.X - 1;
                }
                if (!PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) || !PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y - 1))
                {
                    return(false);
                }
                return(PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y + 1));
            }
            if (num1 == 0)
            {
                return(true);
            }
            if (num1 == 1)
            {
                tileCoordinates.Y = tileCoordinates.Y - 1;
            }
            if (PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X + 1, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X - 1, tileCoordinates.Y))
            {
                return(true);
            }
            if (!PortalHelper.SupportedHalfbrick(tileCoordinates.X, tileCoordinates.Y) || !PortalHelper.SupportedHalfbrick(tileCoordinates.X + 1, tileCoordinates.Y))
            {
                return(false);
            }
            return(PortalHelper.SupportedHalfbrick(tileCoordinates.X - 1, tileCoordinates.Y));
        }
Пример #25
0
        private static bool SupportedNormal(int x, int y)
        {
            Tile tile = Main.tile[x, y];

            return(tile != null && tile.nactive() && (!Main.tileCut[(int)tile.type] && !TileID.Sets.BreakableWhenPlacing[(int)tile.type]) && (Main.tileSolid[(int)tile.type] && !TileID.Sets.NotReallySolid[(int)tile.type] && (!tile.halfBrick() && tile.slope() == (byte)0)) && PortalHelper.DoesTileTypeSupportPortals(tile.type));
        }