Ejemplo n.º 1
0
        /// <summary>
        ///     Shoot's a ray from the camera position in the
        ///     direction of the camera, for the specified distance.
        /// </summary>
        /// <param name="distance">The shape test distance.</param>
        /// <param name="flags">The shapetest flags.</param>
        /// <param name="ignoreEntity">The entity to be ignored by the shapetest ray.</param>
        /// <returns></returns>
        public static ShapeTestResult GetCameraRay(float distance, ShapeTestFlags flags, Entity ignoreEntity = null)
        {
            var gameCamPos = GameplayCamera.Position;
            var dir        = GameplayCamera.Direction * distance;
            var ray        = WorldProbe.StartShapeTestRay(gameCamPos, gameCamPos + dir, flags, ignoreEntity);
            var result     = ray.GetResult();

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Shoot's a ray from the player position in the
        ///     direction of the player, for the specified distance.
        /// </summary>
        /// <param name="distance">The shape test distance.</param>
        /// <param name="flags">The shapetest flags.</param>
        /// <param name="ignoreEntity">The entity to be ignored by the shapetest ray.</param>
        /// <returns></returns>
        public static ShapeTestResult GetPlayerRay(float distance, ShapeTestFlags flags, Entity ignoreEntity = null)
        {
            var player     = Game.Player.Character;
            var gameCamPos = player.Position;
            var dir        = player.ForwardVector * distance;
            var ray        = WorldProbe.StartShapeTestRay(gameCamPos, gameCamPos + dir, flags, ignoreEntity);
            var result     = ray.GetResult();

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Start's a shape test in the form of a capsule.
        /// </summary>
        /// <param name="startCoords">The starting coords (bottom of the capsule)</param>
        /// <param name="endCoords">The ending coords (top of the capsule)</param>
        /// <param name="radius">The radius of the capsule.</param>
        /// <param name="flags">The flags specifying what this shape test interacts with.</param>
        /// <param name="ignoreEntity">The entity to ignore.</param>
        /// <param name="p9">An unknown variable (always 7). Just including this incase it needs changed.</param>
        /// <returns></returns>
        public static ShapeTest StartShapeTestCapsule(Vector3 startCoords, Vector3 endCoords, float radius,
                                                      ShapeTestFlags flags,
                                                      Entity ignoreEntity, int p9 = 7)
        {
            var entityHandle = ignoreEntity?.Handle ?? 0;

            return(new ShapeTest(Function.Call <int>(Hash._0x28579D1B8F8AAC80,
                                                     startCoords.X, startCoords.Y, startCoords.Z,
                                                     endCoords.X, endCoords.Y, endCoords.Z,
                                                     radius,
                                                     (int)flags,
                                                     entityHandle)));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Start's a shape test ray (line).
        /// </summary>
        /// <param name="startCoords">The starting coordinates.</param>
        /// <param name="endCoords">The ending coordinates.</param>
        /// <param name="flags">The flags specifying what this shape test interacts with.</param>
        /// <param name="ignoreEntity">The entity to ignore.</param>
        /// <returns></returns>
        public static ShapeTest StartShapeTestRay(Vector3 startCoords, Vector3 endCoords, ShapeTestFlags flags,
                                                  Entity ignoreEntity)
        {
            var entityHandle = ignoreEntity?.Handle ?? 0;

            return(new ShapeTest(Function.Call <int>(Hash._0x377906D8A31E5586,
                                                     startCoords.X, startCoords.Y, startCoords.Z,
                                                     endCoords.X, endCoords.Y, endCoords.Z,
                                                     (int)flags,
                                                     entityHandle)));
        }