Skip to content

Commit

Permalink
fix: adjust marker type to support string names, and numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Jun 16, 2024
1 parent 2b36c0c commit 8bb9b28
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 49 deletions.
6 changes: 5 additions & 1 deletion src/main/server/controllers/markers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as alt from 'alt-server';
import * as Utility from '@Shared/utility/index.js';
import { Marker } from '@Shared/types/marker.js';
import { Marker, MarkerType } from '@Shared/types/marker.js';
import { Events } from '@Shared/events/index.js';

const GroupType = 'marker';
Expand All @@ -16,6 +16,10 @@ const markerGroup = new alt.VirtualEntityGroup(MAX_MARKERS);
* @return
*/
export function useMarkerGlobal(marker: Marker, maxDistance: number = 50) {
if (typeof marker.type !== 'number') {
marker.type = MarkerType[marker.type];
}

if (maxDistance > 50) {
maxDistance = 50;
}
Expand Down
99 changes: 51 additions & 48 deletions src/main/shared/types/marker.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
import * as alt from 'alt-shared';

export enum MarkerType {
UPSIDE_DOWN_CONE = 0,
CYLINDER = 1,
CHEVRON_UP = 2,
THIN_CHEVRON_UP = 3,
CHECKERED_FLAG = 4,
CHECKERED_FLAG_CIRCLE = 5,
VERTICLE_CIRCLE = 6,
PLANE_MODEL = 7,
LOST_MC = 8,
LOST_MC_SOLID = 9,
NUMBER_0 = 10,
NUMBER_1 = 11,
NUMBER_2 = 12,
NUMBER_3 = 13,
NUMBER_4 = 14,
NUMBER_5 = 15,
NUMBER_6 = 16,
NUMBER_7 = 17,
NUMBER_8 = 18,
NUMBER_9 = 19,
CHEVRON_UP_SINGLE = 20,
CHEVRON_UP_DOUBLE = 21,
CHEVRON_UP_TRIPLE = 22,
FLAT_CIRCLE = 23,
REPLAY = 24,
FLAT_CIRCLE_SKINNY = 25,
FLAT_CIRCLE_SKINNY_DIRECTIONAL = 26,
FLAT_CIRCLE_SKINNY_SPLIT = 27,
SPHERE = 28,
DOLLAR_SIGN = 29,
HORIZONTAL_BARS = 30,
WOLF_HEAD = 31,
QUESTION = 32,
PLANE = 33,
HELICOPTER = 34,
BOAT = 35,
CAR = 36,
MOTORCYCLE = 37,
BIKE = 38,
TRUCK = 39,
PARACHUTE = 40,
JETPACK = 41,
SAW_BLADE = 42,
FLAT_VERTICAL_GRADIENT = 43,
}
export const MarkerType = {
UPSIDE_DOWN_CONE: 0,
CYLINDER: 1,
CHEVRON_UP: 2,
THIN_CHEVRON_UP: 3,
CHECKERED_FLAG: 4,
CHECKERED_FLAG_CIRCLE: 5,
VERTICLE_CIRCLE: 6,
PLANE_MODEL: 7,
LOST_MC: 8,
LOST_MC_SOLID: 9,
NUMBER_0: 10,
NUMBER_1: 11,
NUMBER_2: 12,
NUMBER_3: 13,
NUMBER_4: 14,
NUMBER_5: 15,
NUMBER_6: 16,
NUMBER_7: 17,
NUMBER_8: 18,
NUMBER_9: 19,
CHEVRON_UP_SINGLE: 20,
CHEVRON_UP_DOUBLE: 21,
CHEVRON_UP_TRIPLE: 22,
FLAT_CIRCLE: 23,
REPLAY: 24,
FLAT_CIRCLE_SKINNY: 25,
FLAT_CIRCLE_SKINNY_DIRECTIONAL: 26,
FLAT_CIRCLE_SKINNY_SPLIT: 27,
SPHERE: 28,
DOLLAR_SIGN: 29,
HORIZONTAL_BARS: 30,
WOLF_HEAD: 31,
QUESTION: 32,
PLANE: 33,
HELICOPTER: 34,
BOAT: 35,
CAR: 36,
MOTORCYCLE: 37,
BIKE: 38,
TRUCK: 39,
PARACHUTE: 40,
JETPACK: 41,
SAW_BLADE: 42,
FLAT_VERTICAL_GRADIENT: 43,
};

export type Marker = {
export type MarkerBase = {
uid?: string;
type: MarkerType;
pos: alt.IVector3;
scale: alt.IVector3;
color: alt.RGBA;
dimension?: number;
};

export type Marker = {
type: number | keyof typeof MarkerType;
} & MarkerBase;

0 comments on commit 8bb9b28

Please sign in to comment.