UNPKG

rock-mod

Version:

Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.

47 lines (46 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RageEntity = void 0; const RageWorldObject_1 = require("../worldObject/RageWorldObject"); const utils_1 = require("../../../../shared/common/utils"); class RageEntity extends RageWorldObject_1.RageWorldObject { _rotation; get model() { return this.mpEntity.model; } get rotation() { const { x, y, z } = this._getEntityRotationProperty() ?? this._rotation ?? new utils_1.Vector3D(0, 0, 0); return new utils_1.Vector3D(x, y, z); } constructor(options) { super(options); this._rotation = options.rotation; } setModel(value) { this.mpEntity.model = mp.joaat(value); } setRotation(value) { this._rotation = value; this.mpEntity.rotation = new mp.Vector3(value); } getNetData(name) { return this.mpEntity.getVariable(name); } setNetData(name, value) { this.mpEntity.setVariable(name, value); } _getEntityRotationProperty() { const rotation = this.mpEntity.rotation; if (!this._isVectorLike(rotation)) return null; return rotation; } _isVectorLike(value) { return (typeof value === "object" && value !== null && typeof value.x === "number" && typeof value.y === "number" && typeof value.z === "number"); } } exports.RageEntity = RageEntity;