mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +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 = () => {
|
||||
const coords = Vector3.fromArray(GetEntityCoords(cache.ped, false));
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
if (points.length < 1) return;
|
||||
|
||||
if (nearbyCount !== 0) {
|
||||
nearbyPoints = [];
|
||||
nearbyCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user