mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
perf(package): don't run points interval if there are no points
This commit is contained in:
@@ -42,12 +42,22 @@ export class Point<T = unknown> {
|
|||||||
remove = () => {
|
remove = () => {
|
||||||
const coords = Vector3.fromArray(GetEntityCoords(cache.ped, false));
|
const coords = Vector3.fromArray(GetEntityCoords(cache.ped, false));
|
||||||
const distance = coords.distance(this.coords);
|
const distance = coords.distance(this.coords);
|
||||||
if (distance < this.distance && this.onExit) this.onExit();
|
if (distance < this.distance) {
|
||||||
|
this.onExit && this.onExit();
|
||||||
|
nearbyCount -= 1;
|
||||||
|
nearbyPoints = nearbyPoints.filter((point) => point.id !== this.id);
|
||||||
|
if (nearbyCount === 0 && tick) {
|
||||||
|
clearTick(tick);
|
||||||
|
tick = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
points = points.filter((point) => point.id !== this.id);
|
points = points.filter((point) => point.id !== this.id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
if (points.length < 1) return;
|
||||||
|
|
||||||
if (nearbyCount !== 0) {
|
if (nearbyCount !== 0) {
|
||||||
nearbyPoints = [];
|
nearbyPoints = [];
|
||||||
nearbyCount = 0;
|
nearbyCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user