Skip to content

Commit

Permalink
feat: text draw skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Sep 13, 2022
1 parent fb68389 commit 6209d1e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/controllers/textdraw/basePlayerTextDraw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { BaseTextDraw } from "./baseTextDraw";

export abstract class BasePlayerTextDraw extends BaseTextDraw {}
1 change: 1 addition & 0 deletions src/controllers/textdraw/baseTextDraw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export abstract class BaseTextDraw {}
3 changes: 3 additions & 0 deletions src/controllers/textdraw/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./baseTextDraw";
export * from "./basePlayerTextDraw";
export * from "./textdrawEvent";
8 changes: 8 additions & 0 deletions src/controllers/textdraw/textdrawBus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { EventBus } from "@/utils/eventBus";

export enum textDrawHooks {
created = "OnTextDrawCreate",
destroyed = "OnTextDrawDestroy",
}

export const textDrawBus = new EventBus();
22 changes: 22 additions & 0 deletions src/controllers/textdraw/textdrawEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CommonTextDraw } from "@/interfaces";
import { BasePlayerTextDraw } from "./basePlayerTextDraw";
import { BaseTextDraw } from "./baseTextDraw";
import { textDrawBus, textDrawHooks } from "./textdrawBus";

export abstract class BaseTextDrawEvent<
T extends BaseTextDraw,
PT extends BasePlayerTextDraw
> {
public readonly textDraws = new Set<CommonTextDraw<T, PT>>();
constructor() {
textDrawBus.on(textDrawHooks.created, (textDraw: CommonTextDraw<T, PT>) => {
this.textDraws.add(textDraw);
});
textDrawBus.on(
textDrawHooks.destroyed,
(textDraw: CommonTextDraw<T, PT>) => {
this.textDraws.delete(textDraw);
}
);
}
}
11 changes: 11 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BasePlayerTextDraw } from "@/controllers/textdraw/basePlayerTextDraw";
import { BaseTextDraw } from "@/controllers/textdraw/baseTextDraw";
import { DialogStylesEnum } from "../enums";
import { EventFunc, EventName } from "../types";

Expand Down Expand Up @@ -65,3 +67,12 @@ export interface IBaseGangZone {
maxx: number;
maxy: number;
}

export interface CommonTextDraw<
T extends BaseTextDraw,
PT extends BasePlayerTextDraw
> {
id: number;
global: boolean;
value: T | PT;
}

0 comments on commit 6209d1e

Please sign in to comment.