UNPKG

rock-mod

Version:

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

127 lines (126 loc) 3.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AltVVehicle = void 0; const AltVEntity_1 = require("../entity/AltVEntity"); var VehicleLockState = AltVShared.VehicleLockState; const utils_1 = require("../../../../shared/common/utils"); const RockMod_1 = require("../../../RockMod"); const Math_1 = require("../../../../shared/common/utils/math/Math"); class AltVVehicle extends AltVEntity_1.AltVEntity { static _minColorId = 0; static _maxColorId = 159; get bodyHealth() { return this.mpEntity.bodyHealth; } get engineHealth() { return this.mpEntity.engineHealth; } get numberPlate() { return this.mpEntity.numberPlateText; } get isLocked() { return this.mpEntity.lockState > 1; } get isDead() { return this.mpEntity.destroyed; } get primaryColor() { return this.mpEntity.primaryColor; } get secondaryColor() { return this.mpEntity.secondaryColor; } get customPrimaryColor() { const { r, g, b, a } = this.mpEntity.customPrimaryColor; return new utils_1.RGBA(r, g, b, a); } get customSecondaryColor() { const { r, g, b, a } = this.mpEntity.customSecondaryColor; return new utils_1.RGBA(r, g, b, a); } get driver() { const mpPlayer = this.mpEntity.driver; if (!mpPlayer) { return null; } return RockMod_1.RockMod.instance.players.getByID(mpPlayer.id); } get passengers() { const players = new Set(); for (const mpPlayer of Object.values(this.mpEntity.passengers)) { 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; } setEngineOn(value) { this.mpEntity.engineOn = value; } setEngineHealth(value) { this.mpEntity.engineHealth = value; } setNumberPlate(value) { this.mpEntity.numberPlateText = value; } setLocked(value) { this.mpEntity.lockState = value ? VehicleLockState.Locked : VehicleLockState.Unlocked; } setPrimaryColor(value) { this.mpEntity.primaryColor = AltVVehicle._clampColorId(value); } setSecondaryColor(value) { this.mpEntity.secondaryColor = AltVVehicle._clampColorId(value); } setCustomPrimaryColor(value) { const { r, g, b, a } = value; this.mpEntity.customPrimaryColor = new AltVShared.RGBA(r, g, b, a); } setCustomSecondaryColor(value) { const { r, g, b, a } = value; this.mpEntity.customSecondaryColor = new AltVShared.RGBA(r, g, b, a); } setMod(modType, modIndex) { this.mpEntity.setMod(modType, modIndex); } getMod(modType) { return this.mpEntity.getMod(modType); } setNeonEnabled(enabled) { this.mpEntity.neon = { ...this.mpEntity.neon, left: enabled, right: enabled, front: enabled, back: enabled, }; } setNeonColor(r, g, b) { this.mpEntity.neonColor = new AltVShared.RGBA(r, g, b); } setWindowTint(tintType) { this.mpEntity.windowTint = tintType; } setWheelType(wheelType) { this.mpEntity.setWheels(wheelType, 0); } setPlateType(plateType) { this.mpEntity.numberPlateIndex = plateType; } explode() { this.mpEntity.engineHealth = 0; this.mpEntity.bodyHealth = 0; } repair() { return this.mpEntity.repair(); } static _clampColorId(value) { return (0, Math_1.MathClamp)(value, AltVVehicle._minColorId, AltVVehicle._maxColorId); } } exports.AltVVehicle = AltVVehicle;