rock-mod
Version:
Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.
150 lines (149 loc) • 5.05 kB
JavaScript
import { BaseObjectType } from "../../../../shared/entities";
import { Vector3D } from "../../../../shared/common/utils";
export class CCMPObject {
constructor(_ccmpObject, _onDestroy = () => { }) {
this._ccmpObject = _ccmpObject;
this._onDestroy = _onDestroy;
this._destroyed = false;
}
get id() {
return this._ccmpObject.id;
}
get remoteId() {
return this._ccmpObject.remoteId;
}
get type() {
return BaseObjectType.Object;
}
get isExists() {
return !this._destroyed && this._ccmpObject.isExists;
}
get handle() {
return this._normalizeHandle(this._ccmpObject.handle);
}
destroy() {
if (this._destroyed)
return;
this._destroyed = true;
this._ccmpObject.destroy();
this._onDestroy(this);
}
get position() {
const { x, y, z } = this._ccmpObject.position;
return new Vector3D(x, y, z);
}
get dimension() {
return this._ccmpObject.dimension;
}
setPosition(value) {
this._ccmpObject.setPosition(value);
}
setDimension(value) {
this._ccmpObject.setDimension(value);
}
setCoords(xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea) {
this._ccmpObject.setCoords(xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea);
}
get model() {
return this._ccmpObject.model;
}
get heading() {
return this._ccmpObject.heading;
}
setHeading(heading) {
this._ccmpObject.setHeading(heading);
}
setModel(value) {
this._ccmpObject.setModel(value);
}
get rotation() {
const { x, y, z } = this._ccmpObject.rotation;
return new Vector3D(x, y, z);
}
get forwardVector() {
const { x, y, z } = this._ccmpObject.forwardVector;
return new Vector3D(x, y, z);
}
setRotation(value) {
this._ccmpObject.setRotation(value);
}
freezePosition(freeze) {
this._ccmpObject.freezePosition(freeze);
}
setCollision(collision, keepPhysics) {
this._ccmpObject.setCollision(collision, keepPhysics);
}
setInvincible(invincible) {
this._ccmpObject.setInvincible(invincible);
}
setVisible(visible) {
this._ccmpObject.setVisible(visible);
}
setAlpha(alpha) {
this._ccmpObject.setAlpha(alpha);
}
get alpha() {
return this._ccmpObject.alpha;
}
resetAlpha() {
this._ccmpObject.resetAlpha();
}
getOffsetFromInWorldCoords(offsetX, offsetY, offsetZ) {
const { x, y, z } = this._ccmpObject.getOffsetFromInWorldCoords(offsetX, offsetY, offsetZ);
return new Vector3D(x, y, z);
}
getBoneIndexByName(boneName) {
return this._ccmpObject.getBoneIndexByName(boneName);
}
getWorldPositionOfBone(boneIndex) {
const { x, y, z } = this._ccmpObject.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.Object, 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.Object, remoteId, key);
}
hasSyncedMeta(key) {
const remoteId = this.remoteId;
if (remoteId === null)
return false;
return ccmp.entities.hasStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Object, remoteId, key);
}
getSyncedMetaKeys() {
const remoteId = this.remoteId;
if (remoteId === null)
return [];
return ccmp.entities.getStreamSyncedMetaKeys(ccmp.entities.ENTITY_TYPE.Object, remoteId);
}
attachTo(entity, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, useSoftPinning, collision, isPed, vertexIndex, fixedRot) {
this._ccmpObject.attachTo(entity, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
}
isAttachedTo(entity) {
return this._ccmpObject.isAttachedTo(entity);
}
attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot) {
this._ccmpObject.attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
}
detach(useDetachVelocity, collision) {
this._ccmpObject.detach(useDetachVelocity, collision);
}
getSpeed() {
return this._ccmpObject.getSpeed();
}
isPlayingAnim(dictionary, name, taskFlag) {
return this._ccmpObject.isPlayingAnim(dictionary, name, taskFlag);
}
_normalizeHandle(value) {
const handle = Number(value);
return Number.isFinite(handle) && handle > 0 ? Math.trunc(handle) : 0;
}
}