@awesome-ecs/abstract 0.32.1 → 0.33.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.
- package/README.md +1 -2
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.mts +1 -1
- package/dist/entities/index.cjs +1 -19
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +3 -3
- package/dist/entities/index.d.mts +3 -3
- package/dist/entities/index.mjs +1 -19
- package/dist/entities/index.mjs.map +1 -1
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +2 -2
- package/dist/factories/index.d.mts +2 -2
- package/dist/factories/index.mjs.map +1 -1
- package/dist/{index-vpjRaGIC.d.mts → index--9JJtMKF.d.mts} +83 -254
- package/dist/{index-BOsrKTWm.d.cts → index-0hg5PXZe.d.cts} +83 -254
- package/dist/{index-BD7sDB60.d.mts → index-BOS-47DQ.d.mts} +137 -298
- package/dist/{index-CeqaKmWR.d.mts → index-Bl7Cf9gi.d.cts} +11 -11
- package/dist/{index-BJFNTFDd.d.cts → index-CPGVaS-_.d.cts} +137 -298
- package/dist/{index-DMTkNY1e.d.cts → index-DXbpfhHa.d.mts} +11 -11
- package/dist/{index-C5nragoq.d.cts → index-HeCQLTSE.d.cts} +11 -3
- package/dist/{index-BlP67nCr.d.mts → index-Tznk33g6.d.mts} +11 -3
- package/dist/pipelines/index.d.cts +2 -2
- package/dist/pipelines/index.d.mts +2 -2
- package/dist/systems/index.cjs +8 -5
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +84 -2
- package/dist/systems/index.d.mts +84 -2
- package/dist/systems/index.mjs +8 -5
- package/dist/systems/index.mjs.map +1 -1
- package/dist/{types-Bbmnq4ni.d.cts → types-COxeVghs.d.cts} +19 -4
- package/dist/{types-C1ojaDL4.d.mts → types-UnqKSA14.d.mts} +19 -4
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as DeepPartial } from "./types-
|
|
1
|
+
import { a as IEntity, c as IEntityProxy, i as EntityUid, m as IComponent, n as IdentityComponent, o as IEntityModel, p as ComponentTypeUid, r as EntityTypeUid, v as ConfigRecord } from "./index-HeCQLTSE.cjs";
|
|
2
|
+
import { n as DeepPartial } from "./types-COxeVghs.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/entities/entity-config.d.ts
|
|
5
5
|
/**
|
|
@@ -16,54 +16,13 @@ interface IEntityConfigSnapshot<TConfig extends ConfigRecord = ConfigRecord> {
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/entities/entity-context-cache.d.ts
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* Each package registers its own per-entity data using its own key constants.
|
|
22
|
-
* Disposal removes all entries for an entity in a single call, covering all packages.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* // Core stores SystemContext:
|
|
26
|
-
* cache.set(entityUid, SYSTEM_KEY, systemContext);
|
|
27
|
-
*
|
|
28
|
-
* // AI stores per-module StateContexts:
|
|
29
|
-
* cache.set(entityUid, `state:${moduleName}`, stateContext);
|
|
30
|
-
*
|
|
31
|
-
* // On removal, one call cleans up everything:
|
|
32
|
-
* cache.disposeEntity(entityUid);
|
|
19
|
+
* Flat per-entity key-value storage for runtime-owned cached context objects.
|
|
33
20
|
*/
|
|
34
21
|
interface IEntityContextCache {
|
|
35
|
-
/**
|
|
36
|
-
* Retrieves a cached value by entity UID and key.
|
|
37
|
-
* @template T - The expected value type.
|
|
38
|
-
* @param entityUid - The entity's unique identifier.
|
|
39
|
-
* @param key - The key to look up.
|
|
40
|
-
* @returns The cached value, or undefined if not found.
|
|
41
|
-
*/
|
|
42
22
|
get<T>(entityUid: EntityUid, key: string | symbol): T | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Stores a value for an entity under the given key.
|
|
45
|
-
* @param entityUid - The entity's unique identifier.
|
|
46
|
-
* @param key - The key to store under.
|
|
47
|
-
* @param value - The value to cache.
|
|
48
|
-
*/
|
|
49
23
|
set(entityUid: EntityUid, key: string | symbol, value: unknown): void;
|
|
50
|
-
/**
|
|
51
|
-
* Checks whether a cached entry exists.
|
|
52
|
-
* @param entityUid - The entity's unique identifier.
|
|
53
|
-
* @param key - Optional key to check. If omitted, checks if any entry exists for the entity.
|
|
54
|
-
*/
|
|
55
24
|
has(entityUid: EntityUid, key?: string | symbol): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Returns an iterator over all key-value pairs cached for the given entity.
|
|
58
|
-
* @param entityUid - The entity's unique identifier.
|
|
59
|
-
* @returns An iterable iterator of [key, value] pairs, or undefined if the entity has no entries.
|
|
60
|
-
*/
|
|
61
25
|
getEntries(entityUid: EntityUid): IterableIterator<[string | symbol, unknown]> | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Removes all cached entries for the given entity.
|
|
64
|
-
* Should be called when an entity is removed from the system.
|
|
65
|
-
* @param entityUid - The entity's unique identifier.
|
|
66
|
-
*/
|
|
67
26
|
disposeEntity(entityUid: EntityUid): void;
|
|
68
27
|
}
|
|
69
28
|
//#endregion
|
|
@@ -211,6 +170,59 @@ interface IEntityEventsDispatcher {
|
|
|
211
170
|
broadcastEvents(events: IEntityEvent<IEventData>[]): void;
|
|
212
171
|
}
|
|
213
172
|
//#endregion
|
|
173
|
+
//#region src/entities/entity-repository.d.ts
|
|
174
|
+
/**
|
|
175
|
+
* Central storage for all active entities in the system.
|
|
176
|
+
* The repository provides CRUD operations and is the source of truth for entity existence and state.
|
|
177
|
+
* All entity access and modifications go through this repository.
|
|
178
|
+
*/
|
|
179
|
+
interface IEntityRepository {
|
|
180
|
+
/**
|
|
181
|
+
* The total number of entities currently stored.
|
|
182
|
+
*/
|
|
183
|
+
readonly size: number;
|
|
184
|
+
/**
|
|
185
|
+
* Checks if an entity exists in storage.
|
|
186
|
+
* @param proxy - Reference to the entity to check.
|
|
187
|
+
* @returns True if the entity exists, false otherwise.
|
|
188
|
+
*/
|
|
189
|
+
has(proxy: IEntityProxy): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves an entity from storage by proxy.
|
|
192
|
+
* @template TEntity - The expected entity type.
|
|
193
|
+
* @param proxy - Reference to the entity to retrieve.
|
|
194
|
+
* @returns The requested entity.
|
|
195
|
+
*/
|
|
196
|
+
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
197
|
+
/**
|
|
198
|
+
* Retrieves all entities of a specific type.
|
|
199
|
+
* @template TEntity - The entity type to retrieve.
|
|
200
|
+
* @param entityType - The type identifier to filter by.
|
|
201
|
+
* @returns Array of all entities matching the type.
|
|
202
|
+
*/
|
|
203
|
+
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
204
|
+
/**
|
|
205
|
+
* Iterates over all entities regardless of type.
|
|
206
|
+
* @returns An iterator over all stored entities.
|
|
207
|
+
*/
|
|
208
|
+
listAll(): IterableIterator<IEntity>;
|
|
209
|
+
/**
|
|
210
|
+
* Stores or updates an entity.
|
|
211
|
+
* @param entity - The entity to store.
|
|
212
|
+
*/
|
|
213
|
+
set(entity: IEntity): void;
|
|
214
|
+
/**
|
|
215
|
+
* Removes an entity from storage.
|
|
216
|
+
* @param proxy - Reference to the entity to remove.
|
|
217
|
+
*/
|
|
218
|
+
delete(proxy: IEntityProxy): void;
|
|
219
|
+
/**
|
|
220
|
+
* Removes all entities of a specific type from storage.
|
|
221
|
+
* @param entityType - The type identifier for entities to remove.
|
|
222
|
+
*/
|
|
223
|
+
clear(entityType: EntityTypeUid): void;
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
214
226
|
//#region src/entities/entity-snapshot.d.ts
|
|
215
227
|
/**
|
|
216
228
|
* A serializable representation of entity state.
|
|
@@ -258,237 +270,54 @@ interface IEntitySnapshotProvider {
|
|
|
258
270
|
createSnapshot(entity: IEntity): IEntitySnapshot;
|
|
259
271
|
}
|
|
260
272
|
//#endregion
|
|
261
|
-
//#region src/entities/entity-
|
|
262
|
-
/**
|
|
263
|
-
* Specifies the action to be performed on an entity.
|
|
264
|
-
* Updates are categorized to enable different processing paths in the runtime.
|
|
265
|
-
*/
|
|
273
|
+
//#region src/entities/entity-scheduler.d.ts
|
|
266
274
|
declare enum EntityUpdateType {
|
|
267
|
-
/**
|
|
268
|
-
* Indicates the entity should be updated with new data.
|
|
269
|
-
*/
|
|
270
275
|
update = "update",
|
|
271
|
-
/**
|
|
272
|
-
* Indicates the entity should be removed from the system.
|
|
273
|
-
*/
|
|
274
276
|
remove = "remove"
|
|
275
277
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Represents a queued entity state change or removal.
|
|
278
|
-
* Updates flow through the system to be processed by entity update handlers.
|
|
279
|
-
*/
|
|
280
278
|
interface IEntityUpdate {
|
|
281
|
-
/**
|
|
282
|
-
* The type of operation: update or remove.
|
|
283
|
-
*/
|
|
284
279
|
readonly type: EntityUpdateType;
|
|
285
|
-
/**
|
|
286
|
-
* The entity being affected by this update.
|
|
287
|
-
*/
|
|
288
280
|
readonly entity: IEntityProxy;
|
|
289
|
-
/**
|
|
290
|
-
* Optional model data for initialization or reconfiguration.
|
|
291
|
-
*/
|
|
292
281
|
readonly model?: IEntityModel;
|
|
293
|
-
/**
|
|
294
|
-
* Optional serialized state to apply to the entity.
|
|
295
|
-
*/
|
|
296
282
|
readonly snapshot?: IEntitySnapshot;
|
|
297
|
-
/**
|
|
298
|
-
* Optional config-only component state to apply to the entity.
|
|
299
|
-
* When present on an update, the runtime applies it after `snapshot` and
|
|
300
|
-
* includes the config system phase in the same tick.
|
|
301
|
-
*/
|
|
302
283
|
readonly config?: IEntityConfigSnapshot;
|
|
303
284
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
* The current number of updates in the queue.
|
|
312
|
-
*/
|
|
313
|
-
readonly size: number;
|
|
314
|
-
/**
|
|
315
|
-
* Adds an update to the queue for processing.
|
|
316
|
-
* @param change - The update to queue.
|
|
317
|
-
*/
|
|
318
|
-
enqueue(change: IEntityUpdate): void;
|
|
319
|
-
/**
|
|
320
|
-
* Removes and returns the next update from the queue.
|
|
321
|
-
* The specific update returned depends on the queue's prioritization strategy.
|
|
322
|
-
* @returns The next queued update.
|
|
323
|
-
*/
|
|
324
|
-
dequeue(): IEntityUpdate;
|
|
325
|
-
/**
|
|
326
|
-
* Views the next update without removing it.
|
|
327
|
-
* Useful for inspection before dequeuing.
|
|
328
|
-
* @returns The next update in the queue.
|
|
329
|
-
*/
|
|
330
|
-
peek(): IEntityUpdate;
|
|
331
|
-
/**
|
|
332
|
-
* Returns a read-only snapshot of all queued updates without removing them.
|
|
333
|
-
* Useful for inspection/debugging UIs.
|
|
334
|
-
* @returns An array of all currently queued updates.
|
|
335
|
-
*/
|
|
336
|
-
items(): ReadonlyArray<IEntityUpdate>;
|
|
337
|
-
/**
|
|
338
|
-
* Removes all updates from the queue.
|
|
339
|
-
*/
|
|
340
|
-
clear(): void;
|
|
341
|
-
}
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/entities/entity-repository.d.ts
|
|
344
|
-
/**
|
|
345
|
-
* Central storage for all active entities in the system.
|
|
346
|
-
* The repository provides CRUD operations and is the source of truth for entity existence and state.
|
|
347
|
-
* All entity access and modifications go through this repository.
|
|
348
|
-
*/
|
|
349
|
-
interface IEntityRepository {
|
|
350
|
-
/**
|
|
351
|
-
* The total number of entities currently stored.
|
|
352
|
-
*/
|
|
353
|
-
readonly size: number;
|
|
354
|
-
/**
|
|
355
|
-
* Checks if an entity exists in storage.
|
|
356
|
-
* @param proxy - Reference to the entity to check.
|
|
357
|
-
* @returns True if the entity exists, false otherwise.
|
|
358
|
-
*/
|
|
359
|
-
has(proxy: IEntityProxy): boolean;
|
|
360
|
-
/**
|
|
361
|
-
* Retrieves an entity from storage by proxy.
|
|
362
|
-
* @template TEntity - The expected entity type.
|
|
363
|
-
* @param proxy - Reference to the entity to retrieve.
|
|
364
|
-
* @returns The requested entity.
|
|
365
|
-
*/
|
|
366
|
-
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
367
|
-
/**
|
|
368
|
-
* Retrieves all entities of a specific type.
|
|
369
|
-
* @template TEntity - The entity type to retrieve.
|
|
370
|
-
* @param entityType - The type identifier to filter by.
|
|
371
|
-
* @returns Array of all entities matching the type.
|
|
372
|
-
*/
|
|
373
|
-
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
374
|
-
/**
|
|
375
|
-
* Iterates over all entities regardless of type.
|
|
376
|
-
* @returns An iterator over all stored entities.
|
|
377
|
-
*/
|
|
378
|
-
listAll(): IterableIterator<IEntity>;
|
|
379
|
-
/**
|
|
380
|
-
* Stores or updates an entity.
|
|
381
|
-
* @param entity - The entity to store.
|
|
382
|
-
*/
|
|
383
|
-
set(entity: IEntity): void;
|
|
384
|
-
/**
|
|
385
|
-
* Removes an entity from storage.
|
|
386
|
-
* @param proxy - Reference to the entity to remove.
|
|
387
|
-
*/
|
|
388
|
-
delete(proxy: IEntityProxy): void;
|
|
389
|
-
/**
|
|
390
|
-
* Removes all entities of a specific type from storage.
|
|
391
|
-
* @param entityType - The type identifier for entities to remove.
|
|
392
|
-
*/
|
|
393
|
-
clear(entityType: EntityTypeUid): void;
|
|
285
|
+
interface IEntityDispatchGroup {
|
|
286
|
+
readonly entityType: EntityTypeUid;
|
|
287
|
+
readonly updates: ReadonlyArray<IEntityUpdate>;
|
|
288
|
+
readonly dirtyUpdates: number;
|
|
289
|
+
readonly scheduledUpdates: number;
|
|
290
|
+
readonly removeUpdates: number;
|
|
291
|
+
readonly pipelineMask?: number;
|
|
394
292
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
* Describes a scheduled entity update, including the target entity and optional interval.
|
|
399
|
-
*/
|
|
293
|
+
type EntityRuntimePendingGroupOptions = {
|
|
294
|
+
readonly includeFrameSubscriptions?: boolean;
|
|
295
|
+
};
|
|
400
296
|
type EntitySchedule = {
|
|
401
297
|
readonly proxy: IEntityProxy;
|
|
402
298
|
readonly intervalMs?: number;
|
|
403
299
|
};
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
300
|
+
type EntityPriorityModel = {
|
|
301
|
+
readonly defaultPriority?: number;
|
|
302
|
+
readonly entityTypes?: ReadonlyMap<EntityTypeUid, number>;
|
|
303
|
+
};
|
|
407
304
|
declare enum SchedulerPauseType {
|
|
408
|
-
/** Pause both interval timers and frame subscriptions. */
|
|
409
305
|
full = "full",
|
|
410
|
-
/** Pause only frame subscriptions. Interval timers continue firing. */
|
|
411
306
|
perFrame = "perFrame",
|
|
412
|
-
/** Pause only interval timers. Frame subscriptions continue. */
|
|
413
307
|
intervals = "intervals"
|
|
414
308
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
* Entities can be scheduled with an interval (timer-driven) or without one (per-frame).
|
|
419
|
-
* The runtime pulls pending entities each tick via the {@link pending} iterator,
|
|
420
|
-
* which yields both per-frame subscriptions and interval entities whose timer has fired.
|
|
421
|
-
*/
|
|
422
|
-
interface IEntityScheduler {
|
|
423
|
-
/**
|
|
424
|
-
* Returns all currently scheduled entities with their configuration.
|
|
425
|
-
* Useful for inspection and debugging.
|
|
426
|
-
*/
|
|
427
|
-
readonly schedules: ReadonlyArray<EntitySchedule>;
|
|
428
|
-
/**
|
|
429
|
-
* Yields entities pending processing this tick: per-frame subscriptions
|
|
430
|
-
* followed by interval entities whose timer has fired since the last drain.
|
|
431
|
-
* Iterating drains the due interval buckets; a second iteration without
|
|
432
|
-
* timer advancement yields only per-frame subscriptions.
|
|
433
|
-
*/
|
|
434
|
-
readonly pending: IterableIterator<IEntityProxy>;
|
|
435
|
-
/**
|
|
436
|
-
* The set of entities scheduled for per-frame updates (no interval).
|
|
437
|
-
*/
|
|
438
|
-
readonly frameSubscriptions: ReadonlySet<IEntityProxy>;
|
|
439
|
-
/**
|
|
440
|
-
* Entity types currently excluded from {@link pending} iteration.
|
|
441
|
-
*/
|
|
442
|
-
readonly skippedEntityTypes: ReadonlySet<EntityTypeUid>;
|
|
443
|
-
/**
|
|
444
|
-
* The number of entities currently awaiting processing:
|
|
445
|
-
* per-frame subscriptions (if not paused) plus interval entities whose timer has fired.
|
|
446
|
-
*/
|
|
309
|
+
interface IEntityRuntimeScheduler {
|
|
310
|
+
readonly dirtyCount: number;
|
|
311
|
+
readonly rawDirtyCount: number;
|
|
447
312
|
readonly pendingCount: number;
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
* @param intervalMs - Update frequency in milliseconds. If omitted, the entity is scheduled per-frame.
|
|
456
|
-
*/
|
|
457
|
-
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
458
|
-
/**
|
|
459
|
-
* Unregisters an entity from the scheduler.
|
|
460
|
-
* @param entityProxy - The entity to unschedule.
|
|
461
|
-
*/
|
|
462
|
-
remove(entityProxy: IEntityProxy): void;
|
|
463
|
-
/**
|
|
464
|
-
* Checks if an entity is currently scheduled for updates.
|
|
465
|
-
* @param entityProxy - The entity to check.
|
|
466
|
-
* @returns True if the entity is scheduled, false otherwise.
|
|
467
|
-
*/
|
|
468
|
-
has(entityProxy: IEntityProxy): boolean;
|
|
469
|
-
/**
|
|
470
|
-
* Removes all schedules and clears all timers.
|
|
471
|
-
*/
|
|
472
|
-
clear(): void;
|
|
473
|
-
/**
|
|
474
|
-
* Excludes an entity type from {@link pending} iteration.
|
|
475
|
-
* Entities remain registered; only yielding is suppressed.
|
|
476
|
-
*/
|
|
477
|
-
skipEntityType(entityType: EntityTypeUid): void;
|
|
478
|
-
/**
|
|
479
|
-
* Re-includes a previously skipped entity type in {@link pending} iteration.
|
|
480
|
-
*/
|
|
481
|
-
unskipEntityType(entityType: EntityTypeUid): void;
|
|
482
|
-
/**
|
|
483
|
-
* Pauses the scheduler.
|
|
484
|
-
* @param type - Which scheduling modes to pause. Defaults to {@link SchedulerPauseType.full}.
|
|
485
|
-
*/
|
|
486
|
-
pause(type?: SchedulerPauseType): void;
|
|
487
|
-
/**
|
|
488
|
-
* Resumes the scheduler from any paused state.
|
|
489
|
-
*/
|
|
490
|
-
resume(): void;
|
|
313
|
+
enqueue(update: IEntityUpdate): void;
|
|
314
|
+
enqueueEvent(entity: IEntityProxy, event: IEntityEvent<IEventData>): void;
|
|
315
|
+
enqueueEvents(entity: IEntityProxy, events: ReadonlyArray<IEntityEvent<IEventData>>): void;
|
|
316
|
+
schedule(proxy: IEntityProxy, intervalMs?: number): void;
|
|
317
|
+
removeSchedule(proxy: IEntityProxy): void;
|
|
318
|
+
hasSchedule(proxy: IEntityProxy): boolean;
|
|
319
|
+
takePendingGroups(maxItems?: number, options?: EntityRuntimePendingGroupOptions): ReadonlyArray<IEntityDispatchGroup>;
|
|
491
320
|
}
|
|
492
321
|
//#endregion
|
|
493
|
-
export {
|
|
494
|
-
//# sourceMappingURL=index-
|
|
322
|
+
export { IEntityEventsManager as _, IEntityDispatchGroup as a, IEntityConfigSnapshot as b, SchedulerPauseType as c, IEntityRepository as d, EntityEventSubscriptionFilter as f, IEntityEventsDispatcher as g, IEntityEvent as h, EntityUpdateType as i, IEntitySnapshot as l, EntityEventUid as m, EntityRuntimePendingGroupOptions as n, IEntityRuntimeScheduler as o, EntityEventSubscriptionOptions as p, EntitySchedule as r, IEntityUpdate as s, EntityPriorityModel as t, IEntitySnapshotProvider as u, IEventData as v, IEntityContextCache as y };
|
|
323
|
+
//# sourceMappingURL=index-0hg5PXZe.d.cts.map
|