import type { eEulerRotationOrder } from '../enums/eEulerRotationOrder'; import type { Entity } from '../classes/Entity'; import type { Ped } from '../classes/Ped'; import { Vector2 } from '../types/Vector2'; import { Vector3 } from '../types/Vector3'; import { Vector4 } from '../types/Vector4'; import { Color } from '../types/Color'; import { IHandle } from '../types/IHandle'; import { registerHandle, 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 Cam implements IHandle { constructor(public handle: number) {} static fromHandle(handle: number): Cam | null { return handle === 0 ? null : new Cam(handle); } /** * @param rotationOrder * @returns */ getRot(rotationOrder: eEulerRotationOrder): Vector3 { return Vector3.fromArray(inv('0x9BF96B57254E7889', this.handle, rotationOrder, rav())); } /** * Allows you to aim and shoot at the direction the camera is facing. * * @param toggle */ set AffectsAiming(toggle: boolean) { inv('0x3CB9E8BDE5E76F33', this.handle, toggle); } /** * Allows you to aim and shoot at the direction the camera is facing. * * @param toggle * @returns The instance for method chaining */ setAffectsAiming(toggle: boolean): this { inv('0x3CB9E8BDE5E76F33', this.handle, toggle); return this; } /** * Set cam DOF and focal settings. TODO: Support structs * * @returns p */ setDofParams(): number { const result = inv('0xE4B7945EF4F1BFB2', this.handle, pvi()); return result; } /** * @param p1 */ set SplinePhase(p1: float) { inv('0xF1898A68E7C15636', this.handle, f(p1)); } /** * @param p1 * @returns The instance for method chaining */ setSplinePhase(p1: float): this { inv('0xF1898A68E7C15636', this.handle, f(p1)); return this; } /** * @returns */ get Coord(): Vector3 { return Vector3.fromArray(inv('0x6B12F11C2A9F0344', this.handle, rav())); } detachCam(): void { inv('0x05B41DDBEB559556', this.handle); } /** * @param timeDuration */ set SplineDuration(timeDuration: int) { inv('0xFF6311652CA91015', this.handle, timeDuration); } /** * @param timeDuration * @returns The instance for method chaining */ setSplineDuration(timeDuration: int): this { inv('0xFF6311652CA91015', this.handle, timeDuration); return this; } /** * @param distance */ set FocusDistance(distance: float) { inv('0x11F32BB61B756732', this.handle, f(distance)); } /** * @param distance * @returns The instance for method chaining */ setFocusDistance(distance: float): this { inv('0x11F32BB61B756732', this.handle, f(distance)); return this; } /** * Sets the position of the cam. * * @param pos */ set Coord(pos: Vector3) { inv('0xF9EE7D419EE49DE6', this.handle, f(pos.x), f(pos.y), f(pos.z)); } /** * Sets the position of the cam. * * @param pos * @returns The instance for method chaining */ setCoord(pos: Vector3): this { inv('0xF9EE7D419EE49DE6', this.handle, f(pos.x), f(pos.y), f(pos.z)); return this; } /** * @param smoothingStyle */ set SplineSmoothingStyle(smoothingStyle: int) { inv('0x84B3645618E726B0', this.handle, smoothingStyle); } /** * @param smoothingStyle * @returns The instance for method chaining */ setSplineSmoothingStyle(smoothingStyle: int): this { inv('0x84B3645618E726B0', this.handle, smoothingStyle); return this; } /** * @param farClip */ set FarClip(farClip: float) { inv('0x5E32817BF6302111', this.handle, f(farClip)); } /** * @param farClip * @returns The instance for method chaining */ setFarClip(farClip: float): this { inv('0x5E32817BF6302111', this.handle, f(farClip)); return this; } /** * @param strength */ set MotionBlurStrength(strength: float) { inv('0x45FD891364181F9E', this.handle, f(strength)); } /** * @param strength * @returns The instance for method chaining */ setMotionBlurStrength(strength: float): this { inv('0x45FD891364181F9E', this.handle, f(strength)); return this; } /** * @param animName * @param animDictionary * @param pos * @param rot * @param animFlags * @param rotOrder * @returns */ playAnim(animName: string, animDictionary: string, pos: Vector3, rot: Vector3, animFlags: int, rotOrder: int): boolean { return !!inv('0xA263DDF694D563F6', this.handle, animName, animDictionary, f(pos.x), f(pos.y), f(pos.z), f(rot.x), f(rot.y), f(rot.z), animFlags, rotOrder, rai()); } /** * Returns whether or not the passed camera handle exists. * * @returns */ doesExist(): boolean { return !!inv('0x153AD457764FD704', this.handle, rai()); } /** * p7 (length) determines the length of the spline, affects camera path and duration of transition between previous node and this one p8 big values ~100 will slow down the camera movement before reaching this node p9 != 0 seems to override the rotation/pitch (bool?) * * @param pos * @param rot * @param length * @param p8 * @param p9 */ addSplineNode(pos: Vector3, rot: Vector3, length: int, p8: int, p9: int): void { inv('0xF1F57F9D230F9CD1', this.handle, f(pos.x), f(pos.y), f(pos.z), f(rot.x), f(rot.y), f(rot.z), length, p8, p9); } /** * Last param determines if its relative to the Entity * * @param entity * @param offset * @param isRelative */ attachToEntity(entity: Entity, offset: Vector3, isRelative: boolean): void { inv('0xFDC0DF7F6FB0A592', this.handle, entity.handle, f(offset.x), f(offset.y), f(offset.z), isRelative); } /** * @param p1 */ set ControlsMiniMapHeading(p1: boolean) { inv('0x1B8F3CE5A6001298', this.handle, p1); } /** * @param p1 * @returns The instance for method chaining */ setControlsMiniMapHeading(p1: boolean): this { inv('0x1B8F3CE5A6001298', this.handle, p1); return this; } /** * Can use this with SET_CAM_SPLINE_PHASE to set the float it this native returns. (returns 1.0f when no nodes has been added, reached end of non existing spline) * * @returns */ get SplinePhase(): float { return inv('0x095EDCD24D90033A', this.handle, raf()); } /** * @returns */ get IsShaking(): boolean { return !!inv('0x2EEB402BD7320159', this.handle, rai()); } /** * @returns */ get Fov(): float { return inv('0x8101D32A0A6B0F60', this.handle, raf()); } /** * @param type * @param amplitude */ shakeCam(type: string, amplitude: float): void { inv('0xF9A7BCF5D050D4E7', this.handle, type, f(amplitude)); } /** * @returns */ get IsInterpolating(): boolean { return !!inv('0x578F8F1CAA17BD2B', this.handle, rai()); } /** * @param p1 */ stopShaking(p1: boolean): void { inv('0xB78CC4B4706614B0', this.handle, p1); } /** * @param nearClip */ set NearClip(nearClip: float) { inv('0xA924028272A61364', this.handle, f(nearClip)); } /** * @param nearClip * @returns The instance for method chaining */ setNearClip(nearClip: float): this { inv('0xA924028272A61364', this.handle, f(nearClip)); return this; } /** * @param pos */ pointAtCoord(pos: Vector3): void { inv('0x948B39341C3A40C2', this.handle, f(pos.x), f(pos.y), f(pos.z)); } /** * @param entity * @param p2 * @param p3 * @param p4 * @param p5 */ pointAtEntity(entity: Entity, p2: float, p3: float, p4: float, p5: boolean): void { inv('0xFC2867E6074D3A61', this.handle, entity.handle, f(p2), f(p3), f(p4), p5); } /** * @param pause */ pauseCameraFocus(pause: boolean): void { inv('0x9F97E85EC142255E', this.handle, pause); } /** * Set camera as active/inactive. * * @param active */ set Active(active: boolean) { inv('0x87295BCA613800C8', this.handle, active); } /** * Set camera as active/inactive. * * @param active * @returns The instance for method chaining */ setActive(active: boolean): this { inv('0x87295BCA613800C8', this.handle, active); return this; } /** * @param pos * @param rot * @param fieldOfView * @param p8 * @param p9 * @param p10 * @param p11 * @param p12 * @param p13 * @returns The instance for method chaining */ setParams(pos: Vector3, rot: Vector3, fieldOfView: float, p8: any, p9: int, p10: int, p11: int, p12: any, p13: any): this { inv('0xA47BBFFFB83D4D0A', this.handle, f(pos.x), f(pos.y), f(pos.z), f(rot.x), f(rot.y), f(rot.z), f(fieldOfView), p8, p9, p10, p11, p12, p13); return this; } /** * Sets the rotation of the cam. * * @param rot * @param rotationOrder * @returns The instance for method chaining */ setRot(rot: Vector3, rotationOrder: int): this { inv('0x63DFA6810AD78719', this.handle, f(rot.x), f(rot.y), f(rot.z), rotationOrder); return this; } /** * BOOL param indicates whether the cam should be destroyed if it belongs to the calling script. * * @param p1 */ destroyCam(p1: boolean): void { inv('0x4E67E0B6D7FD5145', this.handle, p1); } /** * @returns */ get IsRendering(): boolean { return !!inv('0x4415F8A6C536D39F', this.handle, rai()); } /** * Returns whether or not the passed camera handle is active. * * @returns */ get IsActive(): boolean { return !!inv('0x63EFCC7E1810B8E6', this.handle, rai()); } /** * @param p1 */ allowMotionBlurDecay(p1: boolean): void { inv('0x42ED56B02E05D109', this.handle, p1); } /** * boneIndex: https://github.com/femga/rdr3_discoveries/tree/master/boneNames * * @param ped * @param boneIndex * @param pos * @param heading */ attachToPedBone(ped: Ped, boneIndex: int, pos: Vector3, heading: boolean): void { inv('0xDFC1E4A44C0324CA', this.handle, ped.handle, boneIndex, f(pos.x), f(pos.y), f(pos.z), heading); } /** * @param camFrom * @param duration * @param easeLocation * @param easeRotation * @returns The instance for method chaining */ setActiveWithInterp(camFrom: Cam, duration: int, easeLocation: int, easeRotation: int): this { inv('0x8B15AE2987C1AC8F', this.handle, camFrom.handle, duration, easeLocation, easeRotation); return this; } /** * Sets the field of view of the cam. Min: 1.0f * Max: 130.0f * * @param fieldOfView */ set Fov(fieldOfView: float) { inv('0x27666E5988D9D429', this.handle, f(fieldOfView)); } /** * Sets the field of view of the cam. Min: 1.0f * Max: 130.0f * * @param fieldOfView * @returns The instance for method chaining */ setFov(fieldOfView: float): this { inv('0x27666E5988D9D429', this.handle, f(fieldOfView)); return this; } stopPointing(): void { inv('0xCA1B30A3357C71F1', this.handle); } } registerHandle('Cam', Cam);