public static RaycastResult GetDropPlacement(Vector3 Origin)
 {
     return(RaycastUtility.RaycastAll(Origin, Vector3.down, 20));
 }
        public static void RunJumpTool(UnturnedPlayer Player, RaycastResult Raycast, UnturnedPlayerEvents.PlayerGesture gesture)
        {
            if (gesture == UnturnedPlayerEvents.PlayerGesture.PunchRight)
            {
                int   RunMode = 0;
                float Pitch   = Player.Player.look.pitch;

                if (Player.Stance == EPlayerStance.STAND)
                {
                    if (Pitch <= 5)
                    {
                        RunMode = 1;
                    }
                    else if (Pitch >= 175)
                    {
                        RunMode = 2;
                    }
                    else
                    {
                        RunMode = 0;
                    }
                }
                else if (Player.Stance == EPlayerStance.CROUCH)
                {
                    if (Pitch <= 22)
                    {
                        RunMode = 1;
                    }
                    else if (Pitch >= 155)
                    {
                        RunMode = 2;
                    }
                    else
                    {
                        RunMode = 0;
                    }
                }

                if (RunMode == 0)
                {
                    Player.Player.teleportToLocationUnsafe(Raycast.Raycast.point, Player.Rotation);
                }
                else if (RunMode == 1)
                {
                    if (Raycast.Raycast.distance < 300)
                    {
                        Vector3 Target = new Vector3(Raycast.Raycast.point.x, Raycast.Raycast.point.y + (float)1.75, Raycast.Raycast.point.z);
                        Player.Player.teleportToLocationUnsafe(Target, Player.Rotation);
                    }
                    else
                    {
                        Player.Player.teleportToLocationUnsafe(Raycast.Raycast.point, Player.Rotation);
                    }
                }
                else if (RunMode == 2)
                {
                    if (Raycast.Raycast.distance > 300)
                    {
                        Player.Player.teleportToLocationUnsafe(Raycast.Raycast.point, Player.Rotation);
                    }
                    else
                    {
                        Vector3 ViewDir = Vector3.down;

                        RaycastResult FloorCast        = RaycastUtility.Raycast(Player.Position, Vector3.down, RayMasks.GROUND, 1500);
                        float         DistanceToGround = 9999;
                        if (FloorCast.RaycastHit)
                        {
                            DistanceToGround = FloorCast.Raycast.distance - (float)0.5;
                        }

                        RaycastResult DownCast     = RaycastUtility.RaycastAll(new Vector3(Raycast.Raycast.point.x, Raycast.Raycast.point.y - 3, Raycast.Raycast.point.z), ViewDir, 300);
                        bool          Cont         = !DownCast.RaycastHit;
                        int           Displacement = 3;
                        while (Cont)
                        {
                            DownCast      = RaycastUtility.RaycastAll(new Vector3(Raycast.Raycast.point.x, Raycast.Raycast.point.y - Displacement, Raycast.Raycast.point.z), ViewDir, 300);
                            Displacement += 3;
                            if (Displacement > 15 || DownCast.RaycastHit)
                            {
                                Cont = false;
                            }
                        }

                        if (DownCast.RaycastHit && DownCast.Raycast.distance != 0 && DownCast.Raycast.distance < DistanceToGround)
                        {
                            Player.Player.teleportToLocationUnsafe(new Vector3(DownCast.Raycast.point.x, DownCast.Raycast.point.y + 0.2f, DownCast.Raycast.point.z), Player.Rotation);
                        }
                        else
                        {
                            UnturnedChat.Say(Player, "PointTool_Jump_NoPlatformBelow".Translate());
                        }
                    }
                }
            }
            else if (gesture == UnturnedPlayerEvents.PlayerGesture.PunchLeft)
            {
                Vector3         TargetPos = Raycast.Raycast.point;
                float           Height    = 15;
                RaycastResult[] Placings  =
                {
                    GetDropPlacement(new Vector3(TargetPos.x,     TargetPos.y + Height, TargetPos.z)),
                    GetDropPlacement(new Vector3(TargetPos.x + 1, TargetPos.y + Height, TargetPos.z)),
                    GetDropPlacement(new Vector3(TargetPos.x - 1, TargetPos.y + Height, TargetPos.z)),
                    GetDropPlacement(new Vector3(TargetPos.x,     TargetPos.y + Height, TargetPos.z + 1)),
                    GetDropPlacement(new Vector3(TargetPos.x,     TargetPos.y + Height, TargetPos.z - 1))
                };
                Vector3[] Placing = Placings.Where(X => X.RaycastHit && X.Raycast.distance != 0).OrderByDescending(V => V.Raycast.point.y).CastEnumeration(E => E.Raycast.point).ToArray();

                if (Placing.Count() != 0)
                {
                    Player.Player.teleportToLocationUnsafe(new Vector3(Placing[0].x, Placing[0].y + 0.5f, Placing[0].z), Player.Rotation);
                }
                else
                {
                    Player.Player.teleportToLocationUnsafe(new Vector3(TargetPos.x, TargetPos.y + 0.5f, TargetPos.z), Player.Rotation);
                }
            }
            else if (gesture == UnturnedPlayerEvents.PlayerGesture.Point)
            {
                Vector3 TargetPos  = Raycast.Raycast.point;
                Vector3 CurrentPos = Player.Position;
                Vector3 ResultPos  = Vector3.MoveTowards(TargetPos, CurrentPos, 1);
                Player.Player.teleportToLocationUnsafe(new Vector3(ResultPos.x, ResultPos.y + 0.5f, ResultPos.z), Player.Rotation);
            }
        }