rock-mod
Version:
Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.
312 lines (311 loc) • 9.63 kB
JavaScript
import { BaseObjectType } from "../../../../shared/entities";
import { Vector3D } from "../../../../shared/common/utils";
export class CCMPVehicle {
constructor(_ccmpVehicle, _onDestroy = () => { }) {
this._ccmpVehicle = _ccmpVehicle;
this._onDestroy = _onDestroy;
this._destroyed = false;
}
get id() {
return this._ccmpVehicle.id;
}
get remoteId() {
return this._ccmpVehicle.remoteId;
}
get type() {
return BaseObjectType.Vehicle;
}
get isExists() {
if (this._destroyed)
return false;
if (this._ccmpVehicle.isRemote)
return this._getRemoteVehicleExists();
return this._ccmpVehicle.isExists;
}
get handle() {
return this._normalizeHandle(this._ccmpVehicle.handle);
}
destroy() {
if (this._destroyed)
return;
this._destroyed = true;
this._ccmpVehicle.destroy();
this._onDestroy(this);
}
get position() {
const { x, y, z } = this._ccmpVehicle.position;
return new Vector3D(x, y, z);
}
get dimension() {
return this._ccmpVehicle.dimension;
}
setPosition(value) {
this._ccmpVehicle.setPosition(value);
}
setDimension(value) {
this._ccmpVehicle.setDimension(value);
}
setCoords(xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea) {
this._ccmpVehicle.setCoords(xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea);
}
get model() {
return this._ccmpVehicle.model;
}
get heading() {
return this._ccmpVehicle.heading;
}
setHeading(heading) {
this._ccmpVehicle.setHeading(heading);
}
setModel(value) {
this._ccmpVehicle.setModel(value);
}
get rotation() {
const { x, y, z } = this._ccmpVehicle.rotation;
return new Vector3D(x, y, z);
}
get forwardVector() {
const { x, y, z } = this._ccmpVehicle.forwardVector;
return new Vector3D(x, y, z);
}
setRotation(value) {
this._ccmpVehicle.setRotation(value);
}
freezePosition(freeze) {
this._ccmpVehicle.freezePosition(freeze);
}
setCollision(collision, keepPhysics) {
this._ccmpVehicle.setCollision(collision, keepPhysics);
}
setInvincible(invincible) {
this._ccmpVehicle.setInvincible(invincible);
}
setVisible(visible) {
this._ccmpVehicle.setVisible(visible);
}
setAlpha(alpha) {
this._ccmpVehicle.setAlpha(alpha);
}
get alpha() {
return this._ccmpVehicle.alpha;
}
resetAlpha() {
this._ccmpVehicle.resetAlpha();
}
getOffsetFromInWorldCoords(offsetX, offsetY, offsetZ) {
const { x, y, z } = this._ccmpVehicle.getOffsetFromInWorldCoords(offsetX, offsetY, offsetZ);
return new Vector3D(x, y, z);
}
getBoneIndexByName(boneName) {
return this._ccmpVehicle.getBoneIndexByName(boneName);
}
getWorldPositionOfBone(boneIndex) {
const { x, y, z } = this._ccmpVehicle.getWorldPositionOfBone(boneIndex);
return new Vector3D(x, y, z);
}
getVariable(name) {
const remoteId = this.remoteId;
if (remoteId === null)
return null;
const value = ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Vehicle, remoteId, name);
return value === undefined ? null : value;
}
getSyncedMeta(key) {
const remoteId = this.remoteId;
if (remoteId === null)
return undefined;
return ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Vehicle, remoteId, key);
}
hasSyncedMeta(key) {
const remoteId = this.remoteId;
if (remoteId === null)
return false;
return ccmp.entities.hasStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Vehicle, remoteId, key);
}
getSyncedMetaKeys() {
const remoteId = this.remoteId;
if (remoteId === null)
return [];
return ccmp.entities.getStreamSyncedMetaKeys(ccmp.entities.ENTITY_TYPE.Vehicle, remoteId);
}
attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot) {
this._ccmpVehicle.attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
}
detach(useDetachVelocity, collision) {
this._ccmpVehicle.detach(useDetachVelocity, collision);
}
getSpeed() {
return this._ccmpVehicle.getSpeed();
}
isPlayingAnim(dictionary, name, taskFlag) {
return this._ccmpVehicle.isPlayingAnim(dictionary, name, taskFlag);
}
get bodyHealth() {
return this._ccmpVehicle.bodyHealth;
}
get engineHealth() {
return this._ccmpVehicle.engineHealth;
}
get numberPlate() {
return this._ccmpVehicle.numberPlate;
}
get isDead() {
return this._ccmpVehicle.isDead;
}
setBodyHealth(value) {
this._ccmpVehicle.setBodyHealth(value);
}
setEngineHealth(value) {
this._ccmpVehicle.setEngineHealth(value);
}
setNumberPlate(value) {
this._ccmpVehicle.setNumberPlate(value);
}
explode() {
this._ccmpVehicle.explode();
}
getPedInSeat(seat) {
return this._ccmpVehicle.getPedInSeat(seat);
}
setUndriveable(toggle) {
this._ccmpVehicle.setUndriveable(toggle);
}
get maxNumberOfPassengers() {
return this._ccmpVehicle.maxNumberOfPassengers;
}
get gear() {
return this._ccmpVehicle.gear;
}
get speed() {
return this._ccmpVehicle.speed;
}
get isEngineRunning() {
return this._ccmpVehicle.isEngineRunning;
}
setEngineOn(toggle, instantly, otherwise) {
this._ccmpVehicle.setEngineOn(toggle, instantly, otherwise);
}
get lightsState() {
return this._ccmpVehicle.lightsState;
}
get isLocked() {
return this._ccmpVehicle.isLocked;
}
setIsLocked(value) {
this._ccmpVehicle.setIsLocked(value);
}
setCustomPrimaryColour(color) {
this._ccmpVehicle.setCustomPrimaryColour(color);
}
setCustomSecondaryColour(color) {
this._ccmpVehicle.setCustomSecondaryColour(color);
}
get customPrimaryColour() {
return this._ccmpVehicle.customPrimaryColour;
}
get customSecondaryColour() {
return this._ccmpVehicle.customSecondaryColour;
}
setMod(modType, modIndex) {
this._ccmpVehicle.setMod(modType, modIndex);
}
getMod(modType) {
return this._ccmpVehicle.getMod(modType);
}
getNumMods(modType) {
return this._ccmpVehicle.getNumMods(modType);
}
setNeonLightEnabled(index, toggle) {
this._ccmpVehicle.setNeonLightEnabled(index, toggle);
}
setNeonLightsColour(color) {
this._ccmpVehicle.setNeonLightsColour(color);
}
setWindowTint(tintType) {
this._ccmpVehicle.setWindowTint(tintType);
}
get windowTint() {
return this._ccmpVehicle.windowTint;
}
setWheelType(wheelType) {
this._ccmpVehicle.setWheelType(wheelType);
}
get wheelType() {
return this._ccmpVehicle.wheelType;
}
setNumberPlateType(index) {
this._ccmpVehicle.setNumberPlateType(index);
}
get numberPlateType() {
return this._ccmpVehicle.numberPlateType;
}
setDoorOpen(doorIndex, loose, openInstantly) {
this._ccmpVehicle.setDoorOpen(doorIndex, loose, openInstantly);
}
setDoorShut(doorIndex, instantly) {
this._ccmpVehicle.setDoorShut(doorIndex, instantly);
}
setHandling(field, value) {
this._ccmpVehicle.setHandling(field, value);
}
getHandling(field) {
return this._ccmpVehicle.getHandling(field);
}
setEnginePowerMultiplier(value) {
this._ccmpVehicle.setEnginePowerMultiplier(value);
}
setEngineTorqueMultiplier(value) {
this._ccmpVehicle.setEngineTorqueMultiplier(value);
}
modifyTopSpeed(value) {
this._ccmpVehicle.modifyTopSpeed(value);
}
setCheatPowerIncrease(value) {
this._ccmpVehicle.setCheatPowerIncrease(value);
}
toggleMod(modType, toggle) {
this._ccmpVehicle.toggleMod(modType, toggle);
}
setTyreSmokeColor(r, g, b) {
this._ccmpVehicle.setTyreSmokeColor(r, g, b);
}
setModColor1(paintType, color, p3) {
this._ccmpVehicle.setModColor1(paintType, color, p3);
}
setExtraColours(pearlescentColor, wheelColor) {
this._ccmpVehicle.setExtraColours(pearlescentColor, wheelColor);
}
setHeadlightColor(colorIndex) {
this._ccmpVehicle.setHeadlightColor(colorIndex);
}
setDashboardColor(colorIndex) {
this._ccmpVehicle.setDashboardColor(colorIndex);
}
setInteriorColor(colorIndex) {
this._ccmpVehicle.setInteriorColor(colorIndex);
}
getMaxBraking() {
return this._ccmpVehicle.getMaxBraking();
}
getAcceleration() {
return this._ccmpVehicle.getAcceleration();
}
getMaxTraction() {
return this._ccmpVehicle.getMaxTraction();
}
getModelMaxSpeed() {
return this._ccmpVehicle.getModelMaxSpeed();
}
_normalizeHandle(value) {
const handle = Number(value);
return Number.isFinite(handle) && handle > 0 ? Math.trunc(handle) : 0;
}
_getRemoteVehicleExists() {
try {
return this._ccmpVehicle.isExists;
}
catch (_a) {
return true;
}
}
}