UNPKG

rock-mod

Version:

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

36 lines (35 loc) 1.12 kB
import { RageEntitiesManager } from "../entity/RageEntitiesManager"; import { RagePed } from "./RagePed"; export class RagePedsManager extends RageEntitiesManager { constructor() { super({ baseObjectsType: "ped", }); } create(options) { const { model, position, dimension, rotation } = options; const mpEntity = mp.peds.new(mp.game.joaat(model), new mp.Vector3(position), rotation.z, dimension); mpEntity.isExists = () => mp.peds.exists(mpEntity); const ped = new RagePed({ mpEntity }); this.registerBaseObject(ped); return ped; } syncWithMpPool() { for (const mpPed of mp.peds.toArray()) { this.registerById(mpPed.id); } } registerById(id) { const existingPed = this.findByID(id); if (existingPed) { return existingPed; } const mpPed = mp.peds.at(id); mpPed.isExists = () => mp.peds.exists(mpPed); const ped = new RagePed({ mpEntity: mpPed, }); this.registerBaseObject(ped); return ped; } }