mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36: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 closestPoint: Point | undefined;
|
||||||
let tick: number | undefined;
|
let tick: number | undefined;
|
||||||
|
|
||||||
interface LibPoint {
|
interface LibPoint<T = unknown> {
|
||||||
coords: number[];
|
coords: number[];
|
||||||
distance: number;
|
distance: number;
|
||||||
onEnter?: () => void;
|
onEnter?: () => void;
|
||||||
onExit?: () => void;
|
onExit?: () => void;
|
||||||
nearby?: () => void;
|
nearby?: () => void;
|
||||||
|
args?: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Point {
|
export class Point<T = unknown> {
|
||||||
id: number = 0;
|
id: number = 0;
|
||||||
coords: Vector3;
|
coords: Vector3;
|
||||||
distance: number = 0;
|
distance: number = 0;
|
||||||
onEnter?: () => void;
|
onEnter?: () => void;
|
||||||
onExit?: () => void;
|
onExit?: () => void;
|
||||||
nearby?: () => void;
|
nearby?: () => void;
|
||||||
|
args?: T;
|
||||||
inside: boolean = false;
|
inside: boolean = false;
|
||||||
currentDistance?: number;
|
currentDistance?: number;
|
||||||
isClosest: boolean = false;
|
isClosest: boolean = false;
|
||||||
|
|
||||||
constructor(point: LibPoint) {
|
constructor(point: LibPoint<T>) {
|
||||||
this.id = points.length + 1;
|
this.id = points.length + 1;
|
||||||
this.coords = Vector3.fromArray(point.coords);
|
this.coords = Vector3.fromArray(point.coords);
|
||||||
this.distance = point.distance;
|
this.distance = point.distance;
|
||||||
this.onEnter = point.onEnter;
|
this.onEnter = point.onEnter;
|
||||||
this.onExit = point.onExit;
|
this.onExit = point.onExit;
|
||||||
this.nearby = point.nearby;
|
this.nearby = point.nearby;
|
||||||
|
this.args = point.args;
|
||||||
points.push(this);
|
points.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user