import { State } from "./State"; import { Container, Spritesheet, Texture as PIXITexture, Ticker as PIXITicker, SCALE_MODE } from "pixi.js"; import { RenderManager } from "./RenderManager"; import { TWhiskerConfig } from "../config/whiskerConfig"; import { PlatformSDK } from "./PlatformSDKs/PlatformSDK"; import { SaveHandler } from "./Savers/SaveHandler"; import { GameObject } from "./GameObject"; import { LoaderType } from "./Loaders/LoaderType"; import InputManager from "./InputManager"; declare global { const ENGINE: Engine; } type TAutoResize = "either" | "width" | "height" | "none"; export declare class Engine { private readonly ticker; private readonly stateManager; private readonly loader; private readonly jsonLoader; private readonly wasmLoader; private readonly renderManager; private readonly stage; private readonly inputManager; private saveHandler; private analyticsHandler; private platformSdk; private fpsDisplay; private readonly loadtimeMeasurer; /** * If true, pauses tickers/rendering when window loses focus */ pauseOnFocusLoss: boolean; /** * Whether to auto-resize the renderer when the window changes size, and how */ autoResize: TAutoResize; /** * The loading screen object to instantiate when loading states */ loadingScreenObject: GameObject | null; private dt; private _scaleFactor; private _pauseRendering; private _onErrorFunctions; private _onPromiseRejectionFunctions; private _loadAssetsPromise; private _adjustHeightForBannerAd; constructor(); getRenderManager(): RenderManager; hasJSON(key: string): boolean; getJSON(key: string): T; getTicker(): PIXITicker; getStage(): Container; get scaleFactor(): number; get platformSDK(): PlatformSDK; getInputManager(): InputManager; getSaveHandler(): SaveHandler; get renderingPaused(): boolean; set renderingPaused(val: boolean); get deltaTime(): number; set deltaTime(dt: number); /** * @deprecated Shouldn't use * @private */ private _getPlayerDataSingleton; /** * @returns True if the asset is loaded, false if it's not * @param _key */ isPIXIAssetLoaded(_key: string): boolean; /** * Initializes the analytics handler */ initializeAnalytics(): void; /** * Get a loaded WASM module from cache */ getWASM(_key: string): T | null; /** * Get a loaded PIXI texture from cache * @param _key */ getTexture(_key: string): PIXITexture; /** * Sets the scale mode for the renderer * @deprecated Not yet implemented as of PIXI v8 upgrade * @param scaleMode "nearest" or "linear" */ setScaleMode(scaleMode: SCALE_MODE): void; /** * Returns true if any loaders are loading */ isLoaderLoading(): boolean; /** * Initializes the Firebase analytics module with the analytics handler */ initializeFirebaseAnalytics(): void; /** * Gets the currently-loaded state from StateManager */ getActiveState(): State; /** * Requests haptic feedback from the platform SDK, returns true if successful */ requestHapticFeedback(): Promise; /** * Tracks the initial load time of the game * @deprecated Not currently working */ trackInitialLoadTime(): Promise; /** * Hooks a function to be called when an unhandled error occurs * @param _func */ hookOnError(_func: typeof window.onerror): void; /** * Hooks a function to be called when an unhandled promise rejection occurs * @param _func */ hookOnPromiseRejection(_func: (ev: PromiseRejectionEvent) => void): void; /** * Resizes the renderer to the specified width and height * For people who know what they're doing, otherwise use `autoResize` * @param _w * @param _h * @param _autoResizeVal */ resizeRenderer(_w: number, _h: number, _autoResizeVal?: TAutoResize): void; /** * Unloads the current state and loads the specified state * @param _newState * @param _params Parameters to pass to the new state */ changeState(_newState: State, _params?: unknown): Promise; /** * Forces a frame render */ forceRender(): void; /** * Sets the refresh rate of the ticker/renderer * @param fps */ setMaxFPS(fps: number): void; /** * Sets the background colour of the renderer/canvas * @param _col * @param _alpha (optional) */ setBackgroundColor(_col: number, _alpha?: number): void; /** * Helper function for if a PIXI resource is loaded; also checks if it loaded with error * @param key */ hasPIXIResource(key: string): boolean; /** * Gets the specified PIXI resource from the loader, if it exists * @param key * @returns The PIXI texure/spritesheet, or undefined if it doesn't exist */ getPIXIResource(key: string): PIXITexture | Spritesheet; /** * Manually adds the specified asset to the PIXI loader cache * For people who know what they're doing. * @param key * @param asset */ cachePIXIResource(key: string, asset: any): void; /** * Unloads the specified asset from the PIXI loader cache * @param key */ unloadPIXIResource(key: string): void; /** * Records a loadtime event * @deprecated Not yet properly implemented * @param _name * @param _force */ recordLoadtime(_name?: string, _force?: boolean): Promise; /** * `window.alert`s the loadtime as a string, for debugging */ alertLoadtime(): void; /** * Exports the loadtime as a string, for debugging */ exportLoadtimeAsString(): string; /** * Function that is called when a resize event is called, or to force a resize */ onResize(): void; /** * Processes a spritesheet and adds its textures to the PIXI loader cache * @param _spritesheet * @returns True on success, false on failure */ processSpritesheet(_spritesheet: Spritesheet): boolean; /** * Logs an analytics event with the analytics handler * @param eventName * @param valueToSum * @param parameters */ logEvent(eventName: string, valueToSum?: number, parameters?: { [key: string]: string; }): void; /** * Main initialization function for the engine * @param _initialState State to load into * @param _config Configuration object for engine * @param _onProgress (optional) Callback for loading progress */ init(_initialState: State, _config: TWhiskerConfig, _onProgress?: (_val: number) => void): Promise; /** * Loads the specified assets using the specified loaders * @param _assets * @param _onProgress (optional) Callback for loading progress */ loadAssets(_assets: Array<{ key: string; path: string; type: LoaderType; }>, _onProgress?: (_prog: number) => void): Promise; private static hideFontPreload; private hookResize; private _setupHookOnError; private readonly mainLoop; } export {};