ecspresso 0.14.5 → 0.14.7
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/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/plugins/ai/behavior-tree.js +2 -2
- package/dist/plugins/ai/behavior-tree.js.map +2 -2
- package/dist/plugins/ai/detection.js +2 -2
- package/dist/plugins/ai/detection.js.map +2 -2
- package/dist/plugins/ai/flocking.js +2 -2
- package/dist/plugins/ai/flocking.js.map +2 -2
- package/dist/plugins/ai/pathfinding.js +2 -2
- package/dist/plugins/ai/pathfinding.js.map +2 -2
- package/dist/plugins/audio/audio.js +2 -2
- package/dist/plugins/audio/audio.js.map +2 -2
- package/dist/plugins/combat/health.js +2 -2
- package/dist/plugins/combat/health.js.map +2 -2
- package/dist/plugins/combat/projectile.js +2 -2
- package/dist/plugins/combat/projectile.js.map +2 -2
- package/dist/plugins/debug/diagnostics.js +3 -3
- package/dist/plugins/debug/diagnostics.js.map +2 -2
- package/dist/plugins/input/input.js +2 -2
- package/dist/plugins/input/input.js.map +2 -2
- package/dist/plugins/input/selection.js +2 -2
- package/dist/plugins/input/selection.js.map +3 -3
- package/dist/plugins/isometric/depth-sort.js +2 -2
- package/dist/plugins/isometric/depth-sort.js.map +2 -2
- package/dist/plugins/isometric/projection.js +2 -2
- package/dist/plugins/isometric/projection.js.map +2 -2
- package/dist/plugins/physics/collision.js +2 -2
- package/dist/plugins/physics/collision.js.map +2 -2
- package/dist/plugins/physics/collision3D.js +2 -2
- package/dist/plugins/physics/collision3D.js.map +2 -2
- package/dist/plugins/physics/physics2D.js +2 -2
- package/dist/plugins/physics/physics2D.js.map +2 -2
- package/dist/plugins/physics/physics3D.js +2 -2
- package/dist/plugins/physics/physics3D.js.map +2 -2
- package/dist/plugins/physics/steering.js +2 -2
- package/dist/plugins/physics/steering.js.map +2 -2
- package/dist/plugins/rendering/particles.js +2 -2
- package/dist/plugins/rendering/particles.js.map +2 -2
- package/dist/plugins/rendering/renderer2D.js +2 -2
- package/dist/plugins/rendering/renderer2D.js.map +2 -2
- package/dist/plugins/rendering/renderer3D.js +2 -4105
- package/dist/plugins/rendering/renderer3D.js.map +3 -5
- package/dist/plugins/rendering/sprite-animation.js +2 -2
- package/dist/plugins/rendering/sprite-animation.js.map +2 -2
- package/dist/plugins/rendering/tilemap.js +2 -2
- package/dist/plugins/rendering/tilemap.js.map +2 -2
- package/dist/plugins/scripting/coroutine.js +2 -2
- package/dist/plugins/scripting/coroutine.js.map +2 -2
- package/dist/plugins/scripting/state-machine.js +2 -2
- package/dist/plugins/scripting/state-machine.js.map +2 -2
- package/dist/plugins/scripting/timers.js +2 -2
- package/dist/plugins/scripting/timers.js.map +2 -2
- package/dist/plugins/scripting/tween.js +2 -2
- package/dist/plugins/scripting/tween.js.map +2 -2
- package/dist/plugins/spatial/bounds.js +2 -2
- package/dist/plugins/spatial/bounds.js.map +2 -2
- package/dist/plugins/spatial/camera.js +2 -2
- package/dist/plugins/spatial/camera.js.map +3 -3
- package/dist/plugins/spatial/camera3D.js +2 -2
- package/dist/plugins/spatial/camera3D.js.map +3 -3
- package/dist/plugins/spatial/spatial-index.js +2 -2
- package/dist/plugins/spatial/spatial-index.js.map +2 -2
- package/dist/plugins/spatial/spatial-index3D.js +2 -2
- package/dist/plugins/spatial/spatial-index3D.js.map +2 -2
- package/dist/plugins/spatial/transform.js +2 -2
- package/dist/plugins/spatial/transform.js.map +2 -2
- package/dist/plugins/spatial/transform3D.js +2 -2
- package/dist/plugins/spatial/transform3D.js.map +2 -2
- package/dist/plugins/ui/ui.d.ts +40 -8
- package/dist/plugins/ui/ui.js +2 -2
- package/dist/plugins/ui/ui.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"sources": ["../src/hierarchy-manager.ts", "../src/entity-manager.ts", "../src/event-bus.ts", "../src/resource-manager.ts", "../src/reactive-query-manager.ts", "../src/command-buffer.ts", "../src/plugin.ts", "../src/system-builder.ts", "../src/utils/check-required-cycle.ts", "../src/asset-manager.ts", "../src/screen-manager.ts", "../src/ecspresso-builder.ts", "../src/ecspresso.ts", "../src/types.ts", "../src/utils/math.ts", "../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { HierarchyEntry, HierarchyIteratorOptions } from \"./types\";\n\n/**\n * Manages parent-child relationships between entities.\n * Handles hierarchy storage, validation, and traversal operations.\n */\nexport default class HierarchyManager {\n\t/** childId -> parentId */\n\tprivate parentMap: Map<number, number> = new Map();\n\t/** parentId -> ordered childIds */\n\tprivate childrenMap: Map<number, number[]> = new Map();\n\t/** Pre-allocated flat BFS queue for forEachInHierarchy [entityId, parentId (-1=null), depth, ...] */\n\tprivate _bfsQueue: number[] = [];\n\n\t/**\n\t * Set the parent of an entity.\n\t * @param childId The entity to set as a child\n\t * @param parentId The entity to set as the parent\n\t * @throws Error if this would create a circular reference or self-parenting\n\t */\n\tsetParent(childId: number, parentId: number): this {\n\t\tif (childId === parentId) {\n\t\t\tthrow new Error(`Cannot set entity ${childId} as its own parent`);\n\t\t}\n\n\t\t// Check for circular reference by walking up from the prospective parent\n\t\tif (this.wouldCreateCycle(childId, parentId)) {\n\t\t\tthrow new Error('Cannot set parent: would create circular reference');\n\t\t}\n\n\t\t// Remove from old parent's children list if exists\n\t\tconst oldParent = this.parentMap.get(childId);\n\t\tif (oldParent !== undefined) {\n\t\t\tconst oldChildren = this.childrenMap.get(oldParent);\n\t\t\tif (oldChildren) {\n\t\t\t\tconst idx = oldChildren.indexOf(childId);\n\t\t\t\tif (idx !== -1) {\n\t\t\t\t\toldChildren.splice(idx, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Set new parent\n\t\tthis.parentMap.set(childId, parentId);\n\n\t\t// Add to new parent's children list\n\t\tconst children = this.childrenMap.get(parentId);\n\t\tif (children) {\n\t\t\tchildren.push(childId);\n\t\t} else {\n\t\t\tthis.childrenMap.set(parentId, [childId]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Remove the parent relationship for an entity (orphan it).\n\t * @param childId The entity to orphan\n\t * @returns true if a parent was removed, false if entity had no parent\n\t */\n\tremoveParent(childId: number): boolean {\n\t\tconst parentId = this.parentMap.get(childId);\n\t\tif (parentId === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Remove from parent's children list\n\t\tconst children = this.childrenMap.get(parentId);\n\t\tif (children) {\n\t\t\tconst idx = children.indexOf(childId);\n\t\t\tif (idx !== -1) {\n\t\t\t\tchildren.splice(idx, 1);\n\t\t\t}\n\t\t}\n\n\t\tthis.parentMap.delete(childId);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Get the parent of an entity.\n\t * @param entityId The entity to get the parent of\n\t * @returns The parent entity ID, or null if no parent\n\t */\n\tgetParent(entityId: number): number | null {\n\t\treturn this.parentMap.get(entityId) ?? null;\n\t}\n\n\t/**\n\t * Get all children of an entity in insertion order.\n\t * @param parentId The parent entity\n\t * @returns Readonly array of child entity IDs\n\t */\n\tgetChildren(parentId: number): readonly number[] {\n\t\tconst children = this.childrenMap.get(parentId);\n\t\treturn children ? [...children] : [];\n\t}\n\n\t/**\n\t * Get a child at a specific index.\n\t * @param parentId The parent entity\n\t * @param index The index of the child\n\t * @returns The child entity ID, or null if index is out of bounds\n\t */\n\tgetChildAt(parentId: number, index: number): number | null {\n\t\tif (index < 0) return null;\n\t\tconst children = this.childrenMap.get(parentId);\n\t\tif (!children || index >= children.length) return null;\n\t\treturn children[index] ?? null;\n\t}\n\n\t/**\n\t * Get the index of a child within its parent's children list.\n\t * @param parentId The parent entity\n\t * @param childId The child entity to find\n\t * @returns The index of the child, or -1 if not found\n\t */\n\tgetChildIndex(parentId: number, childId: number): number {\n\t\tconst children = this.childrenMap.get(parentId);\n\t\tif (!children) return -1;\n\t\treturn children.indexOf(childId);\n\t}\n\n\t/**\n\t * Remove an entity from the hierarchy (called when entity is destroyed).\n\t * Orphans any children and removes from parent's children list.\n\t * @param entityId The entity being removed\n\t * @returns Information about the removal (oldParent and orphanedChildren)\n\t */\n\tremoveEntity(entityId: number): { oldParent: number | null; orphanedChildren: number[] } {\n\t\tconst oldParent = this.parentMap.get(entityId) ?? null;\n\n\t\t// Remove from parent's children list\n\t\tif (oldParent !== null) {\n\t\t\tconst parentChildren = this.childrenMap.get(oldParent);\n\t\t\tif (parentChildren) {\n\t\t\t\tconst idx = parentChildren.indexOf(entityId);\n\t\t\t\tif (idx !== -1) {\n\t\t\t\t\tparentChildren.splice(idx, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.parentMap.delete(entityId);\n\n\t\t// Orphan all children\n\t\tconst children = this.childrenMap.get(entityId) ?? [];\n\t\tconst orphanedChildren = [...children];\n\t\tfor (const childId of children) {\n\t\t\tthis.parentMap.delete(childId);\n\t\t}\n\t\tthis.childrenMap.delete(entityId);\n\n\t\treturn { oldParent, orphanedChildren };\n\t}\n\n\t/**\n\t * Get all ancestors of an entity in order [parent, grandparent, ...].\n\t * @param entityId The entity to get ancestors of\n\t * @returns Readonly array of ancestor entity IDs\n\t */\n\tgetAncestors(entityId: number): readonly number[] {\n\t\tconst ancestors: number[] = [];\n\t\tlet current = this.parentMap.get(entityId);\n\t\twhile (current !== undefined) {\n\t\t\tancestors.push(current);\n\t\t\tcurrent = this.parentMap.get(current);\n\t\t}\n\t\treturn ancestors;\n\t}\n\n\t/**\n\t * Get all descendants of an entity in depth-first order.\n\t * @param entityId The entity to get descendants of\n\t * @returns Readonly array of descendant entity IDs\n\t */\n\tgetDescendants(entityId: number): readonly number[] {\n\t\tconst descendants: number[] = [];\n\t\tconst initialChildren = this.childrenMap.get(entityId);\n\t\tif (!initialChildren) return descendants;\n\n\t\t// Use push/pop (O(1)) instead of shift/unshift (O(n)).\n\t\t// Seed stack in reverse so pop() yields children in original order.\n\t\tconst stack = initialChildren.slice().reverse();\n\n\t\twhile (stack.length > 0) {\n\t\t\tconst current = stack.pop() as number;\n\t\t\tdescendants.push(current);\n\t\t\tconst children = this.childrenMap.get(current);\n\t\t\tif (children) {\n\t\t\t\tfor (let i = children.length - 1; i >= 0; i--) {\n\t\t\t\t\tstack.push(children[i] as number);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn descendants;\n\t}\n\n\t/**\n\t * Get the root ancestor of an entity (topmost parent), or self if no parent.\n\t * @param entityId The entity to get the root of\n\t * @returns The root entity ID\n\t */\n\tgetRoot(entityId: number): number {\n\t\tlet current = entityId;\n\t\tlet parent = this.parentMap.get(current);\n\t\twhile (parent !== undefined) {\n\t\t\tcurrent = parent;\n\t\t\tparent = this.parentMap.get(current);\n\t\t}\n\t\treturn current;\n\t}\n\n\t/**\n\t * Get siblings of an entity (other children of the same parent).\n\t * @param entityId The entity to get siblings of\n\t * @returns Readonly array of sibling entity IDs\n\t */\n\tgetSiblings(entityId: number): readonly number[] {\n\t\tconst parentId = this.parentMap.get(entityId);\n\t\tif (parentId === undefined) return [];\n\n\t\tconst children = this.childrenMap.get(parentId);\n\t\tif (!children) return [];\n\n\t\treturn children.filter(id => id !== entityId);\n\t}\n\n\t/**\n\t * Check if an entity is a descendant of another entity.\n\t * @param entityId The potential descendant\n\t * @param ancestorId The potential ancestor\n\t * @returns true if entityId is a descendant of ancestorId\n\t */\n\tisDescendantOf(entityId: number, ancestorId: number): boolean {\n\t\tif (entityId === ancestorId) return false;\n\n\t\tlet current = this.parentMap.get(entityId);\n\t\twhile (current !== undefined) {\n\t\t\tif (current === ancestorId) return true;\n\t\t\tcurrent = this.parentMap.get(current);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if an entity is an ancestor of another entity.\n\t * @param entityId The potential ancestor\n\t * @param descendantId The potential descendant\n\t * @returns true if entityId is an ancestor of descendantId\n\t */\n\tisAncestorOf(entityId: number, descendantId: number): boolean {\n\t\treturn this.isDescendantOf(descendantId, entityId);\n\t}\n\n\t/**\n\t * Returns true when at least one parent-child relationship exists.\n\t * O(1) — checks Map size, no iteration.\n\t */\n\tget hasHierarchy(): boolean {\n\t\treturn this.childrenMap.size > 0;\n\t}\n\n\t/**\n\t * Get all root entities (entities that have children but no parent).\n\t * @returns Readonly array of root entity IDs\n\t */\n\tgetRootEntities(): readonly number[] {\n\t\tconst roots: number[] = [];\n\t\tfor (const parentId of this.childrenMap.keys()) {\n\t\t\tif (!this.parentMap.has(parentId)) {\n\t\t\t\troots.push(parentId);\n\t\t\t}\n\t\t}\n\t\treturn roots;\n\t}\n\n\t/**\n\t * Check if setting a parent would create a cycle.\n\t * A cycle would occur if the prospective parent is a descendant of the child.\n\t */\n\tprivate wouldCreateCycle(childId: number, parentId: number): boolean {\n\t\tlet current: number | undefined = parentId;\n\t\twhile (current !== undefined) {\n\t\t\tif (current === childId) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tcurrent = this.parentMap.get(current);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Traverse the hierarchy in parent-first (breadth-first) order.\n\t * Parents are guaranteed to be visited before their children.\n\t * @param callback Function called for each entity with (entityId, parentId, depth)\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t */\n\tforEachInHierarchy(\n\t\tcallback: (entityId: number, parentId: number | null, depth: number) => void,\n\t\toptions?: HierarchyIteratorOptions\n\t): void {\n\t\tconst roots = options?.roots ?? this.getRootEntities();\n\t\t// Flat queue with stride 3: [entityId, parentId (-1 for null), depth, ...]\n\t\tconst queue = this._bfsQueue;\n\t\tqueue.length = 0;\n\n\t\tfor (const id of roots) {\n\t\t\tqueue.push(id, -1, 0);\n\t\t}\n\n\t\tfor (let i = 0; i < queue.length; i += 3) {\n\t\t\tconst entityId = queue[i]!;\n\t\t\tconst rawParent = queue[i + 1]!;\n\t\t\tconst depth = queue[i + 2]!;\n\n\t\t\tcallback(entityId, rawParent === -1 ? null : rawParent, depth);\n\n\t\t\tconst children = this.childrenMap.get(entityId);\n\t\t\tif (children) {\n\t\t\t\tconst childDepth = depth + 1;\n\t\t\t\tfor (const childId of children) {\n\t\t\t\t\tqueue.push(childId, entityId, childDepth);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Generator-based hierarchy traversal in parent-first (breadth-first) order.\n\t * Supports early termination via break.\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t * @yields HierarchyEntry for each entity in parent-first order\n\t */\n\t*hierarchyIterator(options?: HierarchyIteratorOptions): Generator<HierarchyEntry, void, unknown> {\n\t\tconst roots = options?.roots ?? this.getRootEntities();\n\t\tconst queue: HierarchyEntry[] = [];\n\n\t\t// Initialize queue with root entities\n\t\tfor (const id of roots) {\n\t\t\tqueue.push({ entityId: id, parentId: null, depth: 0 });\n\t\t}\n\n\t\tfor (const current of queue) {\n\t\t\tyield current;\n\n\t\t\tconst children = this.childrenMap.get(current.entityId);\n\t\t\tif (children) {\n\t\t\t\tfor (const childId of children) {\n\t\t\t\t\tqueue.push({\n\t\t\t\t\t\tentityId: childId,\n\t\t\t\t\t\tparentId: current.entityId,\n\t\t\t\t\t\tdepth: current.depth + 1\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
6
|
-
"import type { Entity, FilteredEntity, RemoveEntityOptions, HierarchyEntry, HierarchyIteratorOptions } from \"./types\";\nimport HierarchyManager from \"./hierarchy-manager\";\n\n/** Returns true if `components` contains ALL keys in `required`. */\nfunction hasAllComponents(\n\tcomponents: Record<string | number | symbol, unknown>,\n\trequired: ReadonlyArray<string | number | symbol>,\n): boolean {\n\tfor (const key of required) {\n\t\tif (!(key in components)) return false;\n\t}\n\treturn true;\n}\n\n/** Returns true if `components` contains ANY key in `excluded`. */\nfunction hasAnyComponent(\n\tcomponents: Record<string | number | symbol, unknown>,\n\texcluded: ReadonlyArray<string | number | symbol>,\n): boolean {\n\tfor (const key of excluded) {\n\t\tif (key in components) return true;\n\t}\n\treturn false;\n}\n\n/** Returns true if any component in `changed` was modified after `threshold`. */\nfunction hasChangedComponent(\n\tentitySeqs: Map<string | number | symbol, number> | undefined,\n\tchanged: ReadonlyArray<string | number | symbol>,\n\tthreshold: number,\n): boolean {\n\tif (!entitySeqs) return false;\n\tfor (const key of changed) {\n\t\tif ((entitySeqs.get(key) ?? -1) > threshold) return true;\n\t}\n\treturn false;\n}\n\ntype ComponentCallback<ComponentTypes> = (ctx: { value: unknown; entity: Entity<ComponentTypes> }) => void;\n\n/**\n * Manages zero-allocation callback iteration with safe mid-iteration unsubscribe.\n * During iteration, unsubscribes are deferred. Snapshot length guarantees all\n * callbacks registered at call time execute. Compaction runs when iteration ends.\n */\nclass CallbackList<ComponentTypes> {\n\tprivate readonly callbacks: ComponentCallback<ComponentTypes>[] = [];\n\tprivate _iterDepth = 0;\n\tprivate _pendingRemovals: ComponentCallback<ComponentTypes>[] = [];\n\n\tadd(cb: ComponentCallback<ComponentTypes>): void {\n\t\tthis.callbacks.push(cb);\n\t}\n\n\tremove(cb: ComponentCallback<ComponentTypes>): void {\n\t\tif (this._iterDepth > 0) {\n\t\t\tthis._pendingRemovals.push(cb);\n\t\t\treturn;\n\t\t}\n\t\tconst idx = this.callbacks.indexOf(cb);\n\t\tif (idx !== -1) this.callbacks.splice(idx, 1);\n\t}\n\n\tinvoke(ctx: { value: unknown; entity: Entity<ComponentTypes> }): void {\n\t\tthis._iterDepth++;\n\t\tconst len = this.callbacks.length;\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tconst cb = this.callbacks[i];\n\t\t\tif (cb) cb(ctx);\n\t\t}\n\t\tthis._iterDepth--;\n\t\tif (this._iterDepth === 0 && this._pendingRemovals.length > 0) {\n\t\t\tfor (const cb of this._pendingRemovals) {\n\t\t\t\tconst idx = this.callbacks.indexOf(cb);\n\t\t\t\tif (idx !== -1) this.callbacks.splice(idx, 1);\n\t\t\t}\n\t\t\tthis._pendingRemovals.length = 0;\n\t\t}\n\t}\n}\n\nexport default\nclass EntityManager<ComponentTypes> {\n\tprivate nextId: number = 1;\n\tprivate entities: Map<number, Entity<ComponentTypes>> = new Map();\n\tprivate componentIndices: Map<keyof ComponentTypes, Set<number>> = new Map();\n\t/**\n\t * Callbacks registered for component additions\n\t */\n\tprivate addedCallbacks: Map<keyof ComponentTypes, CallbackList<ComponentTypes>> = new Map();\n\t/**\n\t * Callbacks registered for component removals\n\t */\n\tprivate removedCallbacks: Map<keyof ComponentTypes, CallbackList<ComponentTypes>> = new Map();\n\t/**\n\t * Hierarchy manager for parent-child relationships\n\t */\n\tprivate hierarchyManager: HierarchyManager = new HierarchyManager();\n\t/**\n\t * Per-type component dispose callbacks.\n\t * Called when a component is removed (explicit removal, entity destruction, or replacement).\n\t */\n\tprivate disposeCallbacks: Map<keyof ComponentTypes, (ctx: { value: unknown; entityId: number }) => void> = new Map();\n\t/**\n\t * Per-entity per-component change sequence tracking.\n\t * Maps entityId -> (componentName -> sequence number when last changed)\n\t */\n\tprivate changeSeqs: Map<number, Map<keyof ComponentTypes, number>> = new Map();\n\t/**\n\t * Monotonic sequence counter for change detection.\n\t * Each markChanged call increments this and stamps the new value.\n\t */\n\tprivate _changeSeq: number = 0;\n\n\t// ==================== Lifecycle Hook Arrays ====================\n\tprivate _afterComponentAddedHooks: Array<(entityId: number, componentName: keyof ComponentTypes) => void> = [];\n\tprivate _afterEntityMutatedHooks: Array<(entityId: number) => void> = [];\n\tprivate _afterComponentRemovedHooks: Array<(entityId: number, componentName: keyof ComponentTypes) => void> = [];\n\tprivate _beforeEntityRemovedHooks: Array<(entityId: number) => void> = [];\n\tprivate _afterParentChangedHooks: Array<(childId: number) => void> = [];\n\n\t// ==================== Batching Fields ====================\n\tprivate _batchingDepth: number = 0;\n\tprivate _batchedEntityIds: Set<number> = new Set();\n\t/** Component keys being added in the current addComponents batch, if any.\n\t * Used by required component resolution to skip auto-adding explicitly provided components. */\n\t_pendingBatchKeys: ReadonlySet<keyof ComponentTypes> | null = null;\n\n\tget entityCount(): number {\n\t\treturn this.entities.size;\n\t}\n\n\tcreateEntity(): Entity<ComponentTypes> {\n\t\tconst id = this.nextId++;\n\t\tconst entity: Entity<ComponentTypes> = { id, components: {} };\n\t\tthis.entities.set(id, entity);\n\t\treturn entity;\n\t}\n\n\t/**\n\t * Register a dispose callback for a component type.\n\t * Called when a component is removed (explicit removal, entity destruction, or replacement).\n\t * Later registrations replace earlier ones for the same component type.\n\t * @param componentName The component type to register disposal for\n\t * @param callback Function receiving the component value being disposed and the entity ID\n\t */\n\tregisterDispose<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\tcallback: (ctx: { value: ComponentTypes[ComponentName]; entityId: number }) => void\n\t): void {\n\t\tthis.disposeCallbacks.set(componentName, callback as (ctx: { value: unknown; entityId: number }) => void);\n\t}\n\n\t/**\n\t * Get all registered dispose callbacks.\n\t * @internal Used by ECSpresso for plugin installation\n\t */\n\tgetDisposeCallbacks(): Map<keyof ComponentTypes, (ctx: { value: unknown; entityId: number }) => void> {\n\t\treturn this.disposeCallbacks;\n\t}\n\n\t/**\n\t * Invoke the dispose callback for a component, if registered.\n\t * Errors are caught and logged to prevent blocking removal.\n\t */\n\tprivate invokeDispose<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\tvalue: ComponentTypes[ComponentName],\n\t\tentityId: number\n\t): void {\n\t\tconst cb = this.disposeCallbacks.get(componentName);\n\t\tif (!cb) return;\n\t\ttry {\n\t\t\tcb({ value, entityId });\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Component dispose callback for '${String(componentName)}' threw:`, error);\n\t\t}\n\t}\n\n\t// TODO: Component object pooling if(/when) garbage collection is an issue...?\n\taddComponent<ComponentName extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: ComponentName,\n\t\tdata: ComponentTypes[ComponentName]\n\t) {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Cannot add component '${String(componentName)}': Entity with ID ${entityId} does not exist`);\n\t\t}\n\n\t\t// Dispose old value if replacing an existing component\n\t\tconst existing = entity.components[componentName];\n\t\tif (existing !== undefined) {\n\t\t\tthis.invokeDispose(componentName, existing as ComponentTypes[ComponentName], entity.id);\n\t\t}\n\n\t\tentity.components[componentName] = data;\n\n\t\t// Update component index\n\t\tif (!this.componentIndices.has(componentName)) {\n\t\t\tthis.componentIndices.set(componentName, new Set());\n\t\t}\n\t\tthis.componentIndices.get(componentName)?.add(entity.id);\n\t\t// Trigger added callbacks (index-based iteration; unsubscribe nulls slots, compacted after)\n\t\tconst callbacks = this.addedCallbacks.get(componentName);\n\t\tif (callbacks) {\n\t\t\tcallbacks.invoke({ value: data, entity });\n\t\t}\n\n\t\t// Fire afterComponentAdded hooks (may trigger recursive addComponent)\n\t\tthis._batchingDepth++;\n\t\tfor (const hook of this._afterComponentAddedHooks) {\n\t\t\thook(entity.id, componentName);\n\t\t}\n\t\tthis._batchedEntityIds.add(entity.id);\n\t\tthis._batchingDepth--;\n\n\t\t// Flush afterEntityMutated when outermost batch completes\n\t\tif (this._batchingDepth === 0) {\n\t\t\tfor (const entityId of this._batchedEntityIds) {\n\t\t\t\tfor (const hook of this._afterEntityMutatedHooks) {\n\t\t\t\t\thook(entityId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._batchedEntityIds.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add multiple components to an entity at once\n\t * @param entityId Entity ID to add components to\n\t * @param components Object with component names as keys and component data as values\n\t */\n\taddComponents<\n\t\tT extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }\n\t>(\n\t\tentityId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t) {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Cannot add components: Entity with ID ${entityId} does not exist`);\n\t\t}\n\n\t\tconst outerPending = this._pendingBatchKeys;\n\t\tthis._pendingBatchKeys = new Set(Object.keys(components) as (keyof ComponentTypes)[]);\n\t\tthis._batchingDepth++;\n\t\tfor (const componentName in components) {\n\t\t\tthis.addComponent(\n\t\t\t\tentity.id,\n\t\t\t\tcomponentName as keyof ComponentTypes,\n\t\t\t\tcomponents[componentName as keyof T] as ComponentTypes[keyof ComponentTypes]\n\t\t\t);\n\t\t}\n\t\tthis._batchingDepth--;\n\t\tthis._pendingBatchKeys = outerPending;\n\n\t\tif (this._batchingDepth === 0) {\n\t\t\tfor (const entityId of this._batchedEntityIds) {\n\t\t\t\tfor (const hook of this._afterEntityMutatedHooks) {\n\t\t\t\t\thook(entityId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._batchedEntityIds.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tremoveComponent<ComponentName extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: ComponentName\n\t) {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Cannot remove component '${String(componentName)}': Entity with ID ${entityId} does not exist`);\n\t\t}\n\t\t// Get old value for callbacks\n\t\tconst oldValue = entity.components[componentName] as ComponentTypes[ComponentName] | undefined;\n\n\t\t// Invoke dispose before deletion and removal callbacks\n\t\tif (oldValue !== undefined) {\n\t\t\tthis.invokeDispose(componentName, oldValue, entity.id);\n\t\t}\n\n\t\tdelete entity.components[componentName];\n\n\t\t// Trigger removed callbacks (index-based iteration; unsubscribe nulls slots, compacted after)\n\t\tconst removeCbs = this.removedCallbacks.get(componentName);\n\t\tif (removeCbs && oldValue !== undefined) {\n\t\t\tremoveCbs.invoke({ value: oldValue, entity });\n\t\t}\n\n\t\t// Update component index\n\t\tthis.componentIndices.get(componentName)?.delete(entity.id);\n\n\t\t// Fire afterComponentRemoved hooks (only if component was present)\n\t\tif (oldValue !== undefined) {\n\t\t\tfor (const hook of this._afterComponentRemovedHooks) {\n\t\t\t\thook(entity.id, componentName);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetComponent<ComponentName extends keyof ComponentTypes>(entityId: number, componentName: ComponentName): ComponentTypes[ComponentName] | undefined {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) throw new Error(`Cannot get component '${String(componentName)}': Entity with ID ${entityId} does not exist`);\n\n\t\treturn entity.components[componentName];\n\t}\n\n\tgetEntitiesWithQuery<\n\t\tWithComponents extends keyof ComponentTypes = never,\n\t\tWithoutComponents extends keyof ComponentTypes = never\n\t>(\n\t\trequired: ReadonlyArray<WithComponents> = [],\n\t\texcluded: ReadonlyArray<WithoutComponents> = [],\n\t\tchanged?: ReadonlyArray<keyof ComponentTypes>,\n\t\tchangeThreshold?: number,\n\t\tparentHas?: ReadonlyArray<keyof ComponentTypes>,\n\t): Array<FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>> {\n\t\treturn this.getEntitiesWithQueryInto([], required, excluded, changed, changeThreshold, parentHas);\n\t}\n\n\t/**\n\t * Fill an existing array with entities matching the query, clearing it first.\n\t * Returns the same array reference for convenience.\n\t */\n\tgetEntitiesWithQueryInto<\n\t\tWithComponents extends keyof ComponentTypes = never,\n\t\tWithoutComponents extends keyof ComponentTypes = never\n\t>(\n\t\toutput: Array<FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>>,\n\t\trequired: ReadonlyArray<WithComponents> = [],\n\t\texcluded: ReadonlyArray<WithoutComponents> = [],\n\t\tchanged?: ReadonlyArray<keyof ComponentTypes>,\n\t\tchangeThreshold?: number,\n\t\tparentHas?: ReadonlyArray<keyof ComponentTypes>,\n\t): Array<FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>> {\n\t\toutput.length = 0;\n\n\t\tconst hasChangedFilter = changed !== undefined && changed.length > 0 && changeThreshold !== undefined;\n\t\tconst hasParentHasFilter = parentHas !== undefined && parentHas.length > 0;\n\n\t\t// Runtime query filtering guarantees WithComponents/WithoutComponents constraints,\n\t\t// but TypeScript can't narrow Entity<CT> to FilteredEntity from imperative logic.\n\t\ttype ResultEntry = FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>;\n\n\t\tif (required.length === 0) {\n\t\t\tif (excluded.length === 0 && !hasChangedFilter && !hasParentHasFilter) {\n\t\t\t\tfor (const entity of this.entities.values()) {\n\t\t\t\t\toutput.push(entity as unknown as ResultEntry);\n\t\t\t\t}\n\t\t\t\treturn output;\n\t\t\t}\n\n\t\t\tfor (const entity of this.entities.values()) {\n\t\t\t\tif (excluded.length > 0 && hasAnyComponent(entity.components, excluded)) continue;\n\t\t\t\tif (hasChangedFilter && !hasChangedComponent(this.changeSeqs.get(entity.id), changed, changeThreshold)) continue;\n\t\t\t\tif (hasParentHasFilter && !this.parentHasComponents(entity.id, parentHas)) continue;\n\t\t\t\toutput.push(entity as unknown as ResultEntry);\n\t\t\t}\n\t\t\treturn output;\n\t\t}\n\n\t\t// Find the component with the smallest entity set to start with\n\t\tconst firstRequired = required[0];\n\t\tif (firstRequired === undefined) return output;\n\t\tlet smallestComponent: WithComponents = firstRequired;\n\t\tlet smallestSize = this.componentIndices.get(firstRequired)?.size ?? 0;\n\t\t// Start at 1 — firstRequired is already the initial candidate\n\t\tfor (let i = 1; i < required.length; i++) {\n\t\t\tconst comp = required[i];\n\t\t\tif (comp === undefined) continue;\n\t\t\tconst size = this.componentIndices.get(comp)?.size ?? 0;\n\t\t\tif (size < smallestSize) {\n\t\t\t\tsmallestComponent = comp;\n\t\t\t\tsmallestSize = size;\n\t\t\t}\n\t\t}\n\n\t\t// Start with the entities from the smallest component set\n\t\tconst candidateSet = this.componentIndices.get(smallestComponent);\n\t\tif (!candidateSet || candidateSet.size === 0) {\n\t\t\treturn output;\n\t\t}\n\n\t\tfor (const id of candidateSet) {\n\t\t\tconst entity = this.entities.get(id);\n\t\t\tif (!entity) continue;\n\t\t\tif (!hasAllComponents(entity.components, required)) continue;\n\t\t\tif (excluded.length > 0 && hasAnyComponent(entity.components, excluded)) continue;\n\t\t\tif (hasChangedFilter && !hasChangedComponent(this.changeSeqs.get(id), changed, changeThreshold)) continue;\n\t\t\tif (hasParentHasFilter && !this.parentHasComponents(id, parentHas)) continue;\n\t\t\toutput.push(entity as unknown as ResultEntry);\n\t\t}\n\n\t\treturn output;\n\t}\n\n\t/**\n\t * Check if an entity's direct parent has all specified components\n\t */\n\tprivate parentHasComponents(entityId: number, components: ReadonlyArray<keyof ComponentTypes>): boolean {\n\t\tconst parentId = this.hierarchyManager.getParent(entityId);\n\t\tif (parentId === null) return false;\n\n\t\tconst parentEntity = this.entities.get(parentId);\n\t\tif (!parentEntity) return false;\n\n\t\treturn hasAllComponents(parentEntity.components, components);\n\t}\n\n\tremoveEntity(entityId: number, options?: RemoveEntityOptions): boolean {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) return false;\n\n\t\tconst cascade = options?.cascade ?? true;\n\n\t\tif (cascade) {\n\t\t\t// Get all descendants first (depth-first order)\n\t\t\tconst descendants = this.hierarchyManager.getDescendants(entity.id);\n\t\t\t// Fire beforeEntityRemoved for descendants (reverse: children before parents)\n\t\t\tfor (let i = descendants.length - 1; i >= 0; i--) {\n\t\t\t\tconst descendantId = descendants[i];\n\t\t\t\tif (descendantId === undefined) continue;\n\t\t\t\tfor (const hook of this._beforeEntityRemovedHooks) {\n\t\t\t\t\thook(descendantId);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fire beforeEntityRemoved for the entity itself\n\t\t\tfor (const hook of this._beforeEntityRemovedHooks) {\n\t\t\t\thook(entity.id);\n\t\t\t}\n\t\t\t// Now do actual removal (descendants in reverse order)\n\t\t\tfor (let i = descendants.length - 1; i >= 0; i--) {\n\t\t\t\tconst descendantId = descendants[i];\n\t\t\t\tif (descendantId === undefined) continue;\n\t\t\t\tthis.removeEntityInternal(descendantId);\n\t\t\t}\n\t\t} else {\n\t\t\t// Fire beforeEntityRemoved for just this entity\n\t\t\tfor (const hook of this._beforeEntityRemovedHooks) {\n\t\t\t\thook(entity.id);\n\t\t\t}\n\t\t}\n\n\t\treturn this.removeEntityInternal(entity.id);\n\t}\n\n\t/**\n\t * Internal method to remove a single entity without cascade logic\n\t */\n\tprivate removeEntityInternal(entityId: number): boolean {\n\t\tconst entity = this.entities.get(entityId);\n\t\tif (!entity) return false;\n\n\t\t// Clean up hierarchy\n\t\tthis.hierarchyManager.removeEntity(entityId);\n\n\t\t// Trigger disposal and removal callbacks for each component before removing the entity\n\t\tfor (const componentName of Object.keys(entity.components) as Array<keyof ComponentTypes>) {\n\t\t\tconst oldValue = entity.components[componentName];\n\n\t\t\tif (oldValue !== undefined) {\n\t\t\t\t// Invoke dispose before removal callbacks\n\t\t\t\tthis.invokeDispose(componentName, oldValue as ComponentTypes[keyof ComponentTypes], entity.id);\n\n\t\t\t\t// Trigger removed callbacks (index-based iteration; unsubscribe nulls slots, compacted after)\n\t\t\t\tconst removeCbs = this.removedCallbacks.get(componentName);\n\t\t\t\tif (removeCbs) {\n\t\t\t\t\tremoveCbs.invoke({ value: oldValue, entity });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove entity from component indices\n\t\t\tthis.componentIndices.get(componentName)?.delete(entity.id);\n\t\t}\n\n\t\t// Clean up change sequences\n\t\tthis.changeSeqs.delete(entity.id);\n\n\t\t// Remove the entity itself\n\t\treturn this.entities.delete(entity.id);\n\t}\n\n\tgetEntity(entityId: number): Entity<ComponentTypes> | undefined {\n\t\treturn this.entities.get(entityId);\n\t}\n\n\t/**\n\t * Register a callback when a specific component is added to any entity\n\t * @param componentName The component key\n\t * @param handler Function receiving the new component value and the entity\n\t * @returns Unsubscribe function to remove the callback\n\t */\n\tonComponentAdded<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\thandler: (ctx: { value: ComponentTypes[ComponentName]; entity: Entity<ComponentTypes> }) => void\n\t): () => void {\n\t\tconst widened = handler as ComponentCallback<ComponentTypes>;\n\t\tlet list = this.addedCallbacks.get(componentName);\n\t\tif (!list) {\n\t\t\tlist = new CallbackList();\n\t\t\tthis.addedCallbacks.set(componentName, list);\n\t\t}\n\t\tlist.add(widened);\n\t\treturn () => {\n\t\t\tthis.addedCallbacks.get(componentName)?.remove(widened);\n\t\t};\n\t}\n\n\t/**\n\t * Register a callback when a specific component is removed from any entity\n\t * @param componentName The component key\n\t * @param handler Function receiving the old component value and the entity\n\t * @returns Unsubscribe function to remove the callback\n\t */\n\tonComponentRemoved<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\thandler: (ctx: { value: ComponentTypes[ComponentName]; entity: Entity<ComponentTypes> }) => void\n\t): () => void {\n\t\tconst widened = handler as ComponentCallback<ComponentTypes>;\n\t\tlet list = this.removedCallbacks.get(componentName);\n\t\tif (!list) {\n\t\t\tlist = new CallbackList();\n\t\t\tthis.removedCallbacks.set(componentName, list);\n\t\t}\n\t\tlist.add(widened);\n\t\treturn () => {\n\t\t\tthis.removedCallbacks.get(componentName)?.remove(widened);\n\t\t};\n\t}\n\n\t// ==================== Lifecycle Hook Registration ====================\n\n\tonAfterComponentAdded(hook: (entityId: number, componentName: keyof ComponentTypes) => void): () => void {\n\t\tthis._afterComponentAddedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterComponentAddedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterComponentAddedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonAfterEntityMutated(hook: (entityId: number) => void): () => void {\n\t\tthis._afterEntityMutatedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterEntityMutatedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterEntityMutatedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonAfterComponentRemoved(hook: (entityId: number, componentName: keyof ComponentTypes) => void): () => void {\n\t\tthis._afterComponentRemovedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterComponentRemovedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterComponentRemovedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonBeforeEntityRemoved(hook: (entityId: number) => void): () => void {\n\t\tthis._beforeEntityRemovedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._beforeEntityRemovedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._beforeEntityRemovedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonAfterParentChanged(hook: (childId: number) => void): () => void {\n\t\tthis._afterParentChangedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterParentChangedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterParentChangedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\t// ==================== Change Detection Methods ====================\n\n\t/**\n\t * The current monotonic change sequence value.\n\t * Each markChanged call increments this before stamping.\n\t */\n\tget changeSeq(): number {\n\t\treturn this._changeSeq;\n\t}\n\n\t/**\n\t * Mark a component as changed on an entity, stamping the next sequence number.\n\t * @param entityId The entity ID\n\t * @param componentName The component that changed\n\t */\n\tmarkChanged<K extends keyof ComponentTypes>(entityId: number, componentName: K): void {\n\t\tconst seq = ++this._changeSeq;\n\t\tlet entitySeqs = this.changeSeqs.get(entityId);\n\t\tif (!entitySeqs) {\n\t\t\tentitySeqs = new Map();\n\t\t\tthis.changeSeqs.set(entityId, entitySeqs);\n\t\t}\n\t\tentitySeqs.set(componentName, seq);\n\t}\n\n\t/**\n\t * Get the sequence number at which a component was last changed on an entity\n\t * @param entityId The entity ID\n\t * @param componentName The component to check\n\t * @returns The sequence number when last changed, or -1 if never changed\n\t */\n\tgetChangeSeq<K extends keyof ComponentTypes>(entityId: number, componentName: K): number {\n\t\treturn this.changeSeqs.get(entityId)?.get(componentName) ?? -1;\n\t}\n\n\t// ==================== Hierarchy Methods ====================\n\n\t/**\n\t * Create an entity as a child of another entity with initial components\n\t * @param parentId The parent entity ID\n\t * @param components Initial components to add\n\t * @returns The created child entity\n\t */\n\tspawnChild<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tparentId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes> {\n\t\tconst entity = this.createEntity();\n\t\tthis.addComponents(entity.id, components);\n\t\tthis.setParent(entity.id, parentId);\n\t\treturn entity as FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes>;\n\t}\n\n\t/**\n\t * Set the parent of an entity\n\t * @param childId The entity ID to set as a child\n\t * @param parentId The entity ID to set as the parent\n\t */\n\tsetParent(childId: number, parentId: number): this {\n\t\tthis.hierarchyManager.setParent(childId, parentId);\n\t\tfor (const hook of this._afterParentChangedHooks) {\n\t\t\thook(childId);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Remove the parent relationship for an entity (orphan it)\n\t * @param childId The entity ID to orphan\n\t * @returns true if a parent was removed, false if entity had no parent\n\t */\n\tremoveParent(childId: number): boolean {\n\t\tconst result = this.hierarchyManager.removeParent(childId);\n\t\tif (result) {\n\t\t\tfor (const hook of this._afterParentChangedHooks) {\n\t\t\t\thook(childId);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get the parent of an entity\n\t * @param entityId The entity ID to get the parent of\n\t * @returns The parent entity ID, or null if no parent\n\t */\n\tgetParent(entityId: number): number | null {\n\t\treturn this.hierarchyManager.getParent(entityId);\n\t}\n\n\t/**\n\t * Get all children of an entity in insertion order\n\t * @param parentId The parent entity ID\n\t * @returns Readonly array of child entity IDs\n\t */\n\tgetChildren(parentId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getChildren(parentId);\n\t}\n\n\t/**\n\t * Get a child at a specific index\n\t * @param parentId The parent entity ID\n\t * @param index The index of the child\n\t * @returns The child entity ID, or null if index is out of bounds\n\t */\n\tgetChildAt(parentId: number, index: number): number | null {\n\t\treturn this.hierarchyManager.getChildAt(parentId, index);\n\t}\n\n\t/**\n\t * Get the index of a child within its parent's children list\n\t * @param parentId The parent entity ID\n\t * @param childId The child entity ID to find\n\t * @returns The index of the child, or -1 if not found\n\t */\n\tgetChildIndex(parentId: number, childId: number): number {\n\t\treturn this.hierarchyManager.getChildIndex(parentId, childId);\n\t}\n\n\t/**\n\t * Get all ancestors of an entity in order [parent, grandparent, ...]\n\t * @param entityId The entity ID to get ancestors of\n\t * @returns Readonly array of ancestor entity IDs\n\t */\n\tgetAncestors(entityId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getAncestors(entityId);\n\t}\n\n\t/**\n\t * Get all descendants of an entity in depth-first order\n\t * @param entityId The entity ID to get descendants of\n\t * @returns Readonly array of descendant entity IDs\n\t */\n\tgetDescendants(entityId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getDescendants(entityId);\n\t}\n\n\t/**\n\t * Get the root ancestor of an entity (topmost parent), or self if no parent\n\t * @param entityId The entity ID to get the root of\n\t * @returns The root entity ID\n\t */\n\tgetRoot(entityId: number): number {\n\t\treturn this.hierarchyManager.getRoot(entityId);\n\t}\n\n\t/**\n\t * Get siblings of an entity (other children of the same parent)\n\t * @param entityId The entity ID to get siblings of\n\t * @returns Readonly array of sibling entity IDs\n\t */\n\tgetSiblings(entityId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getSiblings(entityId);\n\t}\n\n\t/**\n\t * Check if an entity is a descendant of another entity\n\t * @param entityId The potential descendant ID\n\t * @param ancestorId The potential ancestor ID\n\t * @returns true if entityId is a descendant of ancestorId\n\t */\n\tisDescendantOf(entityId: number, ancestorId: number): boolean {\n\t\treturn this.hierarchyManager.isDescendantOf(entityId, ancestorId);\n\t}\n\n\t/**\n\t * Check if an entity is an ancestor of another entity\n\t * @param entityId The potential ancestor ID\n\t * @param descendantId The potential descendant ID\n\t * @returns true if entityId is an ancestor of descendantId\n\t */\n\tisAncestorOf(entityId: number, descendantId: number): boolean {\n\t\treturn this.hierarchyManager.isAncestorOf(entityId, descendantId);\n\t}\n\n\t/**\n\t * Returns true when at least one parent-child relationship exists.\n\t */\n\tget hasHierarchy(): boolean {\n\t\treturn this.hierarchyManager.hasHierarchy;\n\t}\n\n\t/**\n\t * Get all root entities (entities that have children but no parent)\n\t * @returns Readonly array of root entity IDs\n\t */\n\tgetRootEntities(): readonly number[] {\n\t\treturn this.hierarchyManager.getRootEntities();\n\t}\n\n\t/**\n\t * Traverse the hierarchy in parent-first (breadth-first) order.\n\t * Parents are guaranteed to be visited before their children.\n\t * @param callback Function called for each entity with (entityId, parentId, depth)\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t */\n\tforEachInHierarchy(\n\t\tcallback: (entityId: number, parentId: number | null, depth: number) => void,\n\t\toptions?: HierarchyIteratorOptions\n\t): void {\n\t\tthis.hierarchyManager.forEachInHierarchy(callback, options);\n\t}\n\n\t/**\n\t * Generator-based hierarchy traversal in parent-first (breadth-first) order.\n\t * Supports early termination via break.\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t * @yields HierarchyEntry for each entity in parent-first order\n\t */\n\thierarchyIterator(options?: HierarchyIteratorOptions): Generator<HierarchyEntry, void, unknown> {\n\t\treturn this.hierarchyManager.hierarchyIterator(options);\n\t}\n}\n",
|
|
6
|
+
"import type { Entity, FilteredEntity, RemoveEntityOptions, HierarchyEntry, HierarchyIteratorOptions } from \"./types\";\nimport HierarchyManager from \"./hierarchy-manager\";\n\n/** Returns true if `components` contains ALL keys in `required`. */\nfunction hasAllComponents(\n\tcomponents: Record<string | number | symbol, unknown>,\n\trequired: ReadonlyArray<string | number | symbol>,\n): boolean {\n\tfor (const key of required) {\n\t\tif (!(key in components)) return false;\n\t}\n\treturn true;\n}\n\n/** Returns true if `components` contains ANY key in `excluded`. */\nfunction hasAnyComponent(\n\tcomponents: Record<string | number | symbol, unknown>,\n\texcluded: ReadonlyArray<string | number | symbol>,\n): boolean {\n\tfor (const key of excluded) {\n\t\tif (key in components) return true;\n\t}\n\treturn false;\n}\n\n/** Returns true if any component in `changed` was modified after `threshold`. */\nfunction hasChangedComponent(\n\tentitySeqs: Map<string | number | symbol, number> | undefined,\n\tchanged: ReadonlyArray<string | number | symbol>,\n\tthreshold: number,\n): boolean {\n\tif (!entitySeqs) return false;\n\tfor (const key of changed) {\n\t\tif ((entitySeqs.get(key) ?? -1) > threshold) return true;\n\t}\n\treturn false;\n}\n\ntype ComponentCallback<ComponentTypes> = (ctx: { value: unknown; entity: Entity<ComponentTypes> }) => void;\n\n/**\n * Manages zero-allocation callback iteration with safe mid-iteration unsubscribe.\n * During iteration, unsubscribes are deferred. Snapshot length guarantees all\n * callbacks registered at call time execute. Compaction runs when iteration ends.\n */\nclass CallbackList<ComponentTypes> {\n\tprivate readonly callbacks: ComponentCallback<ComponentTypes>[] = [];\n\tprivate _iterDepth = 0;\n\tprivate _pendingRemovals: ComponentCallback<ComponentTypes>[] = [];\n\n\tadd(cb: ComponentCallback<ComponentTypes>): void {\n\t\tthis.callbacks.push(cb);\n\t}\n\n\tremove(cb: ComponentCallback<ComponentTypes>): void {\n\t\tif (this._iterDepth > 0) {\n\t\t\tthis._pendingRemovals.push(cb);\n\t\t\treturn;\n\t\t}\n\t\tconst idx = this.callbacks.indexOf(cb);\n\t\tif (idx !== -1) this.callbacks.splice(idx, 1);\n\t}\n\n\tinvoke(ctx: { value: unknown; entity: Entity<ComponentTypes> }): void {\n\t\tthis._iterDepth++;\n\t\tconst len = this.callbacks.length;\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tconst cb = this.callbacks[i];\n\t\t\tif (cb) cb(ctx);\n\t\t}\n\t\tthis._iterDepth--;\n\t\tif (this._iterDepth === 0 && this._pendingRemovals.length > 0) {\n\t\t\tfor (const cb of this._pendingRemovals) {\n\t\t\t\tconst idx = this.callbacks.indexOf(cb);\n\t\t\t\tif (idx !== -1) this.callbacks.splice(idx, 1);\n\t\t\t}\n\t\t\tthis._pendingRemovals.length = 0;\n\t\t}\n\t}\n}\n\nexport default\nclass EntityManager<ComponentTypes> {\n\tprivate nextId: number = 1;\n\tprivate entities: Map<number, Entity<ComponentTypes>> = new Map();\n\tprivate componentIndices: Map<keyof ComponentTypes, Set<number>> = new Map();\n\t/**\n\t * Callbacks registered for component additions\n\t */\n\tprivate addedCallbacks: Map<keyof ComponentTypes, CallbackList<ComponentTypes>> = new Map();\n\t/**\n\t * Callbacks registered for component removals\n\t */\n\tprivate removedCallbacks: Map<keyof ComponentTypes, CallbackList<ComponentTypes>> = new Map();\n\t/**\n\t * Hierarchy manager for parent-child relationships\n\t */\n\tprivate hierarchyManager: HierarchyManager = new HierarchyManager();\n\t/**\n\t * Per-type component dispose callbacks.\n\t * Called when a component is removed (explicit removal, entity destruction, or replacement).\n\t */\n\tprivate disposeCallbacks: Map<keyof ComponentTypes, (ctx: { value: unknown; entityId: number }) => void> = new Map();\n\t/**\n\t * Per-entity per-component change sequence tracking.\n\t * Maps entityId -> (componentName -> sequence number when last changed)\n\t */\n\tprivate changeSeqs: Map<number, Map<keyof ComponentTypes, number>> = new Map();\n\t/**\n\t * Monotonic sequence counter for change detection.\n\t * Each markChanged call increments this and stamps the new value.\n\t */\n\tprivate _changeSeq: number = 0;\n\n\t// ==================== Lifecycle Hook Arrays ====================\n\tprivate _afterComponentAddedHooks: Array<(entityId: number, componentName: keyof ComponentTypes) => void> = [];\n\tprivate _afterEntityMutatedHooks: Array<(entityId: number) => void> = [];\n\tprivate _afterComponentRemovedHooks: Array<(entityId: number, componentName: keyof ComponentTypes) => void> = [];\n\tprivate _beforeEntityRemovedHooks: Array<(entityId: number) => void> = [];\n\tprivate _afterParentChangedHooks: Array<(childId: number) => void> = [];\n\n\t// ==================== Batching Fields ====================\n\tprivate _batchingDepth: number = 0;\n\tprivate _batchedEntityIds: Set<number> = new Set();\n\t/** Component keys being added in the current addComponents batch, if any.\n\t * Used by required component resolution to skip auto-adding explicitly provided components. */\n\t_pendingBatchKeys: ReadonlySet<keyof ComponentTypes> | null = null;\n\n\tget entityCount(): number {\n\t\treturn this.entities.size;\n\t}\n\n\tcreateEntity(): Entity<ComponentTypes> {\n\t\tconst id = this.nextId++;\n\t\tconst entity: Entity<ComponentTypes> = { id, components: {} };\n\t\tthis.entities.set(id, entity);\n\t\treturn entity;\n\t}\n\n\t/**\n\t * Register a dispose callback for a component type.\n\t * Called when a component is removed (explicit removal, entity destruction, or replacement).\n\t * Later registrations replace earlier ones for the same component type.\n\t * @param componentName The component type to register disposal for\n\t * @param callback Function receiving the component value being disposed and the entity ID\n\t */\n\tregisterDispose<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\tcallback: (ctx: { value: ComponentTypes[ComponentName]; entityId: number }) => void\n\t): void {\n\t\tthis.disposeCallbacks.set(componentName, callback as (ctx: { value: unknown; entityId: number }) => void);\n\t}\n\n\t/**\n\t * Get all registered dispose callbacks.\n\t * @internal Used by ECSpresso for plugin installation\n\t */\n\tgetDisposeCallbacks(): Map<keyof ComponentTypes, (ctx: { value: unknown; entityId: number }) => void> {\n\t\treturn this.disposeCallbacks;\n\t}\n\n\t/**\n\t * Invoke the dispose callback for a component, if registered.\n\t * Errors are caught and logged to prevent blocking removal.\n\t */\n\tprivate invokeDispose<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\tvalue: ComponentTypes[ComponentName],\n\t\tentityId: number\n\t): void {\n\t\tconst cb = this.disposeCallbacks.get(componentName);\n\t\tif (!cb) return;\n\t\ttry {\n\t\t\tcb({ value, entityId });\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Component dispose callback for '${String(componentName)}' threw:`, error);\n\t\t}\n\t}\n\n\t// TODO: Component object pooling if(/when) garbage collection is an issue...?\n\taddComponent<ComponentName extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: ComponentName,\n\t\tdata: ComponentTypes[ComponentName]\n\t) {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Cannot add component '${String(componentName)}': Entity with ID ${entityId} does not exist`);\n\t\t}\n\n\t\t// Dispose old value if replacing an existing component\n\t\tconst existing = entity.components[componentName];\n\t\tif (existing !== undefined) {\n\t\t\tthis.invokeDispose(componentName, existing as ComponentTypes[ComponentName], entity.id);\n\t\t}\n\n\t\tentity.components[componentName] = data;\n\n\t\t// Update component index\n\t\tif (!this.componentIndices.has(componentName)) {\n\t\t\tthis.componentIndices.set(componentName, new Set());\n\t\t}\n\t\tthis.componentIndices.get(componentName)?.add(entity.id);\n\t\t// Trigger added callbacks (index-based iteration; unsubscribe nulls slots, compacted after)\n\t\tconst callbacks = this.addedCallbacks.get(componentName);\n\t\tif (callbacks) {\n\t\t\tcallbacks.invoke({ value: data, entity });\n\t\t}\n\n\t\t// Fire afterComponentAdded hooks (may trigger recursive addComponent)\n\t\tthis._batchingDepth++;\n\t\tfor (const hook of this._afterComponentAddedHooks) {\n\t\t\thook(entity.id, componentName);\n\t\t}\n\t\tthis._batchedEntityIds.add(entity.id);\n\t\tthis._batchingDepth--;\n\n\t\t// Flush afterEntityMutated when outermost batch completes\n\t\tif (this._batchingDepth === 0) {\n\t\t\tfor (const entityId of this._batchedEntityIds) {\n\t\t\t\tfor (const hook of this._afterEntityMutatedHooks) {\n\t\t\t\t\thook(entityId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._batchedEntityIds.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add multiple components to an entity at once\n\t * @param entityId Entity ID to add components to\n\t * @param components Object with component names as keys and component data as values\n\t */\n\taddComponents<\n\t\tT extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }\n\t>(\n\t\tentityId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t) {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Cannot add components: Entity with ID ${entityId} does not exist`);\n\t\t}\n\n\t\tconst outerPending = this._pendingBatchKeys;\n\t\tthis._pendingBatchKeys = new Set(Object.keys(components) as (keyof ComponentTypes)[]);\n\t\tthis._batchingDepth++;\n\t\tfor (const componentName in components) {\n\t\t\tthis.addComponent(\n\t\t\t\tentity.id,\n\t\t\t\tcomponentName as keyof ComponentTypes,\n\t\t\t\tcomponents[componentName as keyof T] as ComponentTypes[keyof ComponentTypes]\n\t\t\t);\n\t\t}\n\t\tthis._batchingDepth--;\n\t\tthis._pendingBatchKeys = outerPending;\n\n\t\tif (this._batchingDepth === 0) {\n\t\t\tfor (const entityId of this._batchedEntityIds) {\n\t\t\t\tfor (const hook of this._afterEntityMutatedHooks) {\n\t\t\t\t\thook(entityId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._batchedEntityIds.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tremoveComponent<ComponentName extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: ComponentName\n\t) {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) {\n\t\t\tthrow new Error(`Cannot remove component '${String(componentName)}': Entity with ID ${entityId} does not exist`);\n\t\t}\n\t\t// Get old value for callbacks\n\t\tconst oldValue = entity.components[componentName] as ComponentTypes[ComponentName] | undefined;\n\n\t\t// Invoke dispose before deletion and removal callbacks\n\t\tif (oldValue !== undefined) {\n\t\t\tthis.invokeDispose(componentName, oldValue, entity.id);\n\t\t}\n\n\t\tdelete entity.components[componentName];\n\n\t\t// Trigger removed callbacks (index-based iteration; unsubscribe nulls slots, compacted after)\n\t\tconst removeCbs = this.removedCallbacks.get(componentName);\n\t\tif (removeCbs && oldValue !== undefined) {\n\t\t\tremoveCbs.invoke({ value: oldValue, entity });\n\t\t}\n\n\t\t// Update component index\n\t\tthis.componentIndices.get(componentName)?.delete(entity.id);\n\n\t\t// Fire afterComponentRemoved hooks (only if component was present)\n\t\tif (oldValue !== undefined) {\n\t\t\tfor (const hook of this._afterComponentRemovedHooks) {\n\t\t\t\thook(entity.id, componentName);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetComponent<ComponentName extends keyof ComponentTypes>(entityId: number, componentName: ComponentName): ComponentTypes[ComponentName] | undefined {\n\t\treturn this.entities.get(entityId)?.components[componentName];\n\t}\n\n\tgetEntitiesWithQuery<\n\t\tWithComponents extends keyof ComponentTypes = never,\n\t\tWithoutComponents extends keyof ComponentTypes = never\n\t>(\n\t\trequired: ReadonlyArray<WithComponents> = [],\n\t\texcluded: ReadonlyArray<WithoutComponents> = [],\n\t\tchanged?: ReadonlyArray<keyof ComponentTypes>,\n\t\tchangeThreshold?: number,\n\t\tparentHas?: ReadonlyArray<keyof ComponentTypes>,\n\t): Array<FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>> {\n\t\treturn this.getEntitiesWithQueryInto([], required, excluded, changed, changeThreshold, parentHas);\n\t}\n\n\t/**\n\t * Fill an existing array with entities matching the query, clearing it first.\n\t * Returns the same array reference for convenience.\n\t */\n\tgetEntitiesWithQueryInto<\n\t\tWithComponents extends keyof ComponentTypes = never,\n\t\tWithoutComponents extends keyof ComponentTypes = never\n\t>(\n\t\toutput: Array<FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>>,\n\t\trequired: ReadonlyArray<WithComponents> = [],\n\t\texcluded: ReadonlyArray<WithoutComponents> = [],\n\t\tchanged?: ReadonlyArray<keyof ComponentTypes>,\n\t\tchangeThreshold?: number,\n\t\tparentHas?: ReadonlyArray<keyof ComponentTypes>,\n\t): Array<FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>> {\n\t\toutput.length = 0;\n\n\t\tconst hasChangedFilter = changed !== undefined && changed.length > 0 && changeThreshold !== undefined;\n\t\tconst hasParentHasFilter = parentHas !== undefined && parentHas.length > 0;\n\n\t\t// Runtime query filtering guarantees WithComponents/WithoutComponents constraints,\n\t\t// but TypeScript can't narrow Entity<CT> to FilteredEntity from imperative logic.\n\t\ttype ResultEntry = FilteredEntity<ComponentTypes, WithComponents extends never ? never : WithComponents, WithoutComponents extends never ? never : WithoutComponents>;\n\n\t\tif (required.length === 0) {\n\t\t\tif (excluded.length === 0 && !hasChangedFilter && !hasParentHasFilter) {\n\t\t\t\tfor (const entity of this.entities.values()) {\n\t\t\t\t\toutput.push(entity as unknown as ResultEntry);\n\t\t\t\t}\n\t\t\t\treturn output;\n\t\t\t}\n\n\t\t\tfor (const entity of this.entities.values()) {\n\t\t\t\tif (excluded.length > 0 && hasAnyComponent(entity.components, excluded)) continue;\n\t\t\t\tif (hasChangedFilter && !hasChangedComponent(this.changeSeqs.get(entity.id), changed, changeThreshold)) continue;\n\t\t\t\tif (hasParentHasFilter && !this.parentHasComponents(entity.id, parentHas)) continue;\n\t\t\t\toutput.push(entity as unknown as ResultEntry);\n\t\t\t}\n\t\t\treturn output;\n\t\t}\n\n\t\t// Find the component with the smallest entity set to start with\n\t\tconst firstRequired = required[0];\n\t\tif (firstRequired === undefined) return output;\n\t\tlet smallestComponent: WithComponents = firstRequired;\n\t\tlet smallestSize = this.componentIndices.get(firstRequired)?.size ?? 0;\n\t\t// Start at 1 — firstRequired is already the initial candidate\n\t\tfor (let i = 1; i < required.length; i++) {\n\t\t\tconst comp = required[i];\n\t\t\tif (comp === undefined) continue;\n\t\t\tconst size = this.componentIndices.get(comp)?.size ?? 0;\n\t\t\tif (size < smallestSize) {\n\t\t\t\tsmallestComponent = comp;\n\t\t\t\tsmallestSize = size;\n\t\t\t}\n\t\t}\n\n\t\t// Start with the entities from the smallest component set\n\t\tconst candidateSet = this.componentIndices.get(smallestComponent);\n\t\tif (!candidateSet || candidateSet.size === 0) {\n\t\t\treturn output;\n\t\t}\n\n\t\tfor (const id of candidateSet) {\n\t\t\tconst entity = this.entities.get(id);\n\t\t\tif (!entity) continue;\n\t\t\tif (!hasAllComponents(entity.components, required)) continue;\n\t\t\tif (excluded.length > 0 && hasAnyComponent(entity.components, excluded)) continue;\n\t\t\tif (hasChangedFilter && !hasChangedComponent(this.changeSeqs.get(id), changed, changeThreshold)) continue;\n\t\t\tif (hasParentHasFilter && !this.parentHasComponents(id, parentHas)) continue;\n\t\t\toutput.push(entity as unknown as ResultEntry);\n\t\t}\n\n\t\treturn output;\n\t}\n\n\t/**\n\t * Check if an entity's direct parent has all specified components\n\t */\n\tprivate parentHasComponents(entityId: number, components: ReadonlyArray<keyof ComponentTypes>): boolean {\n\t\tconst parentId = this.hierarchyManager.getParent(entityId);\n\t\tif (parentId === null) return false;\n\n\t\tconst parentEntity = this.entities.get(parentId);\n\t\tif (!parentEntity) return false;\n\n\t\treturn hasAllComponents(parentEntity.components, components);\n\t}\n\n\tremoveEntity(entityId: number, options?: RemoveEntityOptions): boolean {\n\t\tconst entity = this.entities.get(entityId);\n\n\t\tif (!entity) return false;\n\n\t\tconst cascade = options?.cascade ?? true;\n\n\t\tif (cascade) {\n\t\t\t// Get all descendants first (depth-first order)\n\t\t\tconst descendants = this.hierarchyManager.getDescendants(entity.id);\n\t\t\t// Fire beforeEntityRemoved for descendants (reverse: children before parents)\n\t\t\tfor (let i = descendants.length - 1; i >= 0; i--) {\n\t\t\t\tconst descendantId = descendants[i];\n\t\t\t\tif (descendantId === undefined) continue;\n\t\t\t\tfor (const hook of this._beforeEntityRemovedHooks) {\n\t\t\t\t\thook(descendantId);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fire beforeEntityRemoved for the entity itself\n\t\t\tfor (const hook of this._beforeEntityRemovedHooks) {\n\t\t\t\thook(entity.id);\n\t\t\t}\n\t\t\t// Now do actual removal (descendants in reverse order)\n\t\t\tfor (let i = descendants.length - 1; i >= 0; i--) {\n\t\t\t\tconst descendantId = descendants[i];\n\t\t\t\tif (descendantId === undefined) continue;\n\t\t\t\tthis.removeEntityInternal(descendantId);\n\t\t\t}\n\t\t} else {\n\t\t\t// Fire beforeEntityRemoved for just this entity\n\t\t\tfor (const hook of this._beforeEntityRemovedHooks) {\n\t\t\t\thook(entity.id);\n\t\t\t}\n\t\t}\n\n\t\treturn this.removeEntityInternal(entity.id);\n\t}\n\n\t/**\n\t * Internal method to remove a single entity without cascade logic\n\t */\n\tprivate removeEntityInternal(entityId: number): boolean {\n\t\tconst entity = this.entities.get(entityId);\n\t\tif (!entity) return false;\n\n\t\t// Clean up hierarchy\n\t\tthis.hierarchyManager.removeEntity(entityId);\n\n\t\t// Trigger disposal and removal callbacks for each component before removing the entity\n\t\tfor (const componentName of Object.keys(entity.components) as Array<keyof ComponentTypes>) {\n\t\t\tconst oldValue = entity.components[componentName];\n\n\t\t\tif (oldValue !== undefined) {\n\t\t\t\t// Invoke dispose before removal callbacks\n\t\t\t\tthis.invokeDispose(componentName, oldValue as ComponentTypes[keyof ComponentTypes], entity.id);\n\n\t\t\t\t// Trigger removed callbacks (index-based iteration; unsubscribe nulls slots, compacted after)\n\t\t\t\tconst removeCbs = this.removedCallbacks.get(componentName);\n\t\t\t\tif (removeCbs) {\n\t\t\t\t\tremoveCbs.invoke({ value: oldValue, entity });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove entity from component indices\n\t\t\tthis.componentIndices.get(componentName)?.delete(entity.id);\n\t\t}\n\n\t\t// Clean up change sequences\n\t\tthis.changeSeqs.delete(entity.id);\n\n\t\t// Remove the entity itself\n\t\treturn this.entities.delete(entity.id);\n\t}\n\n\tgetEntity(entityId: number): Entity<ComponentTypes> | undefined {\n\t\treturn this.entities.get(entityId);\n\t}\n\n\t/**\n\t * Register a callback when a specific component is added to any entity\n\t * @param componentName The component key\n\t * @param handler Function receiving the new component value and the entity\n\t * @returns Unsubscribe function to remove the callback\n\t */\n\tonComponentAdded<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\thandler: (ctx: { value: ComponentTypes[ComponentName]; entity: Entity<ComponentTypes> }) => void\n\t): () => void {\n\t\tconst widened = handler as ComponentCallback<ComponentTypes>;\n\t\tlet list = this.addedCallbacks.get(componentName);\n\t\tif (!list) {\n\t\t\tlist = new CallbackList();\n\t\t\tthis.addedCallbacks.set(componentName, list);\n\t\t}\n\t\tlist.add(widened);\n\t\treturn () => {\n\t\t\tthis.addedCallbacks.get(componentName)?.remove(widened);\n\t\t};\n\t}\n\n\t/**\n\t * Register a callback when a specific component is removed from any entity\n\t * @param componentName The component key\n\t * @param handler Function receiving the old component value and the entity\n\t * @returns Unsubscribe function to remove the callback\n\t */\n\tonComponentRemoved<ComponentName extends keyof ComponentTypes>(\n\t\tcomponentName: ComponentName,\n\t\thandler: (ctx: { value: ComponentTypes[ComponentName]; entity: Entity<ComponentTypes> }) => void\n\t): () => void {\n\t\tconst widened = handler as ComponentCallback<ComponentTypes>;\n\t\tlet list = this.removedCallbacks.get(componentName);\n\t\tif (!list) {\n\t\t\tlist = new CallbackList();\n\t\t\tthis.removedCallbacks.set(componentName, list);\n\t\t}\n\t\tlist.add(widened);\n\t\treturn () => {\n\t\t\tthis.removedCallbacks.get(componentName)?.remove(widened);\n\t\t};\n\t}\n\n\t// ==================== Lifecycle Hook Registration ====================\n\n\tonAfterComponentAdded(hook: (entityId: number, componentName: keyof ComponentTypes) => void): () => void {\n\t\tthis._afterComponentAddedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterComponentAddedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterComponentAddedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonAfterEntityMutated(hook: (entityId: number) => void): () => void {\n\t\tthis._afterEntityMutatedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterEntityMutatedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterEntityMutatedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonAfterComponentRemoved(hook: (entityId: number, componentName: keyof ComponentTypes) => void): () => void {\n\t\tthis._afterComponentRemovedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterComponentRemovedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterComponentRemovedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonBeforeEntityRemoved(hook: (entityId: number) => void): () => void {\n\t\tthis._beforeEntityRemovedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._beforeEntityRemovedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._beforeEntityRemovedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\tonAfterParentChanged(hook: (childId: number) => void): () => void {\n\t\tthis._afterParentChangedHooks.push(hook);\n\t\treturn () => {\n\t\t\tconst idx = this._afterParentChangedHooks.indexOf(hook);\n\t\t\tif (idx !== -1) this._afterParentChangedHooks.splice(idx, 1);\n\t\t};\n\t}\n\n\t// ==================== Change Detection Methods ====================\n\n\t/**\n\t * The current monotonic change sequence value.\n\t * Each markChanged call increments this before stamping.\n\t */\n\tget changeSeq(): number {\n\t\treturn this._changeSeq;\n\t}\n\n\t/**\n\t * Mark a component as changed on an entity, stamping the next sequence number.\n\t * @param entityId The entity ID\n\t * @param componentName The component that changed\n\t */\n\tmarkChanged<K extends keyof ComponentTypes>(entityId: number, componentName: K): void {\n\t\tconst seq = ++this._changeSeq;\n\t\tlet entitySeqs = this.changeSeqs.get(entityId);\n\t\tif (!entitySeqs) {\n\t\t\tentitySeqs = new Map();\n\t\t\tthis.changeSeqs.set(entityId, entitySeqs);\n\t\t}\n\t\tentitySeqs.set(componentName, seq);\n\t}\n\n\t/**\n\t * Get the sequence number at which a component was last changed on an entity\n\t * @param entityId The entity ID\n\t * @param componentName The component to check\n\t * @returns The sequence number when last changed, or -1 if never changed\n\t */\n\tgetChangeSeq<K extends keyof ComponentTypes>(entityId: number, componentName: K): number {\n\t\treturn this.changeSeqs.get(entityId)?.get(componentName) ?? -1;\n\t}\n\n\t// ==================== Hierarchy Methods ====================\n\n\t/**\n\t * Create an entity as a child of another entity with initial components\n\t * @param parentId The parent entity ID\n\t * @param components Initial components to add\n\t * @returns The created child entity\n\t */\n\tspawnChild<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tparentId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes> {\n\t\tconst entity = this.createEntity();\n\t\tthis.addComponents(entity.id, components);\n\t\tthis.setParent(entity.id, parentId);\n\t\treturn entity as FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes>;\n\t}\n\n\t/**\n\t * Set the parent of an entity\n\t * @param childId The entity ID to set as a child\n\t * @param parentId The entity ID to set as the parent\n\t */\n\tsetParent(childId: number, parentId: number): this {\n\t\tthis.hierarchyManager.setParent(childId, parentId);\n\t\tfor (const hook of this._afterParentChangedHooks) {\n\t\t\thook(childId);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Remove the parent relationship for an entity (orphan it)\n\t * @param childId The entity ID to orphan\n\t * @returns true if a parent was removed, false if entity had no parent\n\t */\n\tremoveParent(childId: number): boolean {\n\t\tconst result = this.hierarchyManager.removeParent(childId);\n\t\tif (result) {\n\t\t\tfor (const hook of this._afterParentChangedHooks) {\n\t\t\t\thook(childId);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get the parent of an entity\n\t * @param entityId The entity ID to get the parent of\n\t * @returns The parent entity ID, or null if no parent\n\t */\n\tgetParent(entityId: number): number | null {\n\t\treturn this.hierarchyManager.getParent(entityId);\n\t}\n\n\t/**\n\t * Get all children of an entity in insertion order\n\t * @param parentId The parent entity ID\n\t * @returns Readonly array of child entity IDs\n\t */\n\tgetChildren(parentId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getChildren(parentId);\n\t}\n\n\t/**\n\t * Get a child at a specific index\n\t * @param parentId The parent entity ID\n\t * @param index The index of the child\n\t * @returns The child entity ID, or null if index is out of bounds\n\t */\n\tgetChildAt(parentId: number, index: number): number | null {\n\t\treturn this.hierarchyManager.getChildAt(parentId, index);\n\t}\n\n\t/**\n\t * Get the index of a child within its parent's children list\n\t * @param parentId The parent entity ID\n\t * @param childId The child entity ID to find\n\t * @returns The index of the child, or -1 if not found\n\t */\n\tgetChildIndex(parentId: number, childId: number): number {\n\t\treturn this.hierarchyManager.getChildIndex(parentId, childId);\n\t}\n\n\t/**\n\t * Get all ancestors of an entity in order [parent, grandparent, ...]\n\t * @param entityId The entity ID to get ancestors of\n\t * @returns Readonly array of ancestor entity IDs\n\t */\n\tgetAncestors(entityId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getAncestors(entityId);\n\t}\n\n\t/**\n\t * Get all descendants of an entity in depth-first order\n\t * @param entityId The entity ID to get descendants of\n\t * @returns Readonly array of descendant entity IDs\n\t */\n\tgetDescendants(entityId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getDescendants(entityId);\n\t}\n\n\t/**\n\t * Get the root ancestor of an entity (topmost parent), or self if no parent\n\t * @param entityId The entity ID to get the root of\n\t * @returns The root entity ID\n\t */\n\tgetRoot(entityId: number): number {\n\t\treturn this.hierarchyManager.getRoot(entityId);\n\t}\n\n\t/**\n\t * Get siblings of an entity (other children of the same parent)\n\t * @param entityId The entity ID to get siblings of\n\t * @returns Readonly array of sibling entity IDs\n\t */\n\tgetSiblings(entityId: number): readonly number[] {\n\t\treturn this.hierarchyManager.getSiblings(entityId);\n\t}\n\n\t/**\n\t * Check if an entity is a descendant of another entity\n\t * @param entityId The potential descendant ID\n\t * @param ancestorId The potential ancestor ID\n\t * @returns true if entityId is a descendant of ancestorId\n\t */\n\tisDescendantOf(entityId: number, ancestorId: number): boolean {\n\t\treturn this.hierarchyManager.isDescendantOf(entityId, ancestorId);\n\t}\n\n\t/**\n\t * Check if an entity is an ancestor of another entity\n\t * @param entityId The potential ancestor ID\n\t * @param descendantId The potential descendant ID\n\t * @returns true if entityId is an ancestor of descendantId\n\t */\n\tisAncestorOf(entityId: number, descendantId: number): boolean {\n\t\treturn this.hierarchyManager.isAncestorOf(entityId, descendantId);\n\t}\n\n\t/**\n\t * Returns true when at least one parent-child relationship exists.\n\t */\n\tget hasHierarchy(): boolean {\n\t\treturn this.hierarchyManager.hasHierarchy;\n\t}\n\n\t/**\n\t * Get all root entities (entities that have children but no parent)\n\t * @returns Readonly array of root entity IDs\n\t */\n\tgetRootEntities(): readonly number[] {\n\t\treturn this.hierarchyManager.getRootEntities();\n\t}\n\n\t/**\n\t * Traverse the hierarchy in parent-first (breadth-first) order.\n\t * Parents are guaranteed to be visited before their children.\n\t * @param callback Function called for each entity with (entityId, parentId, depth)\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t */\n\tforEachInHierarchy(\n\t\tcallback: (entityId: number, parentId: number | null, depth: number) => void,\n\t\toptions?: HierarchyIteratorOptions\n\t): void {\n\t\tthis.hierarchyManager.forEachInHierarchy(callback, options);\n\t}\n\n\t/**\n\t * Generator-based hierarchy traversal in parent-first (breadth-first) order.\n\t * Supports early termination via break.\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t * @yields HierarchyEntry for each entity in parent-first order\n\t */\n\thierarchyIterator(options?: HierarchyIteratorOptions): Generator<HierarchyEntry, void, unknown> {\n\t\treturn this.hierarchyManager.hierarchyIterator(options);\n\t}\n}\n",
|
|
7
7
|
"interface EventHandler<T> {\n\tcallback: (data: T) => void;\n\tonce: boolean;\n}\n\nexport default\nclass EventBus<EventTypes> {\n\tprivate handlers: Map<keyof EventTypes, Array<EventHandler<any>>> = new Map();\n\n\t/**\n\t * Subscribe to an event\n\t */\n\tsubscribe<E extends keyof EventTypes>(\n\t\teventType: E,\n\t\tcallback: (data: EventTypes[E]) => void\n\t): () => void {\n\t\treturn this.addHandler(eventType, callback, false);\n\t}\n\n\t/**\n\t * Subscribe to an event once\n\t */\n\tonce<E extends keyof EventTypes>(\n\t\teventType: E,\n\t\tcallback: (data: EventTypes[E]) => void\n\t): () => void {\n\t\treturn this.addHandler(eventType, callback, true);\n\t}\n\n\t/**\n\t * Unsubscribe a specific callback from an event by reference\n\t * @returns true if the callback was found and removed, false otherwise\n\t */\n\tunsubscribe<E extends keyof EventTypes>(\n\t\teventType: E,\n\t\tcallback: (data: EventTypes[E]) => void\n\t): boolean {\n\t\tconst handlers = this.handlers.get(eventType);\n\t\tif (!handlers) return false;\n\n\t\tconst index = handlers.findIndex(h => h.callback === callback);\n\t\tif (index === -1) return false;\n\n\t\thandlers.splice(index, 1);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Internal method to add an event handler\n\t */\n\tprivate addHandler<E extends keyof EventTypes>(\n\t\teventType: E,\n\t\tcallback: (data: EventTypes[E]) => void,\n\t\tonce: boolean\n\t): () => void {\n\t\tlet handlers = this.handlers.get(eventType);\n\t\tif (!handlers) {\n\t\t\thandlers = [];\n\t\t\tthis.handlers.set(eventType, handlers);\n\t\t}\n\n\t\tconst handler: EventHandler<any> = {\n\t\t\tcallback,\n\t\t\tonce\n\t\t};\n\n\t\thandlers.push(handler);\n\n\t\t// Return unsubscribe function\n\t\treturn () => {\n\t\t\tconst handlers = this.handlers.get(eventType);\n\t\t\tif (handlers) {\n\t\t\t\tconst index = handlers.indexOf(handler);\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\thandlers.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Publish an event. Data is required unless EventTypes[E] extends void | undefined.\n\t * Zero-allocation hot path: uses index-based iteration with a snapshot length\n\t * so handlers added mid-publish are not called in the same publish cycle.\n\t */\n\tpublish<E extends keyof EventTypes>(\n\t\t...[eventType, data]: EventTypes[E] extends void | undefined\n\t\t\t? [eventType: E, data?: EventTypes[E]]\n\t\t\t: [eventType: E, data: EventTypes[E]]\n\t): void {\n\t\tconst handlers = this.handlers.get(eventType);\n\t\tif (!handlers || handlers.length === 0) return;\n\n\t\t// Snapshot length prevents calling handlers added mid-publish\n\t\tlet hasOnce = false;\n\t\tconst len = handlers.length;\n\t\tfor (let i = 0; i < len && i < handlers.length; i++) {\n\t\t\tconst handler = handlers[i];\n\t\t\tif (!handler) continue;\n\t\t\thandler.callback(data as EventTypes[E]);\n\t\t\tif (handler.once) hasOnce = true;\n\t\t}\n\n\t\t// Reverse splice to remove once-handlers without shifting earlier indices\n\t\tif (hasOnce) {\n\t\t\tfor (let i = handlers.length - 1; i >= 0; i--) {\n\t\t\t\tif (handlers[i]?.once) {\n\t\t\t\t\thandlers.splice(i, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tthis.handlers.clear();\n\t}\n\n\tclearEvent<E extends keyof EventTypes>(eventType: E): void {\n\t\tthis.handlers.delete(eventType);\n\t}\n}\n",
|
|
8
8
|
"/**\n * Resource factory with declared dependencies and optional disposal callback\n */\nexport interface ResourceFactoryWithDeps<T, Context = unknown, D extends string = string> {\n\tdependsOn?: readonly D[];\n\tfactory: (context: Context) => T | Promise<T>;\n\tonDispose?: (resource: T, context: Context) => void | Promise<void>;\n}\n\n/** @internal */\nexport const RESOURCE_DIRECT: unique symbol = Symbol('resource-direct');\n\n/**\n * Branded wrapper for storing a value as-is, bypassing factory detection.\n * The value is carried on the symbol key to avoid structural conflicts\n * with user resource types that have a `value` property.\n * Create via the `directValue()` helper.\n */\nexport interface ResourceDirectValue<T> {\n\t[RESOURCE_DIRECT]: T;\n}\n\n/**\n * Wrap a value to store it as-is, bypassing factory detection.\n * Use when the resource itself is a function or class that should not be invoked.\n *\n * @example\n * ```ts\n * import { directValue } from 'ecspresso';\n * world.addResource('handler', directValue(myFunction));\n * world.addResource('MyClass', directValue(MyClass));\n * ```\n */\nexport function directValue<T>(value: T): ResourceDirectValue<T> {\n\treturn { [RESOURCE_DIRECT]: value };\n}\n\n/**\n * Create a shallow snapshot of a value for change detection.\n * For objects, copies own enumerable properties one level deep.\n * For primitives, wraps in { $value } so reference changes are caught.\n */\nfunction shallowSnapshot(value: unknown): Record<string, unknown> {\n\tif (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n\t\treturn { ...value as Record<string, unknown> };\n\t}\n\treturn { $value: value };\n}\n\n/**\n * Compare a live value against a snapshot taken by shallowSnapshot.\n * Returns true if any shallow property differs.\n */\nfunction shallowChanged(current: unknown, snapshot: Record<string, unknown>): boolean {\n\tif (typeof current === 'object' && current !== null && !Array.isArray(current)) {\n\t\tconst obj = current as Record<string, unknown>;\n\t\tfor (const k in snapshot) {\n\t\t\tif (!Object.is(obj[k], snapshot[k])) return true;\n\t\t}\n\t\treturn false;\n\t}\n\treturn !Object.is(current, snapshot['$value']);\n}\n\n/**\n * Type guard for detecting { factory } pattern (with optional dependsOn and onDispose)\n */\nfunction isFactoryWithDeps<T>(resource: unknown): resource is ResourceFactoryWithDeps<T> {\n\treturn (\n\t\ttypeof resource === 'object' &&\n\t\tresource !== null &&\n\t\t'factory' in resource &&\n\t\ttypeof (resource as ResourceFactoryWithDeps<T>).factory === 'function'\n\t);\n}\n\n/**\n * Type guard for detecting { value } wrapper pattern (branded with symbol)\n */\nfunction isDirectValue<T>(resource: unknown): resource is ResourceDirectValue<T> {\n\treturn (\n\t\ttypeof resource === 'object' &&\n\t\tresource !== null &&\n\t\tRESOURCE_DIRECT in resource\n\t);\n}\n\n/**\n * Topological sort with cycle detection\n */\nfunction topologicalSort<K extends string>(\n\tkeys: readonly K[],\n\tgetDeps: (key: K) => readonly string[]\n): K[] {\n\tconst sorted: K[] = [];\n\tconst visited = new Set<K>();\n\tconst visiting = new Set<K>();\n\n\tfunction visit(key: K, path: K[] = []): void {\n\t\tif (visited.has(key)) return;\n\t\tif (visiting.has(key)) {\n\t\t\tthrow new Error(`Circular resource dependency: ${[...path, key].join(' -> ')}`);\n\t\t}\n\n\t\tvisiting.add(key);\n\t\tfor (const dep of getDeps(key)) {\n\t\t\tconst found = keys.find(k => k === dep);\n\t\t\tif (found) {\n\t\t\t\tvisit(found, [...path, key]);\n\t\t\t}\n\t\t}\n\t\tvisiting.delete(key);\n\t\tvisited.add(key);\n\t\tsorted.push(key);\n\t}\n\n\tfor (const key of keys) {\n\t\tvisit(key);\n\t}\n\treturn sorted;\n}\n\n/**\n * When Context is unknown (default), context args are optional.\n * When Context is a specific type (e.g. ECSpresso<...>), context is required.\n */\ntype ContextArgs<Context> = unknown extends Context ? [context?: Context] : [context: Context];\n\nexport default\nclass ResourceManager<\n\tResourceTypes extends Record<string, any> = Record<string, any>,\n\tContext = unknown,\n> {\n\tprivate resources: Map<keyof ResourceTypes, any> = new Map();\n\tprivate resourceFactories: Map<keyof ResourceTypes, (context: Context) => any | Promise<any>> = new Map();\n\tprivate resourceDependencies: Map<keyof ResourceTypes, readonly (keyof ResourceTypes & string)[]> = new Map();\n\tprivate resourceDisposers: Map<keyof ResourceTypes, (resource: any, context: Context) => void | Promise<void>> = new Map();\n\tprivate initializedResourceKeys: Set<keyof ResourceTypes> = new Set();\n\tprivate _changeSubscribers: Map<keyof ResourceTypes, Set<(newValue: any, oldValue: any) => void>> = new Map();\n\t/** Shallow snapshots of observed resources, keyed by resource key */\n\tprivate _observedSnapshots: Map<keyof ResourceTypes, Record<string, unknown>> = new Map();\n\n\t/**\n\t * Add a resource to the manager.\n\t *\n\t * Resolution order:\n\t * 1. `{ factory, dependsOn?, onDispose? }` → factory with optional deps/disposal\n\t * 2. `{ value }` → direct value wrapper (use to store functions/classes as-is)\n\t * 3. `typeof === 'function'` → bare factory (no deps)\n\t * 4. Anything else → direct value\n\t *\n\t * @param label The resource key\n\t * @param resource The resource value, a factory function, or a factory with dependencies\n\t * @returns The resource manager instance for chaining\n\t */\n\tadd<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\tresource:\n\t\t\t| ResourceTypes[K]\n\t\t\t| ((context: Context) => ResourceTypes[K] | Promise<ResourceTypes[K]>)\n\t\t\t| ResourceFactoryWithDeps<ResourceTypes[K], Context, keyof ResourceTypes & string>\n\t\t\t| ResourceDirectValue<ResourceTypes[K]>,\n\t) {\n\t\tconst storeValue = (value: unknown) => {\n\t\t\tthis.resources.set(label, value);\n\t\t\tthis.initializedResourceKeys.add(label);\n\t\t\tthis.resourceDependencies.set(label, []);\n\t\t};\n\n\t\tif (isFactoryWithDeps<ResourceTypes[K]>(resource)) {\n\t\t\t// Factory with optional dependencies and/or onDispose\n\t\t\tthis.resourceFactories.set(label, resource.factory as (context: Context) => any | Promise<any>);\n\t\t\t// Type guard narrows to default D=string; the call-site constraint ensures correctness\n\t\t\tthis.resourceDependencies.set(label, (resource.dependsOn ?? []) as readonly (keyof ResourceTypes & string)[]);\n\t\t\tif (resource.onDispose) {\n\t\t\t\tthis.resourceDisposers.set(label, resource.onDispose as (resource: any, context: Context) => void | Promise<void>);\n\t\t\t}\n\t\t} else if (isDirectValue<ResourceTypes[K]>(resource)) {\n\t\t\tstoreValue(resource[RESOURCE_DIRECT]);\n\t\t} else if (typeof resource === 'function') {\n\t\t\t// Bare function → treat as factory (no dependencies)\n\t\t\tthis.resourceFactories.set(label, resource as (context: Context) => any | Promise<any>);\n\t\t\tthis.resourceDependencies.set(label, []);\n\t\t} else {\n\t\t\tstoreValue(resource);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Try to get a resource from the manager.\n\t * Returns the resource value if it exists, or undefined if not found.\n\t * Like `get`, initializes factory resources on first access.\n\t * @param label The resource key\n\t * @param context Context to pass to factory functions (usually the ECSpresso instance)\n\t * @returns The resource value, or undefined if not found\n\t * @see get — the throwing alternative\n\t */\n\ttryGet<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\t...args: ContextArgs<Context>\n\t): ResourceTypes[K] | undefined {\n\t\tif (!this.has(label)) return undefined;\n\t\treturn this.get(label, ...args);\n\t}\n\n\t/**\n\t * Get a resource from the manager\n\t * @param label The resource key\n\t * @param context Context to pass to factory functions (usually the ECSpresso instance)\n\t * @returns The resource value\n\t * @throws Error if resource not found\n\t * @see tryGet — the non-throwing alternative\n\t */\n\tget<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\t...args: ContextArgs<Context>\n\t): ResourceTypes[K] {\n\t\t// Check if we already have the initialized resource\n\t\tconst resource = this.resources.get(label);\n\t\tif (resource !== undefined) {\n\t\t\treturn resource;\n\t\t}\n\n\t\t// Check if we have a factory for this resource\n\t\tconst factory = this.resourceFactories.get(label);\n\t\tif (factory === undefined) {\n\t\t\tthrow new Error(`Resource ${String(label)} not found`);\n\t\t}\n\n\t\t// Initialize the resource, passing the context\n\t\tconst context = args[0] as Context;\n\t\tconst initializedResource = factory(context);\n\n\t\t// If it's not a Promise, store it immediately\n\t\tif (!(initializedResource instanceof Promise)) {\n\t\t\tthis.resources.set(label, initializedResource);\n\t\t\tthis.initializedResourceKeys.add(label);\n\t\t}\n\n\t\treturn initializedResource;\n\t}\n\n\t/**\n\t * Check if a resource exists\n\t * @param label The resource key\n\t * @returns True if the resource exists\n\t */\n\thas<K extends keyof ResourceTypes>(label: K): boolean {\n\t\treturn this.resources.has(label) || this.resourceFactories.has(label);\n\t}\n\n\t/**\n\t * Remove a resource (without calling onDispose)\n\t * @param label The resource key\n\t * @returns True if the resource was removed\n\t */\n\tremove<K extends keyof ResourceTypes>(label: K): boolean {\n\t\tconst resourceRemoved = this.resources.delete(label);\n\t\tconst factoryRemoved = this.resourceFactories.delete(label);\n\t\tthis.resourceDependencies.delete(label);\n\t\tthis.resourceDisposers.delete(label);\n\t\tthis.initializedResourceKeys.delete(label);\n\t\treturn resourceRemoved || factoryRemoved;\n\t}\n\n\t/**\n\t * Get all resource keys\n\t * @returns Array of resource keys\n\t */\n\tgetKeys(): Array<keyof ResourceTypes> {\n\t\tconst keys = new Set([\n\t\t\t...this.resources.keys(),\n\t\t\t...this.resourceFactories.keys()\n\t\t]);\n\t\treturn Array.from(keys);\n\t}\n\n\t/**\n\t * Check if a resource needs to be initialized\n\t * @param label The resource key\n\t * @returns True if the resource needs initialization\n\t */\n\tneedsInitialization<K extends keyof ResourceTypes>(label: K): boolean {\n\t\treturn this.resourceFactories.has(label) && !this.initializedResourceKeys.has(label);\n\t}\n\n\t/**\n\t * Get all resource keys that need to be initialized\n\t * @returns Array of resource keys that need initialization\n\t */\n\tgetPendingInitializationKeys(): Array<keyof ResourceTypes> {\n\t\treturn Array\n\t\t\t.from(this.resourceFactories.keys())\n\t\t\t.filter(key => !this.initializedResourceKeys.has(key));\n\t}\n\n\t/**\n\t * Initialize a specific resource if it's a factory function\n\t * @param label The resource key\n\t * @param context Context to pass to factory functions\n\t * @returns Promise that resolves when the resource is initialized\n\t */\n\tasync initializeResource<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\t...args: ContextArgs<Context>\n\t): Promise<void> {\n\t\tif (!this.resourceFactories.has(label) || this.initializedResourceKeys.has(label)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst factory = this.resourceFactories.get(label);\n\t\tif (!factory) return;\n\t\tconst context = args[0] as Context;\n\t\tconst initializedResource = await factory(context);\n\t\tthis.resources.set(label, initializedResource);\n\t\tthis.initializedResourceKeys.add(label);\n\t\tthis.resourceFactories.delete(label);\n\t}\n\n\t/**\n\t * Initialize specific resources or all resources that haven't been initialized yet.\n\t * Resources are initialized in topological order based on their dependencies.\n\t * @param context Context to pass to factory functions (usually the ECSpresso instance)\n\t * @param keys Optional array of resource keys to initialize\n\t * @returns Promise that resolves when the specified resources are initialized\n\t */\n\tasync initializeResources<K extends keyof ResourceTypes>(\n\t\t...args: [...ContextArgs<Context>, ...K[]]\n\t): Promise<void> {\n\t\t// First arg is context (when Context is typed), remaining are keys\n\t\tconst keys = args.slice(1) as K[];\n\n\t\t// Determine which keys to initialize\n\t\tconst keysToInit = keys.length === 0\n\t\t\t? this.getPendingInitializationKeys()\n\t\t\t: keys;\n\n\t\t// If no keys to initialize, we're done\n\t\tif (keysToInit.length === 0) return;\n\n\t\t// Sort keys topologically based on dependencies\n\t\tconst sortedKeys = topologicalSort(\n\t\t\tkeysToInit as readonly (keyof ResourceTypes & string)[],\n\t\t\t(key) => [...(this.resourceDependencies.get(key) ?? [])]\n\t\t);\n\n\t\t// Initialize in order (sequentially to respect dependencies)\n\t\tfor (const key of sortedKeys) {\n\t\t\tawait this.initializeResource(key, ...args.slice(0, 1) as ContextArgs<Context>);\n\t\t}\n\t}\n\n\t/**\n\t * Get the dependencies of a resource\n\t * @param label The resource key\n\t * @returns Array of resource keys that this resource depends on\n\t */\n\tgetDependencies<K extends keyof ResourceTypes>(label: K): readonly (keyof ResourceTypes & string)[] {\n\t\treturn this.resourceDependencies.get(label) ?? [];\n\t}\n\n\t/**\n\t * Dispose a single resource, calling its onDispose callback if it exists\n\t * @param label The resource key to dispose\n\t * @param context Context to pass to the onDispose callback\n\t * @returns True if the resource existed and was disposed, false if it didn't exist\n\t */\n\tasync disposeResource<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\t...args: ContextArgs<Context>\n\t): Promise<boolean> {\n\t\tif (!this.resources.has(label) && !this.resourceFactories.has(label)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Only call onDispose if the resource was initialized\n\t\tif (this.initializedResourceKeys.has(label)) {\n\t\t\tconst disposer = this.resourceDisposers.get(label);\n\t\t\tconst resource = this.resources.get(label);\n\t\t\tif (disposer && resource !== undefined) {\n\t\t\t\tconst context = args[0] as Context;\n\t\t\t\tawait disposer(resource, context);\n\t\t\t}\n\t\t}\n\n\t\t// Clean up all tracking\n\t\tthis.resources.delete(label);\n\t\tthis.resourceFactories.delete(label);\n\t\tthis.resourceDependencies.delete(label);\n\t\tthis.resourceDisposers.delete(label);\n\t\tthis.initializedResourceKeys.delete(label);\n\t\tthis._changeSubscribers.delete(label);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Subscribe to changes for a specific resource key.\n\t *\n\t * Subscribing marks the resource as \"observed.\" Observed resources:\n\t * - Are re-resolved each frame by `withResources` (no stale cache)\n\t * - Are shallow-diffed at the end of each frame via `flushObserved()`,\n\t * so in-place mutations are detected and subscribers notified\n\t *\n\t * When the last subscriber unsubscribes, the resource reverts to\n\t * normal (cached, no per-frame diff).\n\t *\n\t * @param key The resource key to watch\n\t * @param callback Function called with (newValue, oldValue) when the resource changes\n\t * @returns Unsubscribe function\n\t */\n\tonResourceChange<K extends keyof ResourceTypes>(\n\t\tkey: K,\n\t\tcallback: (newValue: ResourceTypes[K], oldValue: ResourceTypes[K]) => void\n\t): () => void {\n\t\tconst existing = this._changeSubscribers.get(key);\n\t\tconst subscribers = existing ?? new Set<(newValue: any, oldValue: any) => void>();\n\t\tif (!existing) {\n\t\t\tthis._changeSubscribers.set(key, subscribers);\n\t\t\t// First subscriber — take a shallow snapshot for per-frame diffing\n\t\t\tconst current = this.resources.get(key);\n\t\t\tthis._observedSnapshots.set(key, shallowSnapshot(current));\n\t\t}\n\t\tconst wrapped = callback as (newValue: any, oldValue: any) => void;\n\t\tsubscribers.add(wrapped);\n\n\t\treturn () => {\n\t\t\tsubscribers.delete(wrapped);\n\t\t\tif (subscribers.size === 0) {\n\t\t\t\tthis._changeSubscribers.delete(key);\n\t\t\t\tthis._observedSnapshots.delete(key);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Notify subscribers of a resource value change.\n\t * Skips notification if the value is unchanged (via Object.is).\n\t * @param key The resource key that changed\n\t * @param newValue The new resource value\n\t * @param oldValue The previous resource value\n\t */\n\tnotifyChange<K extends keyof ResourceTypes>(\n\t\tkey: K,\n\t\tnewValue: ResourceTypes[K],\n\t\toldValue: ResourceTypes[K]\n\t): void {\n\t\tif (Object.is(newValue, oldValue)) return;\n\t\tconst subscribers = this._changeSubscribers.get(key);\n\t\tif (!subscribers || subscribers.size === 0) return;\n\t\t// Update snapshot so flushObserved doesn't double-fire for this change\n\t\tif (this._observedSnapshots.has(key)) {\n\t\t\tthis._observedSnapshots.set(key, shallowSnapshot(newValue));\n\t\t}\n\t\tconst subscriberSnapshot = [...subscribers];\n\t\tfor (const cb of subscriberSnapshot) {\n\t\t\tcb(newValue, oldValue);\n\t\t}\n\t}\n\n\t/**\n\t * Whether a resource has active change subscribers.\n\t * Observed resources should not be cached by systems — they need\n\t * to be re-resolved each frame so external mutations are visible.\n\t */\n\tisObserved<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._observedSnapshots.has(key);\n\t}\n\n\t/**\n\t * Diff all observed resources against their snapshots.\n\t * Fires subscribers for any resource whose shallow properties changed\n\t * since the last snapshot, then updates the snapshot.\n\t * Call once per frame after all systems have run.\n\t */\n\tflushObserved(): void {\n\t\tif (this._observedSnapshots.size === 0) return;\n\t\tfor (const [key, snapshot] of this._observedSnapshots) {\n\t\t\tconst current = this.resources.get(key);\n\t\t\tif (!shallowChanged(current, snapshot)) continue;\n\n\t\t\t// Reconstruct the old value from the snapshot encoding\n\t\t\tconst oldValue = '$value' in snapshot ? snapshot['$value'] : snapshot;\n\t\t\tconst newSnapshot = shallowSnapshot(current);\n\t\t\tconst subscribers = this._changeSubscribers.get(key)!;\n\t\t\tfor (const cb of subscribers) {\n\t\t\t\tcb(current, oldValue);\n\t\t\t}\n\t\t\tthis._observedSnapshots.set(key, newSnapshot);\n\t\t}\n\t}\n\n\t/**\n\t * Dispose all initialized resources in reverse dependency order.\n\t * Resources that depend on others are disposed first.\n\t * @param context Context to pass to onDispose callbacks\n\t */\n\tasync disposeResources(\n\t\t...args: ContextArgs<Context>\n\t): Promise<void> {\n\t\t// Get only initialized resource keys\n\t\tconst initializedKeys = Array.from(this.initializedResourceKeys);\n\n\t\tif (initializedKeys.length === 0) return;\n\n\t\t// Sort in dependency order, then reverse for disposal\n\t\tconst sortedKeys = topologicalSort(\n\t\t\tinitializedKeys as readonly (keyof ResourceTypes & string)[],\n\t\t\t(key) => [...(this.resourceDependencies.get(key) ?? [])]\n\t\t).reverse();\n\n\t\t// Dispose in reverse dependency order\n\t\tfor (const key of sortedKeys) {\n\t\t\tawait this.disposeResource(key, ...args);\n\t\t}\n\t}\n}\n",
|
|
9
9
|
"import type { Entity, FilteredEntity } from \"./types\";\nimport type EntityManager from \"./entity-manager\";\n\n/**\n * Definition for a reactive query with enter/exit callbacks\n */\nexport interface ReactiveQueryDefinition<\n\tComponentTypes extends Record<string, any>,\n\tWithComponents extends keyof ComponentTypes = keyof ComponentTypes,\n\tWithoutComponents extends keyof ComponentTypes = never,\n\tOptionalComponents extends keyof ComponentTypes = never,\n> {\n\t/** Components the entity must have */\n\twith: ReadonlyArray<WithComponents>;\n\t/** Components the entity must not have */\n\twithout?: ReadonlyArray<WithoutComponents>;\n\t/** Components to include in the entity type but not require for matching */\n\toptional?: ReadonlyArray<OptionalComponents>;\n\t/** Components the entity's direct parent must have */\n\tparentHas?: ReadonlyArray<keyof ComponentTypes>;\n\t/** Called when an entity starts matching the query */\n\tonEnter?: (entity: FilteredEntity<ComponentTypes, WithComponents, WithoutComponents, OptionalComponents>) => void;\n\t/** Called when an entity stops matching the query (receives just the ID since entity may be gone) */\n\tonExit?: (entityId: number) => void;\n}\n\ninterface StoredQuery<ComponentTypes extends Record<string, any>> {\n\tdefinition: ReactiveQueryDefinition<ComponentTypes, any, any, any>;\n\tmatchingEntities: Set<number>;\n}\n\n/**\n * Manages reactive queries that trigger callbacks when entities enter/exit query matches\n */\nexport default class ReactiveQueryManager<ComponentTypes extends Record<string, any>, QueryNames extends string = string> {\n\tprivate queries: Map<string, StoredQuery<ComponentTypes>> = new Map();\n\tprivate entityManager: EntityManager<ComponentTypes>;\n\t/** Whether any registered query uses parentHas */\n\tprivate _hasParentHasQueries: boolean = false;\n\n\tconstructor(entityManager: EntityManager<ComponentTypes>) {\n\t\tthis.entityManager = entityManager;\n\t}\n\n\t/**\n\t * Whether any registered reactive query uses parentHas filters\n\t */\n\tget hasParentHasQueries(): boolean {\n\t\treturn this._hasParentHasQueries;\n\t}\n\n\t/**\n\t * Add a reactive query\n\t * @param name Unique name for the query\n\t * @param definition Query definition with callbacks\n\t */\n\taddQuery<\n\t\tWithComponents extends keyof ComponentTypes,\n\t\tWithoutComponents extends keyof ComponentTypes = never,\n\t\tOptionalComponents extends keyof ComponentTypes = never,\n\t>(\n\t\tname: QueryNames,\n\t\tdefinition: ReactiveQueryDefinition<ComponentTypes, WithComponents, WithoutComponents, OptionalComponents>\n\t): void {\n\t\tconst storedQuery: StoredQuery<ComponentTypes> = {\n\t\t\tdefinition,\n\t\t\tmatchingEntities: new Set(),\n\t\t};\n\n\t\tthis.queries.set(name, storedQuery);\n\n\t\t// Update parentHas flag\n\t\tif (definition.parentHas?.length) {\n\t\t\tthis._hasParentHasQueries = true;\n\t\t}\n\n\t\t// Check existing entities for initial matches\n\t\tconst existingMatches = this.entityManager.getEntitiesWithQuery(\n\t\t\tdefinition.with as ReadonlyArray<keyof ComponentTypes>,\n\t\t\t(definition.without ?? []) as ReadonlyArray<keyof ComponentTypes>\n\t\t);\n\n\t\tfor (const entity of existingMatches) {\n\t\t\tif (this.entityMatchesQuery(entity, storedQuery.definition)) {\n\t\t\t\tstoredQuery.matchingEntities.add(entity.id);\n\t\t\t\tstoredQuery.definition.onEnter?.(entity as FilteredEntity<ComponentTypes, any, any, any>);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Remove a reactive query\n\t * @param name Name of the query to remove\n\t * @returns true if the query existed and was removed\n\t */\n\tremoveQuery(name: QueryNames): boolean {\n\t\tconst result = this.queries.delete(name);\n\n\t\t// Recalculate parentHas flag\n\t\tif (result) {\n\t\t\tthis._recalcParentHasFlag();\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Check if an entity matches a query definition\n\t */\n\tprivate entityMatchesQuery(\n\t\tentity: Entity<ComponentTypes>,\n\t\tdefinition: ReactiveQueryDefinition<ComponentTypes, any, any, any>\n\t): boolean {\n\t\t// Check required components\n\t\tfor (const comp of definition.with) {\n\t\t\tif (!(comp in entity.components)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Check excluded components\n\t\tif (definition.without) {\n\t\t\tfor (const comp of definition.without) {\n\t\t\t\tif (comp in entity.components) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check parentHas\n\t\tif (definition.parentHas?.length) {\n\t\t\tconst parentId = this.entityManager.getParent(entity.id);\n\t\t\tif (parentId === null) return false;\n\n\t\t\tconst parentEntity = this.entityManager.getEntity(parentId);\n\t\t\tif (!parentEntity) return false;\n\n\t\t\tfor (const comp of definition.parentHas) {\n\t\t\t\tif (!(comp in parentEntity.components)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply enter/exit transitions for a single query against an entity.\n\t * Fires onEnter when entity starts matching, onExit when it stops.\n\t */\n\tprivate _applyQueryTransition(entity: Entity<ComponentTypes>, query: StoredQuery<ComponentTypes>): void {\n\t\tconst wasMatching = query.matchingEntities.has(entity.id);\n\t\tconst nowMatches = this.entityMatchesQuery(entity, query.definition);\n\n\t\tif (!wasMatching && nowMatches) {\n\t\t\tquery.matchingEntities.add(entity.id);\n\t\t\tquery.definition.onEnter?.(entity as FilteredEntity<ComponentTypes, any, any, any>);\n\t\t} else if (wasMatching && !nowMatches) {\n\t\t\tquery.matchingEntities.delete(entity.id);\n\t\t\tquery.definition.onExit?.(entity.id);\n\t\t}\n\t}\n\n\t/**\n\t * Called when a component is added to an entity\n\t * Checks all queries for potential enter/exit events\n\t */\n\tonComponentAdded(entity: Entity<ComponentTypes>, _componentName: keyof ComponentTypes): void {\n\t\tfor (const [, query] of this.queries) {\n\t\t\tthis._applyQueryTransition(entity, query);\n\t\t}\n\n\t\tif (this._hasParentHasQueries) {\n\t\t\tthis._recheckChildren(entity.id);\n\t\t}\n\t}\n\n\t/**\n\t * Called when a component is removed from an entity\n\t * Checks all queries for potential enter/exit events\n\t */\n\tonComponentRemoved(entity: Entity<ComponentTypes>, _componentName: keyof ComponentTypes): void {\n\t\tfor (const [, query] of this.queries) {\n\t\t\tthis._applyQueryTransition(entity, query);\n\t\t}\n\n\t\tif (this._hasParentHasQueries) {\n\t\t\tthis._recheckChildren(entity.id);\n\t\t}\n\t}\n\n\t/**\n\t * Called when an entity is removed\n\t * Triggers onExit for all queries the entity was matching\n\t */\n\tonEntityRemoved(entityId: number): void {\n\t\tfor (const [_name, query] of this.queries) {\n\t\t\tif (query.matchingEntities.has(entityId)) {\n\t\t\t\tquery.matchingEntities.delete(entityId);\n\t\t\t\tquery.definition.onExit?.(entityId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Recheck an entity against all queries (used after batch component additions)\n\t * Fires enter/exit callbacks as appropriate based on current state vs tracked state\n\t */\n\trecheckEntity(entity: Entity<ComponentTypes>): void {\n\t\tfor (const [, query] of this.queries) {\n\t\t\tthis._applyQueryTransition(entity, query);\n\t\t}\n\t}\n\n\t/**\n\t * Recheck an entity and its children against all queries.\n\t * Used after component mutations to handle both the entity's own queries\n\t * and parentHas queries on its children.\n\t */\n\trecheckEntityAndChildren(entity: Entity<ComponentTypes>): void {\n\t\tthis.recheckEntity(entity);\n\t\tif (this._hasParentHasQueries) {\n\t\t\tthis._recheckChildren(entity.id);\n\t\t}\n\t}\n\n\t/**\n\t * Recheck all children of a parent entity against parentHas queries.\n\t * Called when a component is added/removed from a parent entity.\n\t */\n\tprivate _recheckChildren(parentId: number): void {\n\t\tconst children = this.entityManager.getChildren(parentId);\n\t\tfor (const childId of children) {\n\t\t\tconst childEntity = this.entityManager.getEntity(childId);\n\t\t\tif (childEntity) {\n\t\t\t\tthis.recheckEntity(childEntity);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Recalculate the _hasParentHasQueries flag from all registered queries\n\t */\n\tprivate _recalcParentHasFlag(): void {\n\t\tthis._hasParentHasQueries = false;\n\t\tfor (const [, query] of this.queries) {\n\t\t\tif (query.definition.parentHas?.length) {\n\t\t\t\tthis._hasParentHasQueries = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"/**\n * Shared vector math utilities for ECSpresso bundles.\n * All functions are pure — they return new vectors, never mutate inputs.\n */\n\n/**\n * A 2D vector with x and y components.\n */\nexport interface Vector2D {\n\tx: number;\n\ty: number;\n}\n\n/**\n * Create a Vector2D from x and y components.\n */\nexport function vec2(x: number, y: number): Vector2D {\n\treturn { x, y };\n}\n\n/**\n * Return a zero vector {x: 0, y: 0}.\n */\nexport function vec2Zero(): Vector2D {\n\treturn { x: 0, y: 0 };\n}\n\n/**\n * Add two vectors component-wise.\n */\nexport function vec2Add(a: Vector2D, b: Vector2D): Vector2D {\n\treturn { x: a.x + b.x, y: a.y + b.y };\n}\n\n/**\n * Subtract b from a component-wise.\n */\nexport function vec2Sub(a: Vector2D, b: Vector2D): Vector2D {\n\treturn { x: a.x - b.x, y: a.y - b.y };\n}\n\n/**\n * Scale a vector by a scalar.\n */\nexport function vec2Scale(v: Vector2D, scalar: number): Vector2D {\n\treturn { x: v.x * scalar, y: v.y * scalar };\n}\n\n/**\n * Negate a vector (flip both components).\n */\nexport function vec2Negate(v: Vector2D): Vector2D {\n\treturn { x: -v.x, y: -v.y };\n}\n\n/**\n * Compute the dot product of two vectors.\n */\nexport function vec2Dot(a: Vector2D, b: Vector2D): number {\n\treturn a.x * b.x + a.y * b.y;\n}\n\n/**\n * Compute the 2D cross product (scalar z-component of the 3D cross product).\n */\nexport function vec2Cross(a: Vector2D, b: Vector2D): number {\n\treturn a.x * b.y - a.y * b.x;\n}\n\n/**\n * Compute the squared length of a vector. Avoids sqrt when only comparing magnitudes.\n */\nexport function vec2LengthSq(v: Vector2D): number {\n\treturn v.x * v.x + v.y * v.y;\n}\n\n/**\n * Compute the length (magnitude) of a vector.\n */\nexport function vec2Length(v: Vector2D): number {\n\treturn Math.sqrt(v.x * v.x + v.y * v.y);\n}\n\n/**\n * Return a unit vector in the same direction. Returns zero vector if input is zero-length.\n */\nexport function vec2Normalize(v: Vector2D): Vector2D {\n\tconst len = Math.sqrt(v.x * v.x + v.y * v.y);\n\tif (len === 0) return { x: 0, y: 0 };\n\treturn { x: v.x / len, y: v.y / len };\n}\n\n/**\n * Compute the squared distance between two points. Avoids sqrt when only comparing.\n */\nexport function vec2DistanceSq(a: Vector2D, b: Vector2D): number {\n\tconst dx = a.x - b.x;\n\tconst dy = a.y - b.y;\n\treturn dx * dx + dy * dy;\n}\n\n/**\n * Compute the distance between two points.\n */\nexport function vec2Distance(a: Vector2D, b: Vector2D): number {\n\tconst dx = a.x - b.x;\n\tconst dy = a.y - b.y;\n\treturn Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * Check if two vectors are approximately equal within an epsilon tolerance.\n */\nexport function vec2Equals(a: Vector2D, b: Vector2D, epsilon = 1e-10): boolean {\n\treturn Math.abs(a.x - b.x) <= epsilon && Math.abs(a.y - b.y) <= epsilon;\n}\n\n// ==================== Vector3D ====================\n\n/**\n * A 3D vector with x, y, and z components.\n */\nexport interface Vector3D {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\n/**\n * Create a Vector3D from x, y, and z components.\n */\nexport function vec3(x: number, y: number, z: number): Vector3D {\n\treturn { x, y, z };\n}\n\n/**\n * Return a zero vector {x: 0, y: 0, z: 0}.\n */\nexport function vec3Zero(): Vector3D {\n\treturn { x: 0, y: 0, z: 0 };\n}\n\n/**\n * Add two vectors component-wise.\n */\nexport function vec3Add(a: Vector3D, b: Vector3D): Vector3D {\n\treturn { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };\n}\n\n/**\n * Subtract b from a component-wise.\n */\nexport function vec3Sub(a: Vector3D, b: Vector3D): Vector3D {\n\treturn { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };\n}\n\n/**\n * Scale a vector by a scalar.\n */\nexport function vec3Scale(v: Vector3D, scalar: number): Vector3D {\n\treturn { x: v.x * scalar, y: v.y * scalar, z: v.z * scalar };\n}\n\n/**\n * Negate a vector (flip all components).\n */\nexport function vec3Negate(v: Vector3D): Vector3D {\n\treturn { x: -v.x, y: -v.y, z: -v.z };\n}\n\n/**\n * Compute the dot product of two vectors.\n */\nexport function vec3Dot(a: Vector3D, b: Vector3D): number {\n\treturn a.x * b.x + a.y * b.y + a.z * b.z;\n}\n\n/**\n * Compute the cross product of two vectors.\n */\nexport function vec3Cross(a: Vector3D, b: Vector3D): Vector3D {\n\treturn {\n\t\tx: a.y * b.z - a.z * b.y,\n\t\ty: a.z * b.x - a.x * b.z,\n\t\tz: a.x * b.y - a.y * b.x,\n\t};\n}\n\n/**\n * Compute the squared length of a vector. Avoids sqrt when only comparing magnitudes.\n */\nexport function vec3LengthSq(v: Vector3D): number {\n\treturn v.x * v.x + v.y * v.y + v.z * v.z;\n}\n\n/**\n * Compute the length (magnitude) of a vector.\n */\nexport function vec3Length(v: Vector3D): number {\n\treturn Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);\n}\n\n/**\n * Return a unit vector in the same direction. Returns zero vector if input is zero-length.\n */\nexport function vec3Normalize(v: Vector3D): Vector3D {\n\tconst len = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);\n\tif (len === 0) return { x: 0, y: 0, z: 0 };\n\treturn { x: v.x / len, y: v.y / len, z: v.z / len };\n}\n\n/**\n * Compute the squared distance between two points. Avoids sqrt when only comparing.\n */\nexport function vec3DistanceSq(a: Vector3D, b: Vector3D): number {\n\tconst dx = a.x - b.x;\n\tconst dy = a.y - b.y;\n\tconst dz = a.z - b.z;\n\treturn dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Compute the distance between two points.\n */\nexport function vec3Distance(a: Vector3D, b: Vector3D): number {\n\tconst dx = a.x - b.x;\n\tconst dy = a.y - b.y;\n\tconst dz = a.z - b.z;\n\treturn Math.sqrt(dx * dx + dy * dy + dz * dz);\n}\n\n/**\n * Check if two vectors are approximately equal within an epsilon tolerance.\n */\nexport function vec3Equals(a: Vector3D, b: Vector3D, epsilon = 1e-10): boolean {\n\treturn Math.abs(a.x - b.x) <= epsilon && Math.abs(a.y - b.y) <= epsilon && Math.abs(a.z - b.z) <= epsilon;\n}\n",
|
|
20
20
|
"import ECSpresso from './ecspresso';\nimport { SystemBuilder, type ProcessContext } from './system-builder';\nimport { type Plugin, type BasePluginOptions, definePlugin } from './plugin';\n\nexport * from './types';\nexport * from './asset-types';\nexport * from './screen-types';\nexport * from './utils/math';\nexport type { ReactiveQueryDefinition } from './reactive-query-manager';\nexport { default as AssetManager, createAssetConfigurator } from './asset-manager';\nexport { default as ScreenManager, createScreenConfigurator } from './screen-manager';\nexport { SystemBuilder, type ProcessContext };\nexport { type Plugin, type BasePluginOptions, definePlugin };\nexport { directValue, type ResourceDirectValue } from './resource-manager';\nexport default ECSpresso;\n"
|
|
21
21
|
],
|
|
22
|
-
"mappings": "4cAMA,MAAqB,CAAiB,CAE7B,UAAiC,IAAI,IAErC,YAAqC,IAAI,IAEzC,UAAsB,CAAC,EAQ/B,SAAS,CAAC,EAAiB,EAAwB,CAClD,GAAI,IAAY,EACf,MAAU,MAAM,qBAAqB,qBAA2B,EAIjE,GAAI,KAAK,iBAAiB,EAAS,CAAQ,EAC1C,MAAU,MAAM,oDAAoD,EAIrE,IAAM,EAAY,KAAK,UAAU,IAAI,CAAO,EAC5C,GAAI,IAAc,OAAW,CAC5B,IAAM,EAAc,KAAK,YAAY,IAAI,CAAS,EAClD,GAAI,EAAa,CAChB,IAAM,EAAM,EAAY,QAAQ,CAAO,EACvC,GAAI,IAAQ,GACX,EAAY,OAAO,EAAK,CAAC,GAM5B,KAAK,UAAU,IAAI,EAAS,CAAQ,EAGpC,IAAM,EAAW,KAAK,YAAY,IAAI,CAAQ,EAC9C,GAAI,EACH,EAAS,KAAK,CAAO,EAErB,UAAK,YAAY,IAAI,EAAU,CAAC,CAAO,CAAC,EAGzC,OAAO,KAQR,YAAY,CAAC,EAA0B,CACtC,IAAM,EAAW,KAAK,UAAU,IAAI,CAAO,EAC3C,GAAI,IAAa,OAChB,MAAO,GAIR,IAAM,EAAW,KAAK,YAAY,IAAI,CAAQ,EAC9C,GAAI,EAAU,CACb,IAAM,EAAM,EAAS,QAAQ,CAAO,EACpC,GAAI,IAAQ,GACX,EAAS,OAAO,EAAK,CAAC,EAKxB,OADA,KAAK,UAAU,OAAO,CAAO,EACtB,GAQR,SAAS,CAAC,EAAiC,CAC1C,OAAO,KAAK,UAAU,IAAI,CAAQ,GAAK,KAQx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aAAgB,CAC9E,OAAO,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,GAAK,GAAW,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,GAAK,GAAW,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,GAAK,EC7NnG,IAAe",
|
|
23
|
+
"debugId": "F5E819A46EFBFBD764756E2164756E21",
|
|
24
24
|
"names": []
|
|
25
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=((j)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(j,{get:(z,J)=>(typeof require<"u"?require:z)[J]}):j)(function(j){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+j+'" is not supported')});import{definePlugin as $}from"ecspresso";var H={Success:0,Failure:1,Running:2};function G(j,z,J){return{type:"action",name:j,tick:z,onAbort:J?.onAbort,nodeIndex:-1}}function P(j,z){return{type:"condition",name:j,check:z,nodeIndex:-1}}function T(j){return{type:"sequence",children:j,nodeIndex:-1}}function B(j){return{type:"selector",children:j,nodeIndex:-1}}function C(j,z){return{type:"parallel",children:j,successThreshold:z?.successThreshold??j.length,failureThreshold:z?.failureThreshold??j.length,nodeIndex:-1}}function m(j){return{type:"inverter",child:j,nodeIndex:-1}}function w(j,z=-1){return{type:"repeat",child:j,count:z,nodeIndex:-1}}function v(j,z){return{type:"cooldown",child:j,duration:z,nodeIndex:-1}}function q(j,z){return{type:"guard",condition:j,child:z,nodeIndex:-1}}var X=new WeakMap,Z=new WeakMap;function A(j,z){let J=0,E=[];function K(M){if(M.nodeIndex=J,E[J]=M,J++,"children"in M)for(let U of M.children)K(U);if("child"in M)K(M.child)}K(z.root);let L=Object.freeze({id:j,root:z.root,nodeCount:J});return X.set(L,E),Z.set(L,z.blackboard),L}function I(j,z){let E={...Z.get(j),...z};return{behaviorTree:{definition:j,blackboard:E,runningNodeIndex:-1,nodeState:new Float64Array(j.nodeCount),elapsedTime:0}}}function g(j,z){let J=j.getComponent(z,"behaviorTree");return J!==void 0&&J.runningNodeIndex!==-1}function p(j,z,J){let E=j.getComponent(z,"behaviorTree");if(!E)return;if(E.runningNodeIndex!==-1){let L=X.get(E.definition)?.[E.runningNodeIndex];if(L&&L.type==="action"&&L.onAbort)L.onAbort({ecs:j,entityId:z,dt:0,blackboard:E.blackboard});E.runningNodeIndex=-1}if(E.nodeState.fill(0),E.elapsedTime=0,J)Object.assign(E.blackboard,J)}function _(j,z){let E=X.get(j.definition)?.[j.runningNodeIndex];if(E&&E.type==="action")E.onAbort?.(z),z.ecs.eventBus.publish("behaviorTreeAbort",{entityId:z.entityId,nodeIndex:j.runningNodeIndex,nodeName:E.name,definitionId:j.definition.id});j.nodeState.fill(0),j.runningNodeIndex=-1}function Q(j,z,J){switch(j.type){case"condition":return j.check(J)?H.Success:H.Failure;case"action":{let E=j.tick(J);if(E===H.Running){if(z.runningNodeIndex!==-1&&z.runningNodeIndex!==j.nodeIndex)_(z,J);z.runningNodeIndex=j.nodeIndex}else if(z.runningNodeIndex===j.nodeIndex)z.runningNodeIndex=-1;return E}case"sequence":{let E=z.runningNodeIndex!==-1?z.nodeState[j.nodeIndex]??0:0;for(let K=E;K<j.children.length;K++){let L=Q(j.children[K],z,J);if(L===H.Failure)return z.nodeState[j.nodeIndex]=0,H.Failure;if(L===H.Running)return z.nodeState[j.nodeIndex]=K,H.Running}return z.nodeState[j.nodeIndex]=0,H.Success}case"selector":{for(let E=0;E<j.children.length;E++){let K=Q(j.children[E],z,J);if(K===H.Success)return H.Success;if(K===H.Running)return H.Running}return H.Failure}case"parallel":{let E=0,K=0,L=!1;for(let M=0;M<j.children.length;M++){let U=Q(j.children[M],z,J);if(U===H.Success)E++;else if(U===H.Failure)K++;else L=!0}if(E>=j.successThreshold)return H.Success;if(K>=j.failureThreshold)return H.Failure;if(L)return H.Running;return H.Failure}case"inverter":{let E=Q(j.child,z,J);if(E===H.Success)return H.Failure;if(E===H.Failure)return H.Success;return H.Running}case"repeat":{let E=z.nodeState[j.nodeIndex]??0,K=Q(j.child,z,J);if(K===H.Failure)return z.nodeState[j.nodeIndex]=0,H.Failure;if(K===H.Running)return H.Running;let L=E+1;if(j.count!==-1&&L>=j.count)return z.nodeState[j.nodeIndex]=0,H.Success;return z.nodeState[j.nodeIndex]=L,H.Running}case"cooldown":{let E=z.nodeState[j.nodeIndex]??0;if(E>0&&z.elapsedTime<E)return H.Failure;let K=Q(j.child,z,J);if(K!==H.Running)z.nodeState[j.nodeIndex]=z.elapsedTime+j.duration;return K}case"guard":{if(!j.condition(J))return H.Failure;return Q(j.child,z,J)}}}function y(j){return{defineBehaviorTree:A,action:G,condition:P,guard:q}}function k(j){let{systemGroup:z="ai",priority:J=0,phase:E="update"}=j??{};return $("behaviorTree").withComponentTypes().withEventTypes().withLabels().withGroups().install((K)=>{K.registerDispose("behaviorTree",({value:L,entityId:M})=>{if(L.runningNodeIndex!==-1){let O=X.get(L.definition)?.[L.runningNodeIndex];if(O&&O.type==="action"&&O.onAbort)O.onAbort({ecs:K,entityId:M,dt:0,blackboard:L.blackboard})}}),K.addSystem("behavior-tree-update").setPriority(J).inPhase(E).inGroup(z).addQuery("trees",{with:["behaviorTree"]}).setProcess(({queries:L,dt:M,ecs:U})=>{let O={ecs:U,entityId:0,dt:0,blackboard:{}};for(let Y of L.trees){let V=Y.components.behaviorTree;if(O.entityId=Y.id,O.dt=M,O.blackboard=V.blackboard,V.elapsedTime+=M,Q(V.definition.root,V,O)!==H.Running&&V.runningNodeIndex!==-1)_(V,O)}})})}export{T as sequence,B as selector,p as resetBehaviorTree,w as repeat,C as parallel,g as isBehaviorTreeRunning,m as inverter,q as guard,A as defineBehaviorTree,k as createBehaviorTreePlugin,y as createBehaviorTreeHelpers,I as createBehaviorTree,v as cooldown,P as condition,G as action,H as NodeStatus};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=71DF25393349415964756E2164756E21
|
|
4
4
|
//# sourceMappingURL=behavior-tree.js.map
|