@awesome-ecs/abstract 0.20.0 → 0.20.2
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.
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js.map +1 -1
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +21 -4
- package/dist/entities/index.d.ts +21 -4
- package/dist/entities/index.js.map +1 -1
- package/dist/entity-repository-BlSpo-x2.d.ts +253 -0
- package/dist/entity-repository-DJ1xbvaN.d.cts +253 -0
- package/dist/factories/index.d.cts +40 -10
- package/dist/factories/index.d.ts +40 -10
- package/dist/index-B1KXekZD.d.ts +199 -0
- package/dist/index-CnlpX7ys.d.cts +199 -0
- package/dist/performance-timer-BVyl0SRs.d.cts +45 -0
- package/dist/performance-timer-BVyl0SRs.d.ts +45 -0
- package/dist/pipeline-BGsQiSer.d.ts +161 -0
- package/dist/pipeline-DunwPUPZ.d.cts +161 -0
- package/dist/pipelines/index.cjs.map +1 -1
- package/dist/pipelines/index.d.cts +23 -11
- package/dist/pipelines/index.d.ts +23 -11
- package/dist/pipelines/index.js.map +1 -1
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +58 -19
- package/dist/systems/index.d.ts +58 -19
- package/dist/systems/index.js.map +1 -1
- package/dist/systems-runtime-context-BTNdV8Z-.d.ts +330 -0
- package/dist/systems-runtime-context-DhtHMczN.d.cts +330 -0
- package/dist/types-cZ-1lGPD.d.cts +77 -0
- package/dist/types-cZ-1lGPD.d.ts +77 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +63 -3
- package/dist/utils/index.d.ts +63 -3
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/entity-repository-BASmOrq7.d.ts +0 -120
- package/dist/entity-repository-DmfcUSrX.d.cts +0 -120
- package/dist/index-BPDsRt_F.d.ts +0 -117
- package/dist/index-DK2CXVZ8.d.cts +0 -117
- package/dist/performance-timer-XvdCbcAE.d.cts +0 -13
- package/dist/performance-timer-XvdCbcAE.d.ts +0 -13
- package/dist/pipeline-BowCAITe.d.cts +0 -83
- package/dist/pipeline-D43CXxWG.d.ts +0 -83
- package/dist/systems-runtime-context-B2ch9kB3.d.ts +0 -163
- package/dist/systems-runtime-context-C-PeYs1I.d.cts +0 -163
- package/dist/types-BNwBqRWY.d.cts +0 -22
- package/dist/types-BNwBqRWY.d.ts +0 -22
package/dist/systems/index.d.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-
|
|
2
|
-
export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-
|
|
3
|
-
import { c as IEntity, E as EntityTypeUid } from '../index-
|
|
4
|
-
import { b as IMiddleware, P as PipelineResult } from '../pipeline-
|
|
5
|
-
import { f as IEntityUpdate } from '../entity-repository-
|
|
6
|
-
import { I as Immutable } from '../types-
|
|
1
|
+
import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-BTNdV8Z-.js';
|
|
2
|
+
export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-BTNdV8Z-.js';
|
|
3
|
+
import { c as IEntity, E as EntityTypeUid } from '../index-B1KXekZD.js';
|
|
4
|
+
import { b as IMiddleware, P as PipelineResult } from '../pipeline-BGsQiSer.js';
|
|
5
|
+
import { f as IEntityUpdate } from '../entity-repository-BlSpo-x2.js';
|
|
6
|
+
import { I as Immutable } from '../types-cZ-1lGPD.js';
|
|
7
7
|
import '../utils/index.js';
|
|
8
|
-
import '../performance-timer-
|
|
8
|
+
import '../performance-timer-BVyl0SRs.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* The ISystemsRuntimeMiddleware represents the building blocks of executing SystemsModule's registered Pipelines.
|
|
11
|
+
* The `ISystemsRuntimeMiddleware` represents the building blocks of executing SystemsModule's registered Pipelines.
|
|
12
12
|
* It receives the current State in the Context, and can decide which SystemPipelines to execute.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TEntity - The type of entity that the middleware operates on.
|
|
15
|
+
* @extends {IMiddleware<ISystemsRuntimeContext<TEntity>>} - Extends the base `IMiddleware` interface, which is used for defining middleware functions.
|
|
13
16
|
*/
|
|
14
17
|
type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
|
-
* The
|
|
18
|
-
* It provides a SystemPipelineContext to
|
|
20
|
+
* The `ISystemMiddleware` is a basic System implementation that can be registered as a Middleware in a SystemPipeline.
|
|
21
|
+
* It provides a `SystemPipelineContext` to its exposed methods.
|
|
22
|
+
*
|
|
23
|
+
* @template TEntity - The type of entity that this middleware operates on.
|
|
24
|
+
* @extends {IMiddleware<ISystemContext<TEntity>>} - Extends the base `IMiddleware` interface, which requires a `SystemPipelineContext` to be provided.
|
|
19
25
|
*/
|
|
20
26
|
type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
|
|
21
27
|
|
|
@@ -25,36 +31,69 @@ type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEn
|
|
|
25
31
|
*/
|
|
26
32
|
interface ISystemsModule<TEntity extends IEntity> {
|
|
27
33
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
34
|
+
* Registers SystemMiddlewares to the specified SystemPipelineType.
|
|
35
|
+
*
|
|
36
|
+
* @param type - The SystemPipelineType to append the provided SystemMiddlewares to.
|
|
37
|
+
* @param systems - The SystemMiddlewares to be registered in the provided SystemPipelineType in the same order as the provided array.
|
|
30
38
|
* The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
|
|
31
39
|
*/
|
|
32
|
-
registerSystems(type: SystemType, systems: ISystemMiddleware<TEntity>[]): void;
|
|
40
|
+
registerSystems?(type: SystemType, systems: ISystemMiddleware<TEntity>[]): void;
|
|
33
41
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
42
|
+
* Triggers all registered SystemPipelines to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
43
|
+
*
|
|
44
|
+
* @param update - The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
45
|
+
* @returns A PipelineResult indicating the success or failure of the triggered SystemPipelines.
|
|
36
46
|
*/
|
|
37
47
|
triggerSystems(update: IEntityUpdate): PipelineResult;
|
|
38
48
|
}
|
|
39
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Interface for managing systems modules.
|
|
52
|
+
*
|
|
53
|
+
* @template TEntity - The type of entity that the systems module operates on.
|
|
54
|
+
*/
|
|
40
55
|
interface ISystemsModuleRepository {
|
|
56
|
+
/**
|
|
57
|
+
* The number of systems modules in the repository.
|
|
58
|
+
*/
|
|
41
59
|
readonly size: number;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves a systems module for a specific entity type.
|
|
62
|
+
*
|
|
63
|
+
* @param type - The unique identifier of the entity type.
|
|
64
|
+
* @returns The systems module for the specified entity type.
|
|
65
|
+
*/
|
|
42
66
|
get<TEntity extends IEntity>(type: EntityTypeUid): ISystemsModule<TEntity>;
|
|
67
|
+
/**
|
|
68
|
+
* Adds or updates a systems module for a specific entity type.
|
|
69
|
+
*
|
|
70
|
+
* @param type - The unique identifier of the entity type.
|
|
71
|
+
* @param module - The systems module to add or update.
|
|
72
|
+
*/
|
|
43
73
|
set(type: EntityTypeUid, module: ISystemsModule<IEntity>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves a read-only map of all systems modules in the repository.
|
|
76
|
+
*
|
|
77
|
+
* @returns A read-only map of entity type unique identifiers to systems modules.
|
|
78
|
+
*/
|
|
44
79
|
list(): ReadonlyMap<EntityTypeUid, Immutable<ISystemsModule<IEntity>>>;
|
|
45
80
|
}
|
|
46
81
|
|
|
47
82
|
/**
|
|
48
83
|
* The System Runtime allows running a loop of Ticks.
|
|
49
84
|
*
|
|
50
|
-
* Each
|
|
51
|
-
*
|
|
85
|
+
* Each `runTick` method can process one or more Entity Updates.
|
|
86
|
+
*
|
|
87
|
+
* We can have multiple implementations of a `SystemsRuntime`, based on the use-case.
|
|
52
88
|
* A different implementation can be chosen at runtime, based for example on performance.
|
|
53
89
|
*/
|
|
54
90
|
interface ISystemsRuntime {
|
|
55
91
|
/**
|
|
56
|
-
* The method should trigger the SystemsModule logic for the provided IEntityUpdate
|
|
57
|
-
* If no EntityUpdate is given, the SystemRuntime implementation can choose to dequeue one from the IEntityUpdateQueue
|
|
92
|
+
* The method should trigger the SystemsModule logic for the provided `IEntityUpdate`.
|
|
93
|
+
* If no EntityUpdate is given, the `SystemRuntime` implementation can choose to dequeue one from the `IEntityUpdateQueue`.
|
|
94
|
+
*
|
|
95
|
+
* @param update - An optional `IEntityUpdate` to process. If not provided, the method will dequeue one from the `IEntityUpdateQueue`.
|
|
96
|
+
* @returns A `PipelineResult` representing the outcome of the SystemsModule logic execution.
|
|
58
97
|
*/
|
|
59
98
|
runTick(update?: IEntityUpdate): PipelineResult;
|
|
60
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/systems/module/system-type.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/systems/module/system-type.ts"],"sourcesContent":["/**\n * Enum representing the built-in System pipeline types.\n * These types can be extended to introduce more types, and the System Runtime Pipeline should\n * add Middleware to handle the newly added types.\n */\nexport enum SystemType {\n /**\n * The initialization phase of the Module pipeline.\n * This phase is typically used for setting up initial state and resources.\n */\n initialize = 'initialize',\n\n /**\n * The update phase of the Module pipeline.\n * This phase is responsible for updating the game logic and state of entities.\n */\n update = 'update',\n\n /**\n * The render phase of the Module pipeline.\n * This phase is used for rendering the game to the screen.\n */\n render = 'render',\n\n /**\n * The synchronization phase of the Module pipeline.\n * This phase is used for synchronizing game state with external systems or other components.\n */\n sync = 'sync'\n}\n"],"mappings":";AAKO,IAAK,aAAL,kBAAKA,gBAAL;AAKL,EAAAA,YAAA,gBAAa;AAMb,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,UAAO;AAvBG,SAAAA;AAAA,GAAA;","names":["SystemType"]}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { I as IEntityProxy, E as EntityTypeUid, b as IEntityModel, c as IEntity, d as EntityProxy } from './index-B1KXekZD.js';
|
|
2
|
+
import { I as IEventData, E as EntityEventUid, b as IEntityEvent, i as IEntitySnapshot, f as IEntityUpdate, h as IEntityRepository } from './entity-repository-BlSpo-x2.js';
|
|
3
|
+
import { I as IPipelineContext, a as IPipeline } from './pipeline-BGsQiSer.js';
|
|
4
|
+
import { IJsonSerializer, ILogger } from './utils/index.js';
|
|
5
|
+
import { I as Immutable } from './types-cZ-1lGPD.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Enum representing the built-in System pipeline types.
|
|
9
|
+
* These types can be extended to introduce more types, and the System Runtime Pipeline should
|
|
10
|
+
* add Middleware to handle the newly added types.
|
|
11
|
+
*/
|
|
12
|
+
declare enum SystemType {
|
|
13
|
+
/**
|
|
14
|
+
* The initialization phase of the Module pipeline.
|
|
15
|
+
* This phase is typically used for setting up initial state and resources.
|
|
16
|
+
*/
|
|
17
|
+
initialize = "initialize",
|
|
18
|
+
/**
|
|
19
|
+
* The update phase of the Module pipeline.
|
|
20
|
+
* This phase is responsible for updating the game logic and state of entities.
|
|
21
|
+
*/
|
|
22
|
+
update = "update",
|
|
23
|
+
/**
|
|
24
|
+
* The render phase of the Module pipeline.
|
|
25
|
+
* This phase is used for rendering the game to the screen.
|
|
26
|
+
*/
|
|
27
|
+
render = "render",
|
|
28
|
+
/**
|
|
29
|
+
* The synchronization phase of the Module pipeline.
|
|
30
|
+
* This phase is used for synchronizing game state with external systems or other components.
|
|
31
|
+
*/
|
|
32
|
+
sync = "sync"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The ISystemContextEvents is the access point for Event related APIs.
|
|
37
|
+
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
38
|
+
*/
|
|
39
|
+
interface ISystemContextEvents {
|
|
40
|
+
/**
|
|
41
|
+
* Dispatches and schedules the Event to its Subscribers or provided Entity Targets.
|
|
42
|
+
* @param data - The EventData to dispatch.
|
|
43
|
+
* @param targets - (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
|
|
44
|
+
*/
|
|
45
|
+
dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Dispatches and schedules the Events to their Subscribers or provided Entity Targets.
|
|
48
|
+
* @param data - The EventData Array to dispatch.
|
|
49
|
+
* @param targets - (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
|
|
50
|
+
*/
|
|
51
|
+
dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the Event with the given UID if it has been previously set on the current Context.
|
|
54
|
+
* @param uid - The Event UID to retrieve.
|
|
55
|
+
* @returns The Event with the given UID if it exists, otherwise undefined.
|
|
56
|
+
*/
|
|
57
|
+
getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData> | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves all the Events currently set on the Context.
|
|
60
|
+
* @returns An array of all the Events currently set on the Context.
|
|
61
|
+
*/
|
|
62
|
+
listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
|
|
63
|
+
/**
|
|
64
|
+
* Returns whether the Event with the given UID has previously been set on the current Context.
|
|
65
|
+
* @param uid - The Event UID to check for existence. If not provided, checks for any events in the context.
|
|
66
|
+
* @returns True if the Event with the given UID exists, otherwise false.
|
|
67
|
+
*/
|
|
68
|
+
hasEvent(uid?: EntityEventUid): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Subscribes to Events with the given UID. When the matching Event is dispatched,
|
|
71
|
+
* the Entity update loop will set this Event on the Pipeline Context.
|
|
72
|
+
* @param uid - The Event UID to subscribe to.
|
|
73
|
+
* @param filter - (optional) Provides a callback function that will be executed on all matching Events.
|
|
74
|
+
* Can be used to filter what Event to schedule through to the current Entity update.
|
|
75
|
+
*/
|
|
76
|
+
subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
|
|
77
|
+
/**
|
|
78
|
+
* Stops subscribing to Events with the given UID. The Entity will not receive any future Events with this UID.
|
|
79
|
+
* @param uid - The Event UID to stop listening to.
|
|
80
|
+
*/
|
|
81
|
+
unsubscribeFrom(uid: EntityEventUid): void;
|
|
82
|
+
/**
|
|
83
|
+
* Adds the given Events into the Context instance.
|
|
84
|
+
* @param events - The Event instances to be set on the Context.
|
|
85
|
+
*/
|
|
86
|
+
setContextEvents(events: IEntityEvent<IEventData>[]): void;
|
|
87
|
+
/**
|
|
88
|
+
* Adds the given Event into the Context instance.
|
|
89
|
+
* @param event - The Event instance to be set on the Context.
|
|
90
|
+
*/
|
|
91
|
+
setContextEvent(event: IEntityEvent<IEventData>): void;
|
|
92
|
+
/**
|
|
93
|
+
* Removes all the Events currently set on the Context instance.
|
|
94
|
+
*/
|
|
95
|
+
clearContextEvents(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Removes all the Event Subscriptions for the current Entity.
|
|
98
|
+
*/
|
|
99
|
+
clearSubscriptions(): void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The ISystemContextProxies interface provides access to EntityProxy related APIs.
|
|
104
|
+
* These APIs are accessed within a SystemMiddleware through the provided ISystemPipelineContext.
|
|
105
|
+
*/
|
|
106
|
+
interface ISystemContextProxies {
|
|
107
|
+
/**
|
|
108
|
+
* Registers a single EntityProxy instance.
|
|
109
|
+
*
|
|
110
|
+
* @param proxy - The EntityProxy instance to register.
|
|
111
|
+
* @param cleanup - Optional flag indicating whether all existing proxies should be removed.
|
|
112
|
+
* Default is false.
|
|
113
|
+
*/
|
|
114
|
+
registerProxy(proxy: IEntityProxy, cleanup?: boolean): void;
|
|
115
|
+
/**
|
|
116
|
+
* Registers multiple EntityProxy instances.
|
|
117
|
+
*
|
|
118
|
+
* @param proxies - An array of EntityProxy instances to register.
|
|
119
|
+
* @param cleanup - Optional flag indicating whether all existing proxies should be removed.
|
|
120
|
+
* Default is false.
|
|
121
|
+
*/
|
|
122
|
+
registerProxies(proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
123
|
+
/**
|
|
124
|
+
* Removes a single EntityProxy instance.
|
|
125
|
+
*
|
|
126
|
+
* @param proxy - The EntityProxy instance to remove.
|
|
127
|
+
*/
|
|
128
|
+
removeProxy(proxy: IEntityProxy): void;
|
|
129
|
+
/**
|
|
130
|
+
* Removes all EntityProxy instances associated with a specific entity type.
|
|
131
|
+
* If no entity type is provided, all registered proxies will be removed.
|
|
132
|
+
*
|
|
133
|
+
* @param proxyEntityType - Optional entity type UID.
|
|
134
|
+
*/
|
|
135
|
+
removeProxies(proxyEntityType?: EntityTypeUid): void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The `ISystemContextRepository` is the access point for the `IEntityRepository` related APIs.
|
|
140
|
+
*
|
|
141
|
+
* The access is made in an `ISystemMiddleware` through the provided `ISystemPipelineContext`.
|
|
142
|
+
*/
|
|
143
|
+
interface ISystemContextRepository {
|
|
144
|
+
/**
|
|
145
|
+
* Schedule adding a new entity to the repository.
|
|
146
|
+
*
|
|
147
|
+
* @param entityType - The type of the entity.
|
|
148
|
+
* @param model - The model of the entity.
|
|
149
|
+
* @param snapshot - Optional initial snapshot of the entity.
|
|
150
|
+
*/
|
|
151
|
+
addEntity(entityType: EntityTypeUid, model: IEntityModel, snapshot?: IEntitySnapshot): void;
|
|
152
|
+
/**
|
|
153
|
+
* Retrieves an entity from the repository.
|
|
154
|
+
*
|
|
155
|
+
* @template TEntity - The type of the entity.
|
|
156
|
+
* @param proxy - The proxy of the entity.
|
|
157
|
+
* @returns An immutable representation of the entity.
|
|
158
|
+
*/
|
|
159
|
+
getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): Immutable<TEntity>;
|
|
160
|
+
/**
|
|
161
|
+
* Schedule updating an entity in the repository.
|
|
162
|
+
*
|
|
163
|
+
* @param target - Optional target entity proxy. If not provided, updates the current entity set on the system context.
|
|
164
|
+
*/
|
|
165
|
+
updateEntity(target?: IEntityProxy): void;
|
|
166
|
+
/**
|
|
167
|
+
* Removes an entity from the repository.
|
|
168
|
+
*
|
|
169
|
+
* @param target - The entity proxy to be removed.
|
|
170
|
+
*/
|
|
171
|
+
removeEntity(target: IEntityProxy): void;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The `ISystemContextScheduler` interface represents the access point for Scheduler related APIs.
|
|
176
|
+
* The access is made in a `SystemMiddleware` through the provided `ISystemPipelineContext`.
|
|
177
|
+
*/
|
|
178
|
+
interface ISystemContextScheduler {
|
|
179
|
+
/**
|
|
180
|
+
* Schedules an update for the specified `target` entity proxy at a given `intervalMs`.
|
|
181
|
+
* If no `target` is provided, update will be scheduled for the current entity set on the system context.
|
|
182
|
+
* If no `intervalMs` is provided, the default update interval will be used.
|
|
183
|
+
*
|
|
184
|
+
* @param target - The entity proxy for which the update is scheduled.
|
|
185
|
+
* @param intervalMs - The interval in milliseconds at which the update should be triggered.
|
|
186
|
+
*/
|
|
187
|
+
scheduleUpdate(target?: IEntityProxy, intervalMs?: number): void;
|
|
188
|
+
/**
|
|
189
|
+
* Removes the scheduled update for the specified `target` entity proxy.
|
|
190
|
+
* If no `target` is provided, schedule is removed for the current entity set on the system context.
|
|
191
|
+
*
|
|
192
|
+
* @param target - The entity proxy for which the scheduled update should be removed.
|
|
193
|
+
*/
|
|
194
|
+
removeSchedule(target?: IEntityProxy): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The ISystemContextSnapshot is the access point for Snapshot related APIs.
|
|
199
|
+
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
200
|
+
*/
|
|
201
|
+
interface ISystemContextSnapshot {
|
|
202
|
+
/**
|
|
203
|
+
* A read-only reference to the JSON serializer used for snapshot serialization.
|
|
204
|
+
*/
|
|
205
|
+
readonly serializer: Immutable<IJsonSerializer>;
|
|
206
|
+
/**
|
|
207
|
+
* Applies the provided entity snapshot to the current entity set on the system context.
|
|
208
|
+
*
|
|
209
|
+
* @param snapshot - The entity snapshot to apply.
|
|
210
|
+
*/
|
|
211
|
+
applyToEntity(snapshot: IEntitySnapshot): void;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a new entity snapshot from the provided entity.
|
|
214
|
+
*
|
|
215
|
+
* @param entity - The entity to create a snapshot from. If not provided, a snapshot for the current entity set on the system context will be created.
|
|
216
|
+
* @returns A new entity snapshot.
|
|
217
|
+
*/
|
|
218
|
+
createFromEntity(entity?: IEntity): IEntitySnapshot;
|
|
219
|
+
/**
|
|
220
|
+
* Dispatches an update to the entity using the provided snapshot and entity proxy.
|
|
221
|
+
*
|
|
222
|
+
* @param snapshot - The entity snapshot to use for the update.
|
|
223
|
+
* @param proxy - The entity proxy to use for the update.
|
|
224
|
+
*/
|
|
225
|
+
dispatchToUpdate(snapshot: IEntitySnapshot, proxy: IEntityProxy): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The ISystemContext is the Context passed to a SystemMiddleware as part of the Pipeline Dispatch.
|
|
230
|
+
* It's an abstraction layer so that the Middleware code won't have explicit dependencies on other parts of the ECS.
|
|
231
|
+
*
|
|
232
|
+
* Any State changes done by the SystemMiddleware are executed using the APIs provided by the ISystemContext.
|
|
233
|
+
*
|
|
234
|
+
* @template TEntity - The type of entity that the SystemMiddleware operates on.
|
|
235
|
+
* @extends IPipelineContext - The ISystemContext extends the IPipelineContext interface.
|
|
236
|
+
*/
|
|
237
|
+
interface ISystemContext<TEntity extends IEntity> extends IPipelineContext {
|
|
238
|
+
/**
|
|
239
|
+
* The time in milliseconds since the last entity update.
|
|
240
|
+
*/
|
|
241
|
+
readonly deltaTimeMs: Immutable<number>;
|
|
242
|
+
/**
|
|
243
|
+
* The entity that the SystemMiddleware is operating on.
|
|
244
|
+
*/
|
|
245
|
+
readonly entity: Immutable<TEntity>;
|
|
246
|
+
/**
|
|
247
|
+
* The update object containing information about the entity's changes.
|
|
248
|
+
*/
|
|
249
|
+
readonly update: Immutable<IEntityUpdate>;
|
|
250
|
+
/**
|
|
251
|
+
* The events API for the SystemMiddleware to interact with the ECS events system.
|
|
252
|
+
*/
|
|
253
|
+
readonly events: Immutable<ISystemContextEvents>;
|
|
254
|
+
/**
|
|
255
|
+
* The proxies API for the SystemMiddleware to interact with the ECS proxies system.
|
|
256
|
+
*/
|
|
257
|
+
readonly proxies: Immutable<ISystemContextProxies>;
|
|
258
|
+
/**
|
|
259
|
+
* The repository API for the SystemMiddleware to interact with the ECS repository system.
|
|
260
|
+
*/
|
|
261
|
+
readonly repository: Immutable<ISystemContextRepository>;
|
|
262
|
+
/**
|
|
263
|
+
* The scheduler API for the SystemMiddleware to interact with the ECS scheduler system.
|
|
264
|
+
*/
|
|
265
|
+
readonly scheduler: Immutable<ISystemContextScheduler>;
|
|
266
|
+
/**
|
|
267
|
+
* The snapshot API for the SystemMiddleware to interact with the ECS snapshot system.
|
|
268
|
+
*/
|
|
269
|
+
readonly snapshot: Immutable<ISystemContextSnapshot>;
|
|
270
|
+
/**
|
|
271
|
+
* The logger API for the SystemMiddleware to log messages.
|
|
272
|
+
*/
|
|
273
|
+
readonly logger: Immutable<ILogger>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Interface representing a system context entity.
|
|
278
|
+
* This interface provides methods to manipulate and access entity and update data.
|
|
279
|
+
*/
|
|
280
|
+
interface ISystemContextEntity {
|
|
281
|
+
/**
|
|
282
|
+
* The immutable entity associated with the system context.
|
|
283
|
+
*/
|
|
284
|
+
readonly entity: Immutable<IEntity>;
|
|
285
|
+
/**
|
|
286
|
+
* The immutable entity update associated with the system context.
|
|
287
|
+
*/
|
|
288
|
+
readonly update: Immutable<IEntityUpdate>;
|
|
289
|
+
/**
|
|
290
|
+
* Sets the entity associated with the system context entity.
|
|
291
|
+
*
|
|
292
|
+
* @param entity - The new entity to be associated with the system context.
|
|
293
|
+
*/
|
|
294
|
+
setEntity(entity: IEntity): void;
|
|
295
|
+
/**
|
|
296
|
+
* Sets the entity update associated with the system context.
|
|
297
|
+
*
|
|
298
|
+
* @param update - The new entity update to be associated with the system context.
|
|
299
|
+
*/
|
|
300
|
+
setUpdate(update: IEntityUpdate): void;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The ISystemsRuntimeContext is the Context passed by a SystemsRuntimePipeline.
|
|
305
|
+
* It helps orchestrate the execution of SystemPipelines registered in the SystemsModule.
|
|
306
|
+
*/
|
|
307
|
+
interface ISystemsRuntimeContext<TEntity extends IEntity> extends IPipelineContext {
|
|
308
|
+
/**
|
|
309
|
+
* A Set of allowed steps for the SystemPipelines.
|
|
310
|
+
*/
|
|
311
|
+
readonly allowedSteps: Set<SystemType>;
|
|
312
|
+
/**
|
|
313
|
+
* An entity provider for the SystemPipelines.
|
|
314
|
+
*/
|
|
315
|
+
readonly entityProvider: ISystemContextEntity;
|
|
316
|
+
/**
|
|
317
|
+
* An entity repository for the SystemPipelines.
|
|
318
|
+
*/
|
|
319
|
+
readonly entityRepository: IEntityRepository;
|
|
320
|
+
/**
|
|
321
|
+
* A Map of SystemPipelines registered in the SystemsModule.
|
|
322
|
+
*/
|
|
323
|
+
readonly systemPipelines: Map<SystemType, IPipeline<ISystemContext<TEntity>>>;
|
|
324
|
+
/**
|
|
325
|
+
* The SystemContext for the SystemPipelines.
|
|
326
|
+
*/
|
|
327
|
+
readonly systemContext: ISystemContext<TEntity>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
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 };
|