More refactoring of events

This commit is contained in:
Pax1601
2024-10-28 07:53:09 +01:00
parent 14c0a2f1e8
commit 7f5873b5b8
32 changed files with 1010 additions and 891 deletions

View File

@@ -6,6 +6,7 @@ import { SVGInjector } from "@tanem/svg-injector";
import { DLINK, DataIndexes, GAME_MASTER, IRST, OPTIC, RADAR, VISUAL } from "../constants/constants";
import { DataExtractor } from "../server/dataextractor";
import { ObjectIconOptions } from "../interfaces";
import { MapOptionsChangedEvent } from "../events";
export class Weapon extends CustomMarker {
ID: number;
@@ -50,9 +51,7 @@ export class Weapon extends CustomMarker {
this.ID = ID;
/* Update the marker when the options change */
document.addEventListener("mapOptionsChanged", (ev: CustomEventInit) => {
this.#updateMarker();
});
MapOptionsChangedEvent.on(() => this.#updateMarker());
}
getCategory() {

View File

@@ -3,6 +3,7 @@ import { Weapon } from "./weapon";
import { DataIndexes } from "../constants/constants";
import { DataExtractor } from "../server/dataextractor";
import { Contact } from "../interfaces";
import { CommandModeOptionsChangedEvent } from "../events";
/** The WeaponsManager handles the creation and update of weapons. Data is strictly updated by the server ONLY. */
export class WeaponsManager {
@@ -11,7 +12,7 @@ export class WeaponsManager {
constructor() {
this.#weapons = {};
document.addEventListener("commandModeOptionsChanged", () => {
CommandModeOptionsChangedEvent.on(() => {
Object.values(this.#weapons).forEach((weapon: Weapon) => weapon.updateVisibility());
});
}