FindCollision() private static method

private static FindCollision ( Vector2 startPosition, Vector2 stopPosition ) : Vector2
startPosition Vector2
stopPosition Vector2
return Vector2
示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }