// SPDX-FileCopyrightText: 2026 Paula Wisnievski // SPDX-License-Identifier: AGPL-3.0-or-later // cubi/engine: engine access, for what the game api doesn't cover yet. a mod needs "engine_access": true and a // game_version within one minor version in its manifest. see docs/modding/misc/engine.md // // this is bundled into each mod that imports it, so it only imports types: the engine and hook are the game's own, // read from the global the game sets up before it loads mods import type { EngineGlobal, Hook } from "../hooks.ts"; import type { common_engine } from "../engine_modules.ts"; import type { server_engine } from "../../server/game/engine_modules.ts"; import type { client_engine } from "../../client/engine_modules.ts"; export type { HookHandlers } from "../hooks.ts"; // the engine's live classes and objects. common is on every side, server only in server phases, client only in // client phases export interface Engine { common: ReturnType; server: ReturnType; client: ReturnType; } const api = (globalThis as unknown as Record)["__cubi_engine"]; if (!api) throw new Error("cubi/engine only works in a mod's script, loaded by the game"); api.check_access(); export const engine = api.engine as Engine; // the version of the game that's running, like "0.4.2" export const game_version: string = api.version; // hooks a method of target, usually a class's prototype, so every instance already made changes too. returns a // function that unhooks it export const hook: Hook = api.hook;