import type { Entity } from '../classes/Entity'; import type { ScrHandle } from '../types/NativeAliases'; import { Vector2 } from '../types/Vector2'; import { Vector3 } from '../types/Vector3'; import { Vector4 } from '../types/Vector4'; import { Color } from '../types/Color'; import { createFromHandle } from '../types/HandleRegistry'; import { inv, rai, raf, ras, rav, pvi, pvf, pvv, pvii, pvfi, _h, f, int, uint, float, Hash, u8, u16, u32, u64, i8, i16, i32, i64 } from '../types/NativeAliases'; export class Shapetest { /** * Asynchronously starts a line-of-sight (raycast) world probe shape test. Use the handle with 0x3D87450E15D98694 or 0x65287525D951F6BE until it returns 0 or 2. p8 is a bit mask with bits 1, 2 and/or 4, relating to collider types; 4 should usually be used. * * @param pos1 * @param pos2 * @param flags * @param entity * @param p8 * @returns */ static startShapeTestLosProbe(pos1: Vector3, pos2: Vector3, flags: int, entity: Entity, p8: int): number { return inv('0x7EE9F5D83DD4F90E', f(pos1.x), f(pos1.y), f(pos1.z), f(pos2.x), f(pos2.y), f(pos2.z), flags, entity.handle, p8, rai()); } /** * Returns the result of a shape test: 0 if the handle is invalid, 1 if the shape test is still pending, or 2 if the shape test has completed, and the handle should be invalidated. When used with an asynchronous shape test, this native should be looped until returning 0 or 2, after which the handle is invalidated. enum eShapeTestStatus * { * SHAPETEST_STATUS_NONEXISTENT, * SHAPETEST_STATUS_RESULTS_NOTREADY, * SHAPETEST_STATUS_RESULTS_READY * }; * * @param shapeTestHandle * @returns hit; endCoords; surfaceNormal; entityHit */ static getShapeTestResult(shapeTestHandle: number): [int, boolean, Vector3, Vector3, Entity | null] { const result = inv<[number, number, number[], number[], number]>('0xEDE8AC7C5108FB1D', shapeTestHandle, pvi(), pvv(), pvv(), pvi(), rai()); return [result[0], !!result[1], Vector3.fromArray(result[2]), Vector3.fromArray(result[3]), createFromHandle('Entity', result[4])]; } /** * @param p0 * @param p1 * @returns */ static N_0x04AA59CA40571C2E(p0: any, p1: any): any { return inv('0x04AA59CA40571C2E', p0, p1); } /** * @param pos1 * @param pos2 * @param radius * @param flags * @param entityToIgnore * @param p9 * @returns */ static startShapeTestCapsule(pos1: Vector3, pos2: Vector3, radius: float, flags: int, entityToIgnore: Entity, p9: int): number { return inv('0x28579D1B8F8AAC80', f(pos1.x), f(pos1.y), f(pos1.z), f(pos2.x), f(pos2.y), f(pos2.z), f(radius), flags, entityToIgnore.handle, p9, rai()); } /** * @param pos * @param dimensionsX * @param dimensionsY * @param dimensionsZ * @param rot * @param rotationOrder * @param flags * @param entityToIgnore * @param options * @returns */ static startShapeTestBox(pos: Vector3, dimensionsX: float, dimensionsY: float, dimensionsZ: float, rot: Vector3, rotationOrder: int, flags: int, entityToIgnore: Entity, options: int): number { return inv('0xFE466162C4401D18', f(pos.x), f(pos.y), f(pos.z), f(dimensionsX), f(dimensionsY), f(dimensionsZ), f(rot.x), f(rot.y), f(rot.z), rotationOrder, flags, entityToIgnore.handle, options, rai()); } /** * Does the same as 0x7EE9F5D83DD4F90E, except blocking until the shape test completes. * * @param pos1 * @param pos2 * @param flags * @param entityToIgnore * @param p8 * @returns */ static startExpensiveSynchronousShapeTestLosProbe(pos1: Vector3, pos2: Vector3, flags: int, entityToIgnore: Entity, p8: int): number { return inv('0x377906D8A31E5586', f(pos1.x), f(pos1.y), f(pos1.z), f(pos2.x), f(pos2.y), f(pos2.z), flags, entityToIgnore.handle, p8, rai()); } /** * Old name: _START_SHAPE_TEST_SURROUNDING_COORDS * * @param flag * @param entity * @param flag2 * @returns pVec1; pVec2 */ static startShapeTestMouseCursorLosProbe(flag: int, entity: Entity, flag2: int): [number, Vector3, Vector3] { const result = inv<[number, number[], number[]]>('0x9839013D8B6014F1', pvv(), pvv(), flag, entity.handle, flag2, rai()); return [result[0], Vector3.fromArray(result[1]), Vector3.fromArray(result[2])]; } /** * @param pos1 * @param pos2 * @param radius * @param flags * @param entity * @param p9 * @returns */ static startShapeTestSweptSphere(pos1: Vector3, pos2: Vector3, radius: float, flags: int, entity: Entity, p9: any): number { return inv('0xAA5B7C8309F73230', f(pos1.x), f(pos1.y), f(pos1.z), f(pos2.x), f(pos2.y), f(pos2.z), f(radius), flags, entity.handle, p9, rai()); } }