UNPKG

2.46 kBTypeScriptView Raw
1import { Runner } from '@pixi/runner';
2import { EventEmitter } from '@pixi/utils';
3import type { IRenderer } from '../IRenderer';
4import type { ISystemConstructor } from './ISystem';
5interface ISystemConfig<R> {
6 runners: string[];
7 systems: Record<string, ISystemConstructor<R>>;
8 priority: string[];
9}
10/**
11 * The SystemManager is a class that provides functions for managing a set of systems
12 * This is a base class, that is generic (no render code or knowledge at all)
13 * @memberof PIXI
14 */
15export declare class SystemManager<R = IRenderer> extends EventEmitter {
16 /** a collection of runners defined by the user */
17 readonly runners: {
18 [key: string]: Runner;
19 };
20 private _systemsHash;
21 /**
22 * Set up a system with a collection of SystemClasses and runners.
23 * Systems are attached dynamically to this class when added.
24 * @param config - the config for the system manager
25 */
26 setup(config: ISystemConfig<R>): void;
27 /**
28 * Create a bunch of runners based of a collection of ids
29 * @param runnerIds - the runner ids to add
30 */
31 addRunners(...runnerIds: string[]): void;
32 /**
33 * Add a new system to the renderer.
34 * @param ClassRef - Class reference
35 * @param name - Property name for system, if not specified
36 * will use a static `name` property on the class itself. This
37 * name will be assigned as s property on the Renderer so make
38 * sure it doesn't collide with properties on Renderer.
39 * @returns Return instance of renderer
40 */
41 addSystem(ClassRef: ISystemConstructor<R>, name: string): this;
42 /**
43 * A function that will run a runner and call the runners function but pass in different options
44 * to each system based on there name.
45 *
46 * E.g. If you have two systems added called `systemA` and `systemB` you could call do the following:
47 *
48 * ```js
49 * system.emitWithCustomOptions(init, {
50 * systemA: {...optionsForA},
51 * systemB: {...optionsForB},
52 * });
53 * ```
54 *
55 * `init` would be called on system A passing `optionsForA` and on system B passing `optionsForB`.
56 * @param runner - the runner to target
57 * @param options - key value options for each system
58 */
59 emitWithCustomOptions(runner: Runner, options: Record<string, unknown>): void;
60 /** destroy the all runners and systems. Its apps job to */
61 destroy(): void;
62}
63export {};