Added gameWon global event

This commit is contained in:
thepaperpilot 2022-03-11 17:26:39 -06:00
parent 563bf76bee
commit 1ecab3716e

View file

@ -1,7 +1,7 @@
import projInfo from "data/projInfo.json"; import projInfo from "data/projInfo.json";
import Decimal from "util/bignum"; import Decimal from "util/bignum";
import { createNanoEvents } from "nanoevents"; import { createNanoEvents } from "nanoevents";
import { App, Ref } from "vue"; import { App, Ref, watch } from "vue";
import { GenericLayer } from "./layers"; import { GenericLayer } from "./layers";
import player from "./player"; import player from "./player";
import settings, { Settings } from "./settings"; import settings, { Settings } from "./settings";
@ -12,6 +12,7 @@ export interface GlobalEvents {
removeLayer: (layer: GenericLayer) => void; removeLayer: (layer: GenericLayer) => void;
update: (diff: number, trueDiff: number) => void; update: (diff: number, trueDiff: number) => void;
loadSettings: (settings: Partial<Settings>) => void; loadSettings: (settings: Partial<Settings>) => void;
gameWon: VoidFunction;
setupVue: (vue: App) => void; setupVue: (vue: App) => void;
} }
@ -102,6 +103,11 @@ function update() {
export async function startGameLoop() { export async function startGameLoop() {
hasWon = (await import("data/projEntry")).hasWon; hasWon = (await import("data/projEntry")).hasWon;
watch(hasWon, hasWon => {
if (hasWon) {
globalBus.emit("gameWon");
}
});
if (settings.unthrottled) { if (settings.unthrottled) {
requestAnimationFrame(update); requestAnimationFrame(update);
} else { } else {