@codehz/ecs 0.6.9 → 0.6.10
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/builder.d.mts +20 -3
- package/package.json +1 -1
- package/world.mjs +250 -113
- package/world.mjs.map +1 -1
package/builder.d.mts
CHANGED
|
@@ -64,10 +64,11 @@ declare function decodeRelationId(relationId: RelationId<any>): {
|
|
|
64
64
|
};
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/core/component-registry.d.ts
|
|
67
|
+
type ComponentMerge<T = any> = (prev: T, next: T) => T;
|
|
67
68
|
/**
|
|
68
69
|
* Component options that define intrinsic properties
|
|
69
70
|
*/
|
|
70
|
-
interface ComponentOptions {
|
|
71
|
+
interface ComponentOptions<T = any> {
|
|
71
72
|
/**
|
|
72
73
|
* Optional name for the component (for serialization/debugging)
|
|
73
74
|
*/
|
|
@@ -93,6 +94,10 @@ interface ComponentOptions {
|
|
|
93
94
|
* Inspired by Flecs' DontFragment trait.
|
|
94
95
|
*/
|
|
95
96
|
dontFragment?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Custom merge behavior for repeated set() of the same componentType in a single sync batch.
|
|
99
|
+
*/
|
|
100
|
+
merge?: ComponentMerge<T>;
|
|
96
101
|
}
|
|
97
102
|
/**
|
|
98
103
|
* Allocate a new component ID from the global allocator.
|
|
@@ -108,7 +113,7 @@ interface ComponentOptions {
|
|
|
108
113
|
* // With name and options
|
|
109
114
|
* const ChildOf = component({ name: "ChildOf", exclusive: true });
|
|
110
115
|
*/
|
|
111
|
-
declare function component<T = void>(nameOrOptions?: string | ComponentOptions): ComponentId<T>;
|
|
116
|
+
declare function component<T = void>(nameOrOptions?: string | ComponentOptions<T>): ComponentId<T>;
|
|
112
117
|
/**
|
|
113
118
|
* Get a component ID by its registered name
|
|
114
119
|
* @param name The component name
|
|
@@ -286,6 +291,7 @@ declare class Archetype {
|
|
|
286
291
|
addEntity(entityId: EntityId, componentData: Map<EntityId<any>, any>): void;
|
|
287
292
|
private addDontFragmentRelations;
|
|
288
293
|
getEntity(entityId: EntityId): Map<EntityId<any>, any> | undefined;
|
|
294
|
+
getEntityDontFragmentRelations(entityId: EntityId): Map<EntityId<any>, any> | undefined;
|
|
289
295
|
dump(): Array<{
|
|
290
296
|
entity: EntityId;
|
|
291
297
|
components: Map<EntityId<any>, any>;
|
|
@@ -457,9 +463,14 @@ declare class World {
|
|
|
457
463
|
private relationEntityIdsByTarget;
|
|
458
464
|
private queries;
|
|
459
465
|
private queryCache;
|
|
460
|
-
private commandBuffer;
|
|
461
466
|
private legacyHooks;
|
|
462
467
|
private hooks;
|
|
468
|
+
private commandBuffer;
|
|
469
|
+
private readonly _changeset;
|
|
470
|
+
/** Cached command processor context to avoid per-entity object allocation */
|
|
471
|
+
private readonly _commandCtx;
|
|
472
|
+
/** Cached hooks context to avoid per-entity object allocation */
|
|
473
|
+
private readonly _hooksCtx;
|
|
463
474
|
constructor(snapshot?: SerializedWorld);
|
|
464
475
|
private deserializeSnapshot;
|
|
465
476
|
private createArchetypeSignature;
|
|
@@ -495,6 +506,12 @@ declare class World {
|
|
|
495
506
|
* }
|
|
496
507
|
*/
|
|
497
508
|
exists(entityId: EntityId): boolean;
|
|
509
|
+
private assertEntityExists;
|
|
510
|
+
private assertComponentTypeValid;
|
|
511
|
+
private assertSetComponentTypeValid;
|
|
512
|
+
private resolveSetOperation;
|
|
513
|
+
private resolveRemoveOperation;
|
|
514
|
+
private getComponentEntityWildcardRelations;
|
|
498
515
|
/**
|
|
499
516
|
* Adds or updates a component on an entity (or marks void component as present).
|
|
500
517
|
* The change is buffered and takes effect after calling `world.sync()`.
|