private static void UpdatePlatePosition(Point location, int player, bool onIt)
 {
     if (onIt)
     {
         PressurePlateHelper.MoveInto(location, player);
         return;
     }
     PressurePlateHelper.MoveAwayFrom(location, player);
 }
예제 #2
0
        public static void UpdatePlayerPosition(Player player)
        {
            Point p;

            // ISSUE: explicit reference operation
            ((Point)@p).\u002Ector(1, 1);
            Vector2      vector2  = p.ToVector2();
            List <Point> tilesIn1 = Collision.GetTilesIn(Vector2.op_Addition(PressurePlateHelper.PlayerLastPosition[player.whoAmI], vector2), Vector2.op_Subtraction(Vector2.op_Addition(PressurePlateHelper.PlayerLastPosition[player.whoAmI], player.Size), Vector2.op_Multiply(vector2, 2f)));
            List <Point> tilesIn2 = Collision.GetTilesIn(Vector2.op_Addition(player.TopLeft, vector2), Vector2.op_Subtraction(player.BottomRight, Vector2.op_Multiply(vector2, 2f)));
            Rectangle    hitbox1  = player.Hitbox;
            Rectangle    hitbox2  = player.Hitbox;

            // ISSUE: explicit reference operation
            ((Rectangle)@hitbox1).Inflate((int)-p.X, (int)-p.Y);
            // ISSUE: explicit reference operation
            ((Rectangle)@hitbox2).Inflate((int)-p.X, (int)-p.Y);
            hitbox2.X = (__Null)(int)PressurePlateHelper.PlayerLastPosition[player.whoAmI].X;
            hitbox2.Y = (__Null)(int)PressurePlateHelper.PlayerLastPosition[player.whoAmI].Y;
            for (int index = 0; index < tilesIn1.Count; ++index)
            {
                Point location = tilesIn1[index];
                Tile  tile     = Main.tile[(int)location.X, (int)location.Y];
                if (tile.active() && (int)tile.type == 428)
                {
                    PressurePlateHelper.pressurePlateBounds.X = (__Null)(location.X * 16);
                    PressurePlateHelper.pressurePlateBounds.Y = (__Null)(location.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height);
                    // ISSUE: explicit reference operation
                    if (!((Rectangle)@hitbox1).Intersects(PressurePlateHelper.pressurePlateBounds) && !tilesIn2.Contains(location))
                    {
                        PressurePlateHelper.MoveAwayFrom(location, player.whoAmI);
                    }
                }
            }
            for (int index = 0; index < tilesIn2.Count; ++index)
            {
                Point location = tilesIn2[index];
                Tile  tile     = Main.tile[(int)location.X, (int)location.Y];
                if (tile.active() && (int)tile.type == 428)
                {
                    PressurePlateHelper.pressurePlateBounds.X = (__Null)(location.X * 16);
                    PressurePlateHelper.pressurePlateBounds.Y = (__Null)(location.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height);
                    // ISSUE: explicit reference operation
                    // ISSUE: explicit reference operation
                    if (((Rectangle)@hitbox1).Intersects(PressurePlateHelper.pressurePlateBounds) && (!tilesIn1.Contains(location) || !((Rectangle)@hitbox2).Intersects(PressurePlateHelper.pressurePlateBounds)))
                    {
                        PressurePlateHelper.MoveInto(location, player.whoAmI);
                    }
                }
            }
            PressurePlateHelper.PlayerLastPosition[player.whoAmI] = player.position;
        }
        public static void UpdatePlayerPosition(Player player)
        {
            var p        = new Point(1, 1);
            var vector2  = p.ToVector2();
            var tilesIn1 = Collision.GetTilesIn(PressurePlateHelper.PlayerLastPosition[player.whoAmI] + vector2,
                                                PressurePlateHelper.PlayerLastPosition[player.whoAmI] + player.Size - vector2 * 2f);
            var tilesIn2 = Collision.GetTilesIn(player.TopLeft + vector2, player.BottomRight - vector2 * 2f);
            var hitbox1  = player.Hitbox;
            var hitbox2  = player.Hitbox;

            hitbox1.Inflate(-p.X, -p.Y);
            hitbox2.Inflate(-p.X, -p.Y);
            hitbox2.X = (int)PressurePlateHelper.PlayerLastPosition[player.whoAmI].X;
            hitbox2.Y = (int)PressurePlateHelper.PlayerLastPosition[player.whoAmI].Y;
            for (var index = 0; index < tilesIn1.Count; ++index)
            {
                var location = tilesIn1[index];
                var tile     = Main.tile[location.X, location.Y];
                if (tile.active() && tile.type == (ushort)428)
                {
                    PressurePlateHelper.pressurePlateBounds.X = location.X * 16;
                    PressurePlateHelper.pressurePlateBounds.Y =
                        location.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height;
                    if (!hitbox1.Intersects(PressurePlateHelper.pressurePlateBounds) && !tilesIn2.Contains(location))
                    {
                        PressurePlateHelper.MoveAwayFrom(location, player.whoAmI);
                    }
                }
            }

            for (var index = 0; index < tilesIn2.Count; ++index)
            {
                var location = tilesIn2[index];
                var tile     = Main.tile[location.X, location.Y];
                if (tile.active() && tile.type == (ushort)428)
                {
                    PressurePlateHelper.pressurePlateBounds.X = location.X * 16;
                    PressurePlateHelper.pressurePlateBounds.Y =
                        location.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height;
                    if (hitbox1.Intersects(PressurePlateHelper.pressurePlateBounds) &&
                        (!tilesIn1.Contains(location) || !hitbox2.Intersects(PressurePlateHelper.pressurePlateBounds)))
                    {
                        PressurePlateHelper.MoveInto(location, player.whoAmI);
                    }
                }
            }

            PressurePlateHelper.PlayerLastPosition[player.whoAmI] = player.position;
        }
        public static void UpdatePlayerPosition(Player player)
        {
            Point        p        = new Point(1, 1);
            Vector2      vector   = p.ToVector2();
            List <Point> tilesIn  = Collision.GetTilesIn(PressurePlateHelper.PlayerLastPosition[player.whoAmI] + vector, PressurePlateHelper.PlayerLastPosition[player.whoAmI] + player.Size - vector * 2f);
            List <Point> tilesIn2 = Collision.GetTilesIn(player.TopLeft + vector, player.BottomRight - vector * 2f);
            Rectangle    hitbox   = player.Hitbox;
            Rectangle    hitbox2  = player.Hitbox;

            hitbox.Inflate(-p.X, -p.Y);
            hitbox2.Inflate(-p.X, -p.Y);
            hitbox2.X = (int)PressurePlateHelper.PlayerLastPosition[player.whoAmI].X;
            hitbox2.Y = (int)PressurePlateHelper.PlayerLastPosition[player.whoAmI].Y;
            for (int i = 0; i < tilesIn.Count; i++)
            {
                Point point = tilesIn[i];
                Tile  tile  = Main.tile[point.X, point.Y];
                if (tile.active() && tile.type == 428)
                {
                    PressurePlateHelper.pressurePlateBounds.X = point.X * 16;
                    PressurePlateHelper.pressurePlateBounds.Y = point.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height;
                    if (!hitbox.Intersects(PressurePlateHelper.pressurePlateBounds) && !tilesIn2.Contains(point))
                    {
                        PressurePlateHelper.MoveAwayFrom(point, player.whoAmI);
                    }
                }
            }
            for (int j = 0; j < tilesIn2.Count; j++)
            {
                Point point2 = tilesIn2[j];
                Tile  tile2  = Main.tile[point2.X, point2.Y];
                if (tile2.active() && tile2.type == 428)
                {
                    PressurePlateHelper.pressurePlateBounds.X = point2.X * 16;
                    PressurePlateHelper.pressurePlateBounds.Y = point2.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height;
                    if (hitbox.Intersects(PressurePlateHelper.pressurePlateBounds) && (!tilesIn.Contains(point2) || !hitbox2.Intersects(PressurePlateHelper.pressurePlateBounds)))
                    {
                        PressurePlateHelper.MoveInto(point2, player.whoAmI);
                    }
                }
            }
            PressurePlateHelper.PlayerLastPosition[player.whoAmI] = player.position;
        }