mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-15 17:33:56 +00:00
perf(package): don't run points interval if there are no points
This commit is contained in:
1 parent
b6af7e7166
commit
8b39f630fd
1 file changed
+11
-1
@@ -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