UNPKG

react-simple-game-engine

Version:

[WIP] not able to use in currently. <!-- Document cumming soon... -->

109 lines 4.71 kB
import { ComponentType, ReactElement } from "react"; import { LogicComponent } from "./logic-component"; import { SceneManagement } from "./scene-management"; import { WorldManagement } from "./world-management"; import { EntitySuit } from "./entities/entity-suit"; import { Prefab } from "./prefab"; import { Sound } from "./sound"; import { AssetErrorType, AssetsFailBehavior, Avatar, GetSoundOptions, JoystickAction, SoundManagement } from "../export-types"; import { SoundType } from "../export-enums"; import { SimpleCamera } from "./simple-camera"; import { P5 } from "./p5"; import { TouchEvent } from "../ui-components/movement-control"; declare type SoundOptionsChangeListener<O extends SoundType> = (options: SoundManagement[O]) => void; declare type LoadAssetsListener = (loadedAssets: boolean, errors?: { type: AssetErrorType; detail: any; }[]) => void; declare type EntityPropsChangeListener<V = any> = (value: V) => void; declare type ProcessStateChangeListener = (isForeground: boolean) => void; declare type JoystickActionListener = (data: JoystickAction) => void; export declare abstract class Scene<UIP = any> { private ui; private _worldManagement; private _loadedAssets; private _renderer; private _renderAssetsFail; private loadAssetsListener; private nativeEventsUnsubscribes; private readonly entityPropsChangeListeners; private readonly soundBackgroundOptionsChangeListeners; private readonly soundOnceOptionsChangeListeners; private readonly processStateChangeListeners; private readonly joystickActionListeners; private readonly prefabs; private readonly soundsDecor; private readonly spritesDecor; readonly sounds: Sound[]; readonly sprites: Avatar[]; readonly sessionId: string; assetsDelay: number; tag: string; manager: SceneManagement; constructor(); get renderer(): P5; get worldManagement(): WorldManagement; get renderAssetsFail(): () => ReactElement<any, string | import("react").JSXElementConstructor<any>> | { type: AssetErrorType; detail: any; }[]; get UI(): ComponentType<UIP> | (() => any); get soundBackgroundOptions(): SoundManagement[SoundType.BACKGROUND]; get soundOnceOptions(): SoundManagement[SoundType.ONCE]; set renderer(_renderer: P5); set soundBackgroundOptions(options: Partial<SoundManagement[SoundType.BACKGROUND]>); set soundOnceOptions(options: Partial<SoundManagement[SoundType.ONCE]>); private bootSoundOptions; protected getSoundOptions(): GetSoundOptions; protected onBorn(): void; protected getComponents(simpleCamera: SimpleCamera): LogicComponent<EntitySuit>[]; getUIProps(): Partial<UIP>; getInitialConfigs(): { joystick?: boolean | { containerTouchEvent?: TouchEvent; }; }; get loadedAssets(): boolean; private set loadedAssets(value); private set loadedAssetsError(value); onProcessStateChangeListener(func: ProcessStateChangeListener): () => void; onSoundOnceOptionsChange(func: SoundOptionsChangeListener<SoundType.ONCE>): () => void; onSoundBackgroundOptionsChange(func: SoundOptionsChangeListener<SoundType.BACKGROUND>): () => void; onJoystickAction(func: JoystickActionListener): () => void; onEntityPropsChange<V = any>(name: string, func: EntityPropsChangeListener<V>): () => void; emitJoystickActionEvent(data: JoystickAction): void; emitProcessStateChangeEvent(isForeground: boolean): void; emitEntityPropsChangeEvent<V = any>(name: string, value: V): void; onLoadAssetNotify(func: LoadAssetsListener): void; destructor(): void; switchToScene(tag: string): void; private loadSprites; private loadSounds; createSprites(...sources: (string | { src: string; })[]): Promise<Avatar[]>; createSounds(...sources: (string | { src: string; volume?: number; type?: SoundType; })[]): Promise<Sound[]>; mapSprites(...sources: string[]): Promise<void>; mapSounds(...sources: string[]): Promise<void>; loadAssets(delay: number | undefined | null, { skip, render }?: AssetsFailBehavior): Promise<void>; onLoadAssets(): Promise<void>; getPrefab<C extends EntitySuit>(Class: { new (...args: any[]): Prefab<C>; }): Prefab<C>; listenNativeEvents(): void; protected onBootstrapDone(simpleCamera: SimpleCamera): void; private bootstrapDone; bootstrap(simpleCamera: SimpleCamera): void; protected onDraw(): void; protected onUpdate(): void; mouseMove(): void; mousePressed(): void; mouseRelease(): void; action(): void; } export {}; //# sourceMappingURL=scene.d.ts.map