mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
refactor(package): use generics to type point args
This commit is contained in:
@@ -6,32 +6,35 @@ let nearbyCount: number = 0;
|
||||
let closestPoint: Point | undefined;
|
||||
let tick: number | undefined;
|
||||
|
||||
interface LibPoint {
|
||||
interface LibPoint<T = unknown> {
|
||||
coords: number[];
|
||||
distance: number;
|
||||
onEnter?: () => void;
|
||||
onExit?: () => void;
|
||||
nearby?: () => void;
|
||||
args?: T;
|
||||
}
|
||||
|
||||
export class Point {
|
||||
export class Point<T = unknown> {
|
||||
id: number = 0;
|
||||
coords: Vector3;
|
||||
distance: number = 0;
|
||||
onEnter?: () => void;
|
||||
onExit?: () => void;
|
||||
nearby?: () => void;
|
||||
args?: T;
|
||||
inside: boolean = false;
|
||||
currentDistance?: number;
|
||||
isClosest: boolean = false;
|
||||
|
||||
constructor(point: LibPoint) {
|
||||
constructor(point: LibPoint<T>) {
|
||||
this.id = points.length + 1;
|
||||
this.coords = Vector3.fromArray(point.coords);
|
||||
this.distance = point.distance;
|
||||
this.onEnter = point.onEnter;
|
||||
this.onExit = point.onExit;
|
||||
this.nearby = point.nearby;
|
||||
this.args = point.args;
|
||||
points.push(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user