@awesome-ecs/abstract 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +129 -0
  2. package/dist/components/index.cjs.map +1 -1
  3. package/dist/components/index.d.cts +2 -2
  4. package/dist/components/index.d.ts +2 -2
  5. package/dist/components/index.js.map +1 -1
  6. package/dist/entities/index.cjs.map +1 -1
  7. package/dist/entities/index.d.cts +21 -4
  8. package/dist/entities/index.d.ts +21 -4
  9. package/dist/entities/index.js.map +1 -1
  10. package/dist/entity-repository-BlSpo-x2.d.ts +253 -0
  11. package/dist/entity-repository-DJ1xbvaN.d.cts +253 -0
  12. package/dist/factories/index.d.cts +41 -13
  13. package/dist/factories/index.d.ts +41 -13
  14. package/dist/index-B1KXekZD.d.ts +199 -0
  15. package/dist/index-CnlpX7ys.d.cts +199 -0
  16. package/dist/performance-timer-BVyl0SRs.d.cts +45 -0
  17. package/dist/performance-timer-BVyl0SRs.d.ts +45 -0
  18. package/dist/pipeline-9bVMwJKD.d.ts +161 -0
  19. package/dist/pipeline-CzwetuCd.d.cts +161 -0
  20. package/dist/pipelines/index.cjs.map +1 -1
  21. package/dist/pipelines/index.d.cts +61 -16
  22. package/dist/pipelines/index.d.ts +61 -16
  23. package/dist/pipelines/index.js.map +1 -1
  24. package/dist/systems/index.cjs.map +1 -1
  25. package/dist/systems/index.d.cts +76 -24
  26. package/dist/systems/index.d.ts +76 -24
  27. package/dist/systems/index.js.map +1 -1
  28. package/dist/systems-runtime-context-Bz9hIdKT.d.cts +330 -0
  29. package/dist/systems-runtime-context-C_Tsvoym.d.ts +330 -0
  30. package/dist/types-cZ-1lGPD.d.cts +77 -0
  31. package/dist/types-cZ-1lGPD.d.ts +77 -0
  32. package/dist/utils/index.cjs.map +1 -1
  33. package/dist/utils/index.d.cts +63 -3
  34. package/dist/utils/index.d.ts +63 -3
  35. package/dist/utils/index.js.map +1 -1
  36. package/package.json +2 -2
  37. package/dist/entity-repository-BASmOrq7.d.ts +0 -120
  38. package/dist/entity-repository-DmfcUSrX.d.cts +0 -120
  39. package/dist/index-BPDsRt_F.d.ts +0 -117
  40. package/dist/index-DK2CXVZ8.d.cts +0 -117
  41. package/dist/performance-timer-XvdCbcAE.d.cts +0 -13
  42. package/dist/performance-timer-XvdCbcAE.d.ts +0 -13
  43. package/dist/pipeline-BowCAITe.d.cts +0 -83
  44. package/dist/pipeline-D43CXxWG.d.ts +0 -83
  45. package/dist/systems-runtime-context-CDVzeB9f.d.ts +0 -162
  46. package/dist/systems-runtime-context-CpgxOdc8.d.cts +0 -162
  47. package/dist/types-BNwBqRWY.d.cts +0 -22
  48. package/dist/types-BNwBqRWY.d.ts +0 -22
@@ -1,117 +0,0 @@
1
- import { B as BooleanProps, I as Immutable } from './types-BNwBqRWY.js';
2
-
3
- type ComponentTypeUid = string | number;
4
- /**
5
- * The `IComponent` provides the main storage mechanism of `IEntity` state, and can be accessed and modified by Systems.
6
- *
7
- * The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
8
- */
9
- interface IComponent {
10
- /**
11
- * The `ComponentTypeUid` is an Unique Identifier for each Component type.
12
- */
13
- readonly componentType: ComponentTypeUid;
14
- /**
15
- * Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
16
- * Useful if the state needs to be replicated or updated through remote updates (e.g. coming from the server or peers).
17
- */
18
- readonly isSerializable: boolean;
19
- /**
20
- * @optional
21
- * Specifies the current version of the component.
22
- * Useful for keeping backwards-compatibility when the stored state might be of a different version.
23
- */
24
- readonly version?: number;
25
- /**
26
- * @optional
27
- * The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
28
- * If not provided, the standard `JSON.stringify()` functionality applies.
29
- */
30
- toJSON?(): string | object;
31
- /**
32
- * Allows for custom logic when loading the current from an `IEntitySnapshot`.
33
- * The default behavior simply overwrites the fields with the target state.
34
- */
35
- load?(targetState: this): void;
36
- }
37
-
38
- /**
39
- * The `IEntityProxy` represents a pointer to another `Entity`.
40
- */
41
- interface IEntityProxy {
42
- readonly entityType: EntityTypeUid;
43
- readonly entityUid: EntityUid;
44
- }
45
- /**
46
- * A utility extension of `IEntityProxy`.
47
- * Useful for providing strong `Type` information when using the IEntityProxy.
48
- */
49
- interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
50
- }
51
- /**
52
- * The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
53
- *
54
- * It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
55
- */
56
- interface IEntityProxiesManager {
57
- registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
58
- registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
59
- removeProxy(entity: IEntity, proxy: IEntityProxy): void;
60
- removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
61
- }
62
-
63
- type EntityTypeUid = string | number;
64
- type EntityUid = string | number;
65
- /**
66
- * The `IEntityModel` represents the basic identity information about the current `IEntity`.
67
- * It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
68
- *
69
- * The Features property can be used to toggle Entity features on and off.
70
- */
71
- interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
72
- readonly uid: EntityUid;
73
- readonly features?: TFeatures;
74
- }
75
- /**
76
- * The `IEntity` is basically a container of Components and Entity Proxies.
77
- * Only Systems can manipulate the internal state of the Entity, by altering its Components' data.
78
- *
79
- * The implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies` but should not contain any logic
80
- * apart from quick-access functionality.
81
- */
82
- interface IEntity {
83
- readonly components: Map<ComponentTypeUid, IComponent>;
84
- readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
85
- /**
86
- * The IdentityComponent represents mandatory state any Entity needs to have.
87
- */
88
- readonly identity: Readonly<IdentityComponent<IEntityModel>>;
89
- /**
90
- * Own Proxy reference, points to this Entity. Useful for quick access of Proxy data.
91
- */
92
- readonly myProxy: Readonly<IEntityProxy>;
93
- }
94
-
95
- declare enum BasicComponentType {
96
- identity = "identity"
97
- }
98
- /**
99
- * The `IdentityComponent` contains basic information regarding what makes the current Entity unique.
100
- */
101
- interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
102
- /**
103
- * The Entity Type that defines what Category type the Entity is part of. There can be multiple Entities sharing the same EntityType.
104
- */
105
- readonly entityType: EntityTypeUid;
106
- /**
107
- * The Model is the basic information needed to create an `IEntity` when it's first initialized.
108
- * It provides a first snapshot of information needed for the successful creation of an Entity instance.
109
- */
110
- readonly model: Immutable<TModel>;
111
- /**
112
- * Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
113
- */
114
- readonly lastUpdated?: Date;
115
- }
116
-
117
- export { BasicComponentType as B, type ComponentTypeUid as C, type EntityTypeUid as E, type IEntityProxy as I, type EntityUid as a, type IEntityModel as b, type IEntity as c, type EntityProxy as d, type IEntityProxiesManager as e, type IdentityComponent as f, type IComponent as g };
@@ -1,117 +0,0 @@
1
- import { B as BooleanProps, I as Immutable } from './types-BNwBqRWY.cjs';
2
-
3
- type ComponentTypeUid = string | number;
4
- /**
5
- * The `IComponent` provides the main storage mechanism of `IEntity` state, and can be accessed and modified by Systems.
6
- *
7
- * The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
8
- */
9
- interface IComponent {
10
- /**
11
- * The `ComponentTypeUid` is an Unique Identifier for each Component type.
12
- */
13
- readonly componentType: ComponentTypeUid;
14
- /**
15
- * Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
16
- * Useful if the state needs to be replicated or updated through remote updates (e.g. coming from the server or peers).
17
- */
18
- readonly isSerializable: boolean;
19
- /**
20
- * @optional
21
- * Specifies the current version of the component.
22
- * Useful for keeping backwards-compatibility when the stored state might be of a different version.
23
- */
24
- readonly version?: number;
25
- /**
26
- * @optional
27
- * The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
28
- * If not provided, the standard `JSON.stringify()` functionality applies.
29
- */
30
- toJSON?(): string | object;
31
- /**
32
- * Allows for custom logic when loading the current from an `IEntitySnapshot`.
33
- * The default behavior simply overwrites the fields with the target state.
34
- */
35
- load?(targetState: this): void;
36
- }
37
-
38
- /**
39
- * The `IEntityProxy` represents a pointer to another `Entity`.
40
- */
41
- interface IEntityProxy {
42
- readonly entityType: EntityTypeUid;
43
- readonly entityUid: EntityUid;
44
- }
45
- /**
46
- * A utility extension of `IEntityProxy`.
47
- * Useful for providing strong `Type` information when using the IEntityProxy.
48
- */
49
- interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
50
- }
51
- /**
52
- * The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
53
- *
54
- * It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
55
- */
56
- interface IEntityProxiesManager {
57
- registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
58
- registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
59
- removeProxy(entity: IEntity, proxy: IEntityProxy): void;
60
- removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
61
- }
62
-
63
- type EntityTypeUid = string | number;
64
- type EntityUid = string | number;
65
- /**
66
- * The `IEntityModel` represents the basic identity information about the current `IEntity`.
67
- * It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
68
- *
69
- * The Features property can be used to toggle Entity features on and off.
70
- */
71
- interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
72
- readonly uid: EntityUid;
73
- readonly features?: TFeatures;
74
- }
75
- /**
76
- * The `IEntity` is basically a container of Components and Entity Proxies.
77
- * Only Systems can manipulate the internal state of the Entity, by altering its Components' data.
78
- *
79
- * The implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies` but should not contain any logic
80
- * apart from quick-access functionality.
81
- */
82
- interface IEntity {
83
- readonly components: Map<ComponentTypeUid, IComponent>;
84
- readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
85
- /**
86
- * The IdentityComponent represents mandatory state any Entity needs to have.
87
- */
88
- readonly identity: Readonly<IdentityComponent<IEntityModel>>;
89
- /**
90
- * Own Proxy reference, points to this Entity. Useful for quick access of Proxy data.
91
- */
92
- readonly myProxy: Readonly<IEntityProxy>;
93
- }
94
-
95
- declare enum BasicComponentType {
96
- identity = "identity"
97
- }
98
- /**
99
- * The `IdentityComponent` contains basic information regarding what makes the current Entity unique.
100
- */
101
- interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
102
- /**
103
- * The Entity Type that defines what Category type the Entity is part of. There can be multiple Entities sharing the same EntityType.
104
- */
105
- readonly entityType: EntityTypeUid;
106
- /**
107
- * The Model is the basic information needed to create an `IEntity` when it's first initialized.
108
- * It provides a first snapshot of information needed for the successful creation of an Entity instance.
109
- */
110
- readonly model: Immutable<TModel>;
111
- /**
112
- * Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
113
- */
114
- readonly lastUpdated?: Date;
115
- }
116
-
117
- export { BasicComponentType as B, type ComponentTypeUid as C, type EntityTypeUid as E, type IEntityProxy as I, type EntityUid as a, type IEntityModel as b, type IEntity as c, type EntityProxy as d, type IEntityProxiesManager as e, type IdentityComponent as f, type IComponent as g };
@@ -1,13 +0,0 @@
1
- type PerformanceTimerUid = number;
2
- interface PerformanceTimeEntry {
3
- name: string;
4
- startedAt: number;
5
- endedAt?: number;
6
- msPassed?: number;
7
- }
8
- interface IPerformanceTimer {
9
- startTimer(name: string): PerformanceTimerUid;
10
- endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
11
- }
12
-
13
- export type { IPerformanceTimer as I, PerformanceTimeEntry as P, PerformanceTimerUid as a };
@@ -1,13 +0,0 @@
1
- type PerformanceTimerUid = number;
2
- interface PerformanceTimeEntry {
3
- name: string;
4
- startedAt: number;
5
- endedAt?: number;
6
- msPassed?: number;
7
- }
8
- interface IPerformanceTimer {
9
- startTimer(name: string): PerformanceTimerUid;
10
- endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
11
- }
12
-
13
- export type { IPerformanceTimer as I, PerformanceTimeEntry as P, PerformanceTimerUid as a };
@@ -1,83 +0,0 @@
1
- import { P as PerformanceTimeEntry } from './performance-timer-XvdCbcAE.cjs';
2
-
3
- /**
4
- * The PipelineResult can provide Performance metrics collected from self or inner middleware & pipeline calls.
5
- */
6
- type PipelineResult = {
7
- readonly performance?: PerformanceTimeEntry;
8
- readonly inner?: PipelineResult[];
9
- };
10
-
11
- /**
12
- * The MiddlewareResult can provide Pipeline Results inner pipeline calls.
13
- */
14
- type MiddlewareResult = void | PipelineResult;
15
-
16
- /**
17
- * The PipelineStatus tracks the current status of the pipeline.
18
- */
19
- declare enum PipelineStatus {
20
- idle = "idle",
21
- ongoing = "ongoing",
22
- completed = "completed",
23
- halted = "halted"
24
- }
25
-
26
- /**
27
- * The Pipeline Context allows exposing state to the Pipeline's middlewares.
28
- */
29
- interface IPipelineContext {
30
- readonly runtime: PipelineRuntime;
31
- }
32
- /**
33
- * The Pipeline Runtime exposes runtime status controls for Middlewares, as part of tbe PipelineContext.
34
- */
35
- type PipelineRuntime = {
36
- shouldStop: boolean;
37
- status?: PipelineStatus;
38
- };
39
-
40
- /**
41
- * A middleware, the building block of a Pipeline. The middlewares will provide a unit-of-work implementation
42
- * dealing with potential state changes over the input Context, or running cleanup logic over the input Context.
43
- */
44
- interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareResult> {
45
- readonly name?: string;
46
- /**
47
- * This (optional) function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
48
- * being met so this middleware's action should run.
49
- * @param context The Context to determine whether the run condition is satisfied.
50
- */
51
- shouldRun?(context: TContext): boolean;
52
- /**
53
- * The function gets called as part of the pipeline, based on the registration order.
54
- * @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
55
- */
56
- action(context: TContext): TResult;
57
- /**
58
- * This (optional) function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
59
- * @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
60
- */
61
- cleanup?(context: TContext): TResult;
62
- }
63
-
64
- /**
65
- * An {@link IMiddleware} container and dispatcher.
66
- */
67
- interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResult> {
68
- readonly name?: string;
69
- /**
70
- * Register middleware for this pipeline.
71
- */
72
- use(middleware: IMiddleware<TContext, TResult>): this;
73
- /**
74
- * Execute the Dispatch on the chain of middleware, with the given Context.
75
- */
76
- dispatch(context: TContext): PipelineResult;
77
- /**
78
- * Execute the Cleanup on the chain of middleware, with the given Context.
79
- */
80
- cleanup(context: TContext): PipelineResult;
81
- }
82
-
83
- export { type IPipelineContext as I, type MiddlewareResult as M, type PipelineResult as P, type IPipeline as a, type IMiddleware as b, type PipelineRuntime as c, PipelineStatus as d };
@@ -1,83 +0,0 @@
1
- import { P as PerformanceTimeEntry } from './performance-timer-XvdCbcAE.js';
2
-
3
- /**
4
- * The PipelineResult can provide Performance metrics collected from self or inner middleware & pipeline calls.
5
- */
6
- type PipelineResult = {
7
- readonly performance?: PerformanceTimeEntry;
8
- readonly inner?: PipelineResult[];
9
- };
10
-
11
- /**
12
- * The MiddlewareResult can provide Pipeline Results inner pipeline calls.
13
- */
14
- type MiddlewareResult = void | PipelineResult;
15
-
16
- /**
17
- * The PipelineStatus tracks the current status of the pipeline.
18
- */
19
- declare enum PipelineStatus {
20
- idle = "idle",
21
- ongoing = "ongoing",
22
- completed = "completed",
23
- halted = "halted"
24
- }
25
-
26
- /**
27
- * The Pipeline Context allows exposing state to the Pipeline's middlewares.
28
- */
29
- interface IPipelineContext {
30
- readonly runtime: PipelineRuntime;
31
- }
32
- /**
33
- * The Pipeline Runtime exposes runtime status controls for Middlewares, as part of tbe PipelineContext.
34
- */
35
- type PipelineRuntime = {
36
- shouldStop: boolean;
37
- status?: PipelineStatus;
38
- };
39
-
40
- /**
41
- * A middleware, the building block of a Pipeline. The middlewares will provide a unit-of-work implementation
42
- * dealing with potential state changes over the input Context, or running cleanup logic over the input Context.
43
- */
44
- interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareResult> {
45
- readonly name?: string;
46
- /**
47
- * This (optional) function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
48
- * being met so this middleware's action should run.
49
- * @param context The Context to determine whether the run condition is satisfied.
50
- */
51
- shouldRun?(context: TContext): boolean;
52
- /**
53
- * The function gets called as part of the pipeline, based on the registration order.
54
- * @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
55
- */
56
- action(context: TContext): TResult;
57
- /**
58
- * This (optional) function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
59
- * @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
60
- */
61
- cleanup?(context: TContext): TResult;
62
- }
63
-
64
- /**
65
- * An {@link IMiddleware} container and dispatcher.
66
- */
67
- interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResult> {
68
- readonly name?: string;
69
- /**
70
- * Register middleware for this pipeline.
71
- */
72
- use(middleware: IMiddleware<TContext, TResult>): this;
73
- /**
74
- * Execute the Dispatch on the chain of middleware, with the given Context.
75
- */
76
- dispatch(context: TContext): PipelineResult;
77
- /**
78
- * Execute the Cleanup on the chain of middleware, with the given Context.
79
- */
80
- cleanup(context: TContext): PipelineResult;
81
- }
82
-
83
- export { type IPipelineContext as I, type MiddlewareResult as M, type PipelineResult as P, type IPipeline as a, type IMiddleware as b, type PipelineRuntime as c, PipelineStatus as d };
@@ -1,162 +0,0 @@
1
- import { c as IEntity, I as IEntityProxy, E as EntityTypeUid, b as IEntityModel, d as EntityProxy } from './index-BPDsRt_F.js';
2
- import { f as IEntityUpdate, I as IEventData, E as EntityEventUid, b as IEntityEvent, i as IEntitySnapshot, h as IEntityRepository } from './entity-repository-BASmOrq7.js';
3
- import { I as IPipelineContext, a as IPipeline } from './pipeline-D43CXxWG.js';
4
- import { I as Immutable } from './types-BNwBqRWY.js';
5
- import { IJsonSerializer, ILogger } from './utils/index.js';
6
-
7
- interface ISystemContextEntity {
8
- readonly entity: Immutable<IEntity>;
9
- readonly update: Immutable<IEntityUpdate>;
10
- setEntity(entity: IEntity): void;
11
- setUpdate(update: IEntityUpdate): void;
12
- }
13
-
14
- /**
15
- * The ISystemContextEvents is the access point for Event related APIs.
16
- * The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
17
- */
18
- interface ISystemContextEvents {
19
- /**
20
- * Dispatches and schedules the Event to it's Subscribers or provided Entity Targets.
21
- * @param data The EventData to dispatch.
22
- * @param targets (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
23
- */
24
- dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
25
- /**
26
- * Dispatches and schedules the Events to their Subscribers or provided Entity Targets.
27
- * @param data The EventData Array to dispatch.
28
- * @param targets (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
29
- */
30
- dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
31
- /**
32
- * Retrieves the Event with the given UID if it has been previously set on the current Context.
33
- * @param uid The Event UID to retrieve.
34
- */
35
- getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData>;
36
- /**
37
- * Retrieves all the Events currently set on the Context.
38
- */
39
- listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
40
- /**
41
- * Returns whether the Event with the given UID has previously been set on the current Context.
42
- * @param uid The Event UID to check for existence.
43
- */
44
- hasEvent(uid?: EntityEventUid): boolean;
45
- /**
46
- * Subscribes to Events with the given UID. When the matching Event is dispatched,
47
- * the Entity update loop will set this Event on the Pipeline Context.
48
- * @param uid The Event UID to subscribe to.
49
- * @param filter (optional) Provides a callback function that will be executed on all matching Events.
50
- * Can be used to filter what Event to schedule through to the current Entity update.
51
- */
52
- subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
53
- /**
54
- * Stops subscribing to Events with the given UID. The Entity will not receive any future Events with this UID.
55
- * @param uid The Event UID to stop listening to.
56
- */
57
- unsubscribeFrom(uid: EntityEventUid): void;
58
- /**
59
- * Adds the given Events into the Context instance.
60
- * @param events The Event instances to be set on the Context.
61
- */
62
- setContextEvents(events: IEntityEvent<IEventData>[]): void;
63
- /**
64
- * Adds the given Event into the Context instance.
65
- * @param event The Event instance to be set on the Context.
66
- */
67
- setContextEvent(event: IEntityEvent<IEventData>): void;
68
- /**
69
- * Removes all the Events currently set on the Context instance.
70
- */
71
- clearContextEvents(): void;
72
- /**
73
- * Removes all the Event Subscriptions for the current Entity.
74
- */
75
- clearSubscriptions(): void;
76
- }
77
-
78
- /**
79
- * The ISystemContextProxies is the access point for EntityProxy related APIs.
80
- * The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
81
- */
82
- interface ISystemContextProxies {
83
- registerProxy(proxy: IEntityProxy, cleanup?: boolean): void;
84
- registerProxies(proxies: IEntityProxy[], cleanup?: boolean): void;
85
- removeProxy(proxy: IEntityProxy): void;
86
- removeProxies(proxyEntityType?: EntityTypeUid): void;
87
- }
88
-
89
- /**
90
- * The `ISystemContextRepository` is the access point for the `IEntityRepository` related APIs.
91
- *
92
- * The access is made in an `ISystemMiddleware` through the provided `ISystemPipelineContext`.
93
- */
94
- interface ISystemContextRepository {
95
- addEntity(entityType: EntityTypeUid, model: IEntityModel, snapshot?: IEntitySnapshot): void;
96
- getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): Immutable<TEntity>;
97
- updateEntity(target?: IEntityProxy): void;
98
- removeEntity(target: IEntityProxy): void;
99
- }
100
-
101
- /**
102
- * The ISystemContextRepository is the access point for Scheduler related APIs.
103
- * The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
104
- */
105
- interface ISystemContextScheduler {
106
- scheduleUpdate(target?: IEntityProxy, intervalMs?: number): void;
107
- removeSchedule(target?: IEntityProxy): void;
108
- }
109
-
110
- /**
111
- * The ISystemContextSnapshot is the access point for Snapshot related APIs.
112
- * The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
113
- */
114
- interface ISystemContextSnapshot {
115
- readonly serializer: Immutable<IJsonSerializer>;
116
- applyToEntity(snapshot: IEntitySnapshot): void;
117
- createFromEntity(entity?: IEntity): IEntitySnapshot;
118
- dispatchToUpdate(snapshot: IEntitySnapshot, proxy?: IEntityProxy): void;
119
- }
120
-
121
- /**
122
- * The ISystemContext is the Context passed to a SystemMiddleware as part of the Pipeline Dispatch.
123
- * It's an abstraction layer so that the Middleware code won't have explicit dependencies on other parts of the ECS.
124
- *
125
- * Any State changes done by the SystemMiddleware are executed using the APIs provided by the ISystemContext.
126
- */
127
- interface ISystemContext<TEntity extends IEntity> extends IPipelineContext {
128
- readonly deltaTimeMs: Immutable<number>;
129
- readonly entity: Immutable<TEntity>;
130
- readonly update: Immutable<IEntityUpdate>;
131
- readonly events: Immutable<ISystemContextEvents>;
132
- readonly proxies: Immutable<ISystemContextProxies>;
133
- readonly repository: Immutable<ISystemContextRepository>;
134
- readonly scheduler: Immutable<ISystemContextScheduler>;
135
- readonly snapshot: Immutable<ISystemContextSnapshot>;
136
- readonly logger: Immutable<ILogger>;
137
- }
138
-
139
- /**
140
- * The built-in ECS pipeline types. They can be extended to introduce more types, and the System Runtime Pipeline should
141
- * add Middleware to handle the newly added types.
142
- */
143
- declare enum SystemType {
144
- initialize = "initialize",
145
- update = "update",
146
- render = "render",
147
- sync = "sync"
148
- }
149
-
150
- /**
151
- * The ISystemsRuntimeContext is the Context passed by a SystemsRuntimePipeline.
152
- * It helps orchestrate the execution of SystemPipelines registered in the SystemsModule.
153
- */
154
- interface ISystemsRuntimeContext<TEntity extends IEntity> extends IPipelineContext {
155
- readonly allowedSteps: Set<SystemType>;
156
- readonly entityProvider: ISystemContextEntity;
157
- readonly entityRepository: IEntityRepository;
158
- readonly systemPipelines: Map<SystemType, IPipeline<ISystemContext<TEntity>>>;
159
- readonly systemContext: ISystemContext<TEntity>;
160
- }
161
-
162
- export { type ISystemsRuntimeContext as I, SystemType as S, type ISystemContext as a, type ISystemContextEntity as b, type ISystemContextEvents as c, type ISystemContextProxies as d, type ISystemContextRepository as e, type ISystemContextScheduler as f, type ISystemContextSnapshot as g };