refactor(package): use generics to type point args

This commit is contained in:
Luke
2023-02-20 17:25:12 +01:00
parent 7ff9f93838
commit 7520509da3

View File

@@ -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);
}