UNPKG

rock-mod

Version:

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

117 lines (116 loc) 3.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RageVehicle = void 0; const RageEntity_1 = require("../entity/RageEntity"); const utils_1 = require("../../../../shared/common/utils"); const RockMod_1 = require("../../../RockMod"); const Math_1 = require("../../../../shared/common/utils/math/Math"); class RageVehicle extends RageEntity_1.RageEntity { static _minColorId = 0; static _maxColorId = 159; get bodyHealth() { return this.mpEntity.bodyHealth; } get engineHealth() { return this.mpEntity.engineHealth; } get numberPlate() { return this.mpEntity.numberPlate; } get isLocked() { return this.mpEntity.locked; } get isDead() { return this.mpEntity.dead; } get primaryColor() { return this.mpEntity.getColor(0); } get secondaryColor() { return this.mpEntity.getColor(1); } get customPrimaryColor() { const [r, g, b] = this.mpEntity.getColorRGB(0) ?? [0, 0, 0]; return new utils_1.RGBA(r, g, b); } get customSecondaryColor() { const [r, g, b] = this.mpEntity.getColorRGB(1) ?? [0, 0, 0]; return new utils_1.RGBA(r, g, b); } get driver() { const mpPlayer = this.mpEntity.getOccupant(0); if (!mpPlayer) { return null; } return RockMod_1.RockMod.instance.players.getByID(mpPlayer.id); } get passengers() { const players = new Set(); for (const mpPlayer of this.mpEntity.getOccupants()) { const player = RockMod_1.RockMod.instance.players.getByID(mpPlayer.id); players.add(player); } return players; } constructor(options) { super(options); } setBodyHealth(value) { this.mpEntity.bodyHealth = value; } setEngineHealth(value) { throw new Error(`Not implemented (setEngineHealth: ${value})`); } setNumberPlate(value) { this.mpEntity.numberPlate = value; } setLocked(value) { this.mpEntity.locked = value; } setEngineOn(value) { this.mpEntity.engine = value; } setPrimaryColor(value) { return this.mpEntity.setColor(RageVehicle._clampColorId(value), this.secondaryColor); } setSecondaryColor(value) { return this.mpEntity.setColor(this.primaryColor, RageVehicle._clampColorId(value)); } setCustomPrimaryColor(value) { this.mpEntity.setColorRGB(value.r, value.g, value.b, this.customSecondaryColor.r, this.customSecondaryColor.g, this.customSecondaryColor.b); } setCustomSecondaryColor(value) { this.mpEntity.setColorRGB(this.customPrimaryColor.r, this.customPrimaryColor.g, this.customPrimaryColor.b, value.r, value.g, value.b); } setMod(modType, modIndex) { this.mpEntity.setMod(modType, modIndex); } getMod(modType) { return this.mpEntity.getMod(modType); } setNeonEnabled(enabled) { this.mpEntity.neonEnabled = enabled; } setNeonColor(r, g, b) { this.mpEntity.setNeonColor(r, g, b); } setWindowTint(tintType) { this.mpEntity.windowTint = tintType; } setWheelType(wheelType) { this.mpEntity.wheelType = wheelType; } setPlateType(plateType) { this.mpEntity.numberPlateType = plateType; } explode() { return this.mpEntity.explode(); } repair() { return this.mpEntity.repair(); } static _clampColorId(value) { return (0, Math_1.MathClamp)(value, RageVehicle._minColorId, RageVehicle._maxColorId); } } exports.RageVehicle = RageVehicle;