UNPKG

rock-mod

Version:

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

41 lines (40 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CCMPWorldObjectsIterator = void 0; const CCMPBaseObjectsIterator_1 = require("../baseObject/CCMPBaseObjectsIterator"); class CCMPWorldObjectsIterator extends CCMPBaseObjectsIterator_1.CCMPBaseObjectsIterator { constructor(baseObjects) { super(baseObjects); } *dimension(value) { for (const worldObject of this.all()) { if (worldObject.dimension === value) { yield worldObject; } } } *range2D(center, range) { const rangeSquared = range * range; for (const worldObject of this.all()) { const { x, y } = worldObject.position; const dx = center.x - x; const dy = center.y - y; if (dx * dx + dy * dy <= rangeSquared) { yield worldObject; } } } *range3D(center, range) { const rangeSquared = range * range; for (const worldObject of this.all()) { const { x, y, z } = worldObject.position; const dx = center.x - x; const dy = center.y - y; const dz = center.z - z; if (dx * dx + dy * dy + dz * dz <= rangeSquared) { yield worldObject; } } } } exports.CCMPWorldObjectsIterator = CCMPWorldObjectsIterator;