rock-mod
Version:
Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.
83 lines (82 loc) • 2.39 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CCMPPed = void 0;
const CCMPEntity_1 = require("../entity/CCMPEntity");
const shared_1 = require("../../../../shared");
const Vectors_1 = require("../../../../shared/common/utils/math/Vectors");
const Math_1 = require("../../../../shared/common/utils/math/Math");
const RockMod_1 = require("../../../RockMod");
class CCMPPed extends CCMPEntity_1.CCMPEntity {
_ccmpPed;
_onDestroy;
get id() {
return this._ccmpPed.id;
}
get type() {
return shared_1.BaseObjectType.Ped;
}
get isExists() {
return this._ccmpPed.isExists;
}
get position() {
const p = this._ccmpPed.position;
return new Vectors_1.Vector3D(p.x, p.y, p.z);
}
get dimension() {
return this._ccmpPed.dimension;
}
get model() {
return this._ccmpPed.model;
}
// CCMP exposes only heading; map it onto rotation.z.
get rotation() {
return new Vectors_1.Vector3D(0, 0, this._ccmpPed.heading);
}
get heading() {
return this._ccmpPed.heading;
}
get health() {
return this._ccmpPed.health;
}
get armour() {
return this._ccmpPed.armour;
}
get ccmpMeta() {
return this._ccmpPed;
}
constructor(options) {
super();
this._ccmpPed = options.ccmpPed;
this._onDestroy = options.onDestroy;
}
destroy() {
if (!this._ccmpPed.isExists)
return;
this._ccmpPed.destroy();
this._onDestroy(this);
}
setPosition(value) {
this._ccmpPed.teleport(value.x, value.y, value.z);
}
setDimension(value) {
this._ccmpPed.dimension = value;
}
setModel(value) {
// CCMP ped.model is u32; hash the name via the shared util before assignment.
this._ccmpPed.model = RockMod_1.RockMod.instance.utils.hash(value);
}
setRotation(value) {
// CCMP exposes only heading; pitch/roll (x/y) are silently dropped.
this._ccmpPed.heading = value.z;
}
setHeading(value) {
this._ccmpPed.heading = value;
}
setHealth(value) {
this._ccmpPed.health = (0, Math_1.MathClamp)(value, 0, 200);
}
setArmour(value) {
this._ccmpPed.armour = (0, Math_1.MathClamp)(value, 0, 100);
}
}
exports.CCMPPed = CCMPPed;