UNPKG

rock-mod

Version:

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

113 lines (112 loc) 3.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MockVehicle = void 0; const MockEntity_1 = require("../entity/MockEntity"); const utils_1 = require("../../../../shared/common/utils"); const Math_1 = require("../../../../shared/common/utils/math/Math"); class MockVehicle extends MockEntity_1.MockEntity { _bodyHealth; _engineHealth; _engineOn; _numberPlate; _isLocked; _isDead; _primaryColor; _secondaryColor; _customPrimaryColor; _customSecondaryColor; _passengers; get bodyHealth() { return this._bodyHealth; } get engineHealth() { return this._engineHealth; } get engineOn() { return this._engineOn; } get numberPlate() { return this._numberPlate; } get isLocked() { return this._isLocked; } get isDead() { return this._isDead; } get primaryColor() { return this._primaryColor; } get secondaryColor() { return this._secondaryColor; } get customPrimaryColor() { const { r, g, b, a = 255 } = this._customPrimaryColor; return new utils_1.RGBA(r, g, b, a); } get customSecondaryColor() { const { r, g, b, a } = this._customSecondaryColor; return new utils_1.RGBA(r, g, b, a); } get driver() { for (const passenger of this._passengers.values()) { if (passenger.seat === 0) { return passenger; } } return null; } get passengers() { return this._passengers; } constructor(options) { super(options); this._engineOn = options.engine ?? false; this._bodyHealth = 1000; this._engineHealth = 1000; this._numberPlate = ""; this._isLocked = options.locked ?? false; this._isDead = false; this._primaryColor = 0; this._secondaryColor = 0; this._customPrimaryColor = new utils_1.RGBA(0, 0, 0); this._customSecondaryColor = new utils_1.RGBA(0, 0, 0); this._passengers = new Set(); } setBodyHealth(value) { this._bodyHealth = value; } setEngineHealth(value) { this._engineHealth = (0, Math_1.MathClamp)(value, 0, 1000); } setEngineOn(value) { this._engineOn = value; } setNumberPlate(value) { this._numberPlate = value; } setLocked(value) { this._isLocked = value; } setPrimaryColor(value) { this._primaryColor = value; } setSecondaryColor(value) { this._secondaryColor = value; } setCustomPrimaryColor(value) { this._customPrimaryColor = value; } setCustomSecondaryColor(value) { this._customSecondaryColor = value; } explode() { this.setBodyHealth(0); this.setEngineHealth(0); } repair() { this.setBodyHealth(1000); this.setEngineHealth(1000); } } exports.MockVehicle = MockVehicle;