ecsjs 1.3.0 → 1.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/ecs.js +1 -1
- package/dist/ecs.js.map +3 -3
- package/dist/types/src/component-classes.d.ts.map +1 -1
- package/dist/types/src/component-map.d.ts.map +1 -1
- package/dist/types/src/entity-map.d.ts +21 -2
- package/dist/types/src/entity-map.d.ts.map +1 -1
- package/dist/types/src/iterator.d.ts +0 -1
- package/dist/types/src/iterator.d.ts.map +1 -1
- package/dist/types/src/query.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +0 -7
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/component-classes.ts +0 -1
- package/src/component-map.ts +2 -4
- package/src/entity-map.ts +29 -3
- package/src/iterator.ts +0 -1
- package/src/query.ts +1 -1
- package/src/types.ts +0 -7
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ An entity component system library for JavaScript
|
|
|
21
21
|
|
|
22
22
|
- [Classic Asteroids](https://gitlab.com/ecsjs/example-astroids)
|
|
23
23
|
- [Classic Kung Fu](https://gitlab.com/ecsjs/example-kungfu)
|
|
24
|
+
- [1943](https://gitlab.com/ecsjs/example-1943)
|
|
24
25
|
- [Misc Examples](https://gitlab.com/ecsjs/ecs-examples)
|
|
25
26
|
|
|
26
27
|
#### Browser
|
package/dist/ecs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l="ComponentMap",y="ComponentClassesMap";function T(o){let e=0;for(let t=0;t<o.length;t++){let n=o.charCodeAt(t);e=(e<<5)-e+n,e|=0}return e}var p=class{hashIdToName=new Map;hashIdToIndex=new Map;indexToHashId=[];maps=[];constructor(e){if(e)for(let t=0;t<e.length;t++){let n=e[t];this.setByHashId(n[0],n[1])}}get size(){return this.maps.length}clear(){this.maps.length=0,this.indexToHashId.length=0,this.hashIdToIndex.clear()}get(e){let t=this.hashIdToIndex.get(e.hashId);return t!==void 0?this.maps[t]:void 0}set(e,t){return e.hashId===void 0&&(e.hashId=T(e.name)),this.hashIdToName.set(e.hashId,e.name),this.setByHashId(e.hashId,t)}setByHashId(e,t){let n=this.hashIdToIndex.get(e);return n!==void 0?this.maps[n]=t:(this.hashIdToIndex.set(e,this.maps.length),this.indexToHashId.push(e),this.maps.push(t)),this}delete(e){let t=e.hashId,n=this.hashIdToIndex.get(t);if(n===void 0)return!1;let s=this.maps.length-1,r=this.indexToHashId[s];return this.maps[n]=this.maps[s],this.indexToHashId[n]=r,this.hashIdToIndex.set(r,n),this.maps.pop(),this.indexToHashId.pop(),this.hashIdToIndex.delete(t),!0}forEach(e){for(let t=0;t<this.maps.length;t++)e(this.maps[t],this.hashIdToName.get(this.indexToHashId[t]))}values(){return this.maps.values()}entries(){let e=0,t=this.maps,n=this.indexToHashId;return{next(){if(e<t.length){let s=[n[e],t[e]];return e++,{value:s,done:!1}}return{value:void 0,done:!0}},reset(){e=0},[Symbol.iterator](){return this}}}toJSON(){return{[y]:1,iterable:[...this.entries()]}}};var m=class{indices=[];entities=[];instances=[];constructor(e){if(e)for(let t=0;t<e.length;t++){let n=e[t];this.set(n[0],n[1])}}get size(){return this.instances.length}clear(){this.indices=[],this.entities.length=0,this.instances.length=0}set(e,t){if(this.has(e)){this.instances[this.indices[e]]=t;return}this.indices[e]=this.instances.length,this.entities.push(e),this.instances.push(t)}get(e){let t=this.indices[e];return t!==void 0&&this.entities[t]===e?this.instances[t]:void 0}delete(e){let t=this.indices[e];if(t===void 0||t===-1||this.entities[t]!==e)return!1;let n=this.instances.length-1,s=this.entities[n];return this.instances[t]=this.instances[n],this.entities[t]=s,this.indices[s]=t,this.instances.pop(),this.entities.pop(),this.indices[e]=-1,!0}has(e){let t=this.indices[e];return t!==void 0&&t!==-1&&this.entities[t]===e}forEach(e){for(let t=0;t<this.instances.length;t++)e(this.instances[t],this.entities[t])}firstEntry(){return this.entities.length===0?void 0:[this.entities[0],this.instances[0]]}firstKey(){return this.entities.length===0?void 0:this.entities[0]}firstValue(){return this.instances.length===0?void 0:this.instances[0]}[Symbol.iterator](){return this.entries()}keys(){return this.entities.values()}values(){return this.instances.values()}entries(){let e=0,t=this.entities,n=this.instances;return{next(){if(e<n.length){let s={value:[t[e],n[e]],done:!1};return e++,s}return{value:void 0,done:!0}},reset(){e=0},[Symbol.iterator](){return this}}}toJSON(){return{[l]:1,iterable:[...this.entries()]}}toTable(){let e=[];for(let[t,n]of this.entries()){let s=n,r={};r["entity.key"]=t,r["entity.type"]=s.constructor.name,e.push({...r,...s})}return e}printTable(e=[]){console.table(this.toTable(),e)}};var c=class extends Error{constructor(){super("Component type is missing the 'name' parameter. i.e. a constructor name")}},i=class extends Error{constructor(t){super(`Component map does not exist for '${t}'`);this.componentName=t}};var a=class{keyMap;componentMaps=[];entries;constructor(e){this.keyMap=e.keyMap,this.componentMaps=e.componentMaps,this.entries=this.keyMap.entries()}next(){let e=this.entries.next(),{value:t,done:n}=e;if(n)return{value:t,done:n};let s=t[0];for(let r=0;r<this.componentMaps.length;r++){let h=this.componentMaps[r];t.push(h.get(s))}return{value:t,done:!1}}reset(){this.entries=this.keyMap.entries()}[Symbol.iterator](){return this}};var u=class{constructor(e,...t){this.ecs=e;this.keyMap=this.ecs.getMap(t[0]);for(let n=1;n<t.length;n++)this.componentMaps.push(this.ecs.getMap(t[n]))}keyMap;componentMaps=[];firstEntry(){if(this.componentMaps.length===0)return this.keyMap.firstEntry();let[e,t]=this.keyMap.firstEntry()??[];if(e===void 0)return;let n=[e,t];for(let s=0;s<this.componentMaps.length;s++)n.push(this.componentMaps[s].get(e));return n}firstKey(){let e=this.keyMap.firstKey();if(this.componentMaps.length===0)return e;if(e===void 0)return;let t=[e];for(let n=0;n<this.componentMaps.length;n++)t.push(this.componentMaps[n].get(e));return t}firstValue(){if(this.componentMaps.length===0)return this.keyMap.firstValue();let[e,t]=this.keyMap.firstEntry()??[];if(e===void 0)return;let n=[t];for(let s=0;s<this.componentMaps.length;s++)n.push(this.componentMaps[s].get(e));return n}get entityCount(){return this.keyMap.size}destroyEntities(){return this.ecs.destroyEntity(...this.keyMap.keys())}keys(){return this.keyMap.keys()}values(){let e=this.keyMap,t=this.componentMaps,n=e.keys();return{next(){let s=n.next();if(s.done)return{value:void 0,done:!0};let r=s.value,C=[e.get(r)];for(let f=0;f<t.length;f++){let I=t[f];C.push(I.get(r))}return{value:C,done:!1}},reset(){n=e.keys()},[Symbol.iterator](){return this}}}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new a(this)}};var d=class o{components=new p;nextId=0;register(...e){for(let t of e){if(t.name===void 0)throw new c;this.components.set(t,new m)}return this}getMap(e){let t=this.components.get(e);if(t===void 0)throw new i(e.name);return t}first(e){return this.firstEntity(e)}firstEntity(e){let t=this.getMap(e)?.firstKey();if(t!==void 0)return this.get(t)}entityValues(e){let t=this.getMap(e)?.keys();if(t!==void 0)return[...t.map(n=>this.get(n))]}firstEntry(e,...t){return t.length===0?this.getMap(e)?.firstEntry():this.firstKey(e,e,...t)}firstKey(e,...t){let n=this.getMap(e)?.firstKey();if(arguments.length===1)return n;if(n!==void 0)return[n,...t.map(s=>this.getEntity(n,s))]}firstValue(e,...t){if(arguments.length===1)return this.getMap(e)?.firstValue();let[n,s]=this.getMap(e)?.firstEntry()??[];if(n!==void 0)return[s,...t.map(r=>this.getEntity(n,r))]}getEntity(e,t){let n=this.components.get(t);if(n===void 0)throw new i(t.name);return n.get(e)}get(e,...t){return t.length===1?this.getEntity(e,t[0]):t.length>1?t.map(n=>this.getEntity(e,n)):[...this.components.values()].filter(n=>n.has(e)).map(n=>n.get(e))}has(e,t){let n=this.components.get(t);return n===void 0?!1:n.has(e)}hasAll(e,...t){for(let n=0;n<t.length;n++){let s=t[n],r=this.components.get(s);if(r===void 0||r.has(e)===!1)return!1}return!0}hasAny(e,...t){for(let n=0;n<t.length;n++){let s=t[n],r=this.components.get(s);if(r!==void 0&&r.has(e))return!0}return!1}setEntity(e,t){let n=this.components.get(t.constructor);if(n===void 0)throw new i(t.constructor.name);return n.set(e,t),t}set(e,...t){return t.length>1?t.map(n=>this.setEntity(e,n)):this.setEntity(e,t[0])}remove(e,...t){for(let n of t)this.removeByKey(e,n)}removeByKey(e,t){let n=this.components.get(t);if(n===void 0)throw new i(t.name);return n.get(e)===void 0?!1:n.delete(e)}destroyEntity(...e){let t=0;for(let n=0;n<e.length;n++){let s=e[n];for(let r of this.components.values())r.has(s)&&(r.delete(s),t++)}return t}getNextId(){return this.nextId++,this.nextId}clear(){return this.components.clear(),this.nextId=0,this}clearComponents(){return this.components.forEach(e=>e.clear()),this.nextId=0,this}iterator(e,...t){return new a(new u(this,e,...t))}query(e,...t){return new u(this,e,...t)}printTable(){let e=arguments[0]??[],t=arguments[1]??[];return this.components.forEach((n,s)=>{(e.length===0||e.includes(s))&&console.table(n.toTable(),t)}),this}printEntity(e,t=[]){for(let n of this.components.values()){if(n.has(e)===!1)continue;let s=n.get(e),r={"entity.type":s.constructor.name,...s};console.table({[e]:r},t)}return this}static parse(e){return JSON.parse(e,function(n,s){return s.hasOwnProperty("components")?(Reflect.setPrototypeOf(s,o.prototype),s):s.hasOwnProperty(l)?new m(s.iterable):s.hasOwnProperty(y)?new p(s.iterable):this[n]})}static createWithTracing(e){let t={get(n,s){let r=n[s];return typeof r=="function"&&(e.length===0||e.includes(s))?function(...h){return console.groupCollapsed("ecs trace",s,h),console.trace(),console.groupEnd(),r.apply(this,h)}:r}};return new Proxy(new o,t)}};var g=new d;typeof window<"u"?window.ecs=g:typeof module<"u"&&module!==null&&(module.exports={ecs:g});export{p as ComponentClassesMap,a as ComponentIterator,m as ComponentMap,u as ComponentQuery,d as EntityMap,g as ecs};
|
|
2
2
|
//# sourceMappingURL=ecs.js.map
|
package/dist/ecs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.ts", "../src/utils.ts", "../src/component-classes.ts", "../src/component-map.ts", "../src/errors.ts", "../src/iterator.ts", "../src/query.ts", "../src/entity-map.ts", "../src/ecs.ts"],
|
|
4
|
-
"sourcesContent": ["export const ComponentMapKey = \"ComponentMap\"\nexport const ComponentClassesMapKey = \"ComponentClassesMap\"\n\nexport type KeyCollection<T> = { [key: string]: T }\n\nexport interface Component { }\n\n/**\n * @category Types\n * @example\n * \n * class PositionComponent {\n * constructor(x, y) {\n * this.x = x;\n * this.y = y;\n * }\n * }\n */\nexport type ComponentClass<ComponentInstance> = (new (...args: any[]) => ComponentInstance) & {\n // static property\n hashId?: number;\n};\n\n/**\n* Used for infering generic type spread for classes\n*/\nexport type ComponentClasses<T extends Component[]> =\n { [Index in keyof T]: ComponentClass<T[Index]> }\n\nexport type SingleOrArray<T extends any[]> =\n // return a single variadic item when only 1 item is specified\n T['length'] extends 1 ? T[0]\n // otherwise return an array of variadic types\n : { [Index in keyof T]: T[Index] }\n\nexport type IteratorResult<T> = {\n done: boolean,\n value: T\n}\n\nexport type Iterator<T> = {\n next: () => IteratorResult<T>\n reset: () => void\n [Symbol.iterator]: () => Iterator<T>\n}\n\n/**\n * allow late bound assignment type for intellisense\n * @category Types\n * @example\n * \n * let someIterator: IComponentIterator<[Player, Position]>\n * \n * // assignment made somewhere else in the code\n * const [player, position] = someIterator(Player, Position) ?? []\n * position?.x = 123 // position will have intellisense\n */\nexport type IComponentIterator<T extends Component[]>\n = Iterator<ComponentClasses<[number, ...T]>>", "export function hashString(str: string) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash |= 0; // Convert to 32bit\n }\n return hash;\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type { ComponentMap } from './component-map.js';\nimport {\n ComponentClassesMapKey,\n type ComponentClass,\n type Iterator,\n type IteratorResult\n} from './types.js';\nimport { hashString } from './utils.js';\n\n/**\n * Component class map for storing registered component maps\n * @category Maps\n */\nexport class ComponentClassesMap {\n\n private hashIdToName: Map<number, string> = new Map<number, string>()\n private hashIdToIndex = new Map<number, number>();\n private indexToHashId: number[] = [];\n private maps: ComponentMap<any>[] = [];\n\n constructor(entries?: readonly (readonly [number, ComponentMap<any>])[] | null) {\n if (entries) {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n this.setByHashId(entry[0], entry[1]);\n }\n }\n }\n\n /**\n * The number of registered component maps\n */\n get size() {\n return this.maps.length;\n }\n\n /**\n * Clears all maps and internal indices while preserving array references\n */\n clear(): void {\n this.maps.length = 0;\n this.indexToHashId.length = 0;\n this.hashIdToIndex.clear();\n }\n\n /**\n * Retrieves a component map using the static hashId of a component class\n */\n get<T>(componentClass: ComponentClass<T>): ComponentMap<T> | undefined {\n const index = this.hashIdToIndex.get(componentClass.hashId!);\n return index !== undefined ? this.maps[index] : undefined;\n }\n\n /**\n * Registers a component map. Automatically generates a hashId from the class name if missing\n */\n set<T>(componentClass: ComponentClass<T>, map: ComponentMap<T>): this {\n if (componentClass.hashId === undefined) {\n componentClass.hashId = hashString(componentClass.name);\n }\n\n this.hashIdToName.set(componentClass.hashId, componentClass.name);\n return this.setByHashId(componentClass.hashId!, map);\n }\n\n /**\n * Maps a specific numeric hash id to a component map instance.\n */\n setByHashId(hash: number, map: ComponentMap<any>): this {\n const existingIndex = this.hashIdToIndex.get(hash);\n\n if (existingIndex !== undefined) {\n this.maps[existingIndex] = map;\n } else {\n this.hashIdToIndex.set(hash, this.maps.length);\n this.indexToHashId.push(hash);\n this.maps.push(map);\n }\n\n return this;\n }\n\n /**\n * Removes a component map and re-orders internal storage to maintain density\n */\n delete(componentClass: ComponentClass<any>): boolean {\n const hashId = componentClass.hashId!;\n const index = this.hashIdToIndex.get(hashId);\n if (index === undefined) return false;\n\n const lastIndex = this.maps.length - 1;\n const lastHash = this.indexToHashId[lastIndex];\n\n // Swap\n this.maps[index] = this.maps[lastIndex];\n this.indexToHashId[index] = lastHash;\n\n // Update map pointer\n this.hashIdToIndex.set(lastHash, index);\n\n // Pop\n this.maps.pop();\n this.indexToHashId.pop();\n this.hashIdToIndex.delete(hashId);\n return true;\n }\n\n /**\n * Executes a callback for every map, providing the instance and its registered name\n */\n forEach(callback: (value: ComponentMap<any>, name: string) => void) {\n for (let i = 0; i < this.maps.length; i++) {\n callback(this.maps[i], this.hashIdToName.get(this.indexToHashId[i])!);\n }\n }\n\n /**\n * Returns an iterator of all component map instances \n */\n values(): ArrayIterator<ComponentMap<any>> { return this.maps.values() }\n\n /**\n * Returns an iterator of [hashId, componentMap] pairs\n */\n entries(): Iterator<[number, ComponentMap<any>]> {\n let index = 0;\n const instances = this.maps;\n const hashes = this.indexToHashId;\n\n return {\n next(): IteratorResult<[number, ComponentMap<any>]> {\n if (index < instances.length) {\n const value: [number, ComponentMap<any>] = [hashes[index], instances[index]];\n index++;\n return { value, done: false };\n }\n return { value: undefined as any, done: true };\n },\n reset() { index = 0; },\n [Symbol.iterator]() { return this; }\n };\n }\n\n /**\n * Called when using JSON.stringify\n */\n toJSON() {\n return { [ComponentClassesMapKey]: 1, iterable: [...this.entries()] };\n }\n\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n ComponentMapKey,\n type Iterator,\n type IteratorResult,\n type KeyCollection\n} from './types.js';\n\n/**\n * Component map for storing entity ids and related component data\n * @category Maps\n */\nexport class ComponentMap<TComponentInstance> implements Iterable<[number, TComponentInstance]> {\n\n private indices: number[] = [];\n\n private entities: number[] = [];\n\n private instances: TComponentInstance[] = [];\n\n constructor(entries?: readonly (readonly [number, TComponentInstance])[] | null) {\n if (entries) {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n this.set(entry[0], entry[1]);\n }\n }\n }\n\n get size() {\n return this.instances.length;\n }\n\n clear() {\n this.indices = [];\n this.entities.length = 0;\n this.instances.length = 0;\n }\n\n set(entityId: number, component: TComponentInstance) {\n if (this.has(entityId)) {\n this.instances[this.indices[entityId]] = component;\n return;\n }\n this.indices[entityId] = this.instances.length;\n this.entities.push(entityId);\n this.instances.push(component);\n }\n\n get(entityId: number) {\n const index = this.indices[entityId];\n return index !== undefined && this.entities[index] === entityId\n ? this.instances[index]\n : undefined;\n }\n\n delete(entityId: number) {\n const index = this.indices[entityId];\n if (index === undefined || index === -1 || this.entities[index] !== entityId) return false;\n\n // swap and pop with last element to keep dense\n const lastIdx = this.instances.length - 1;\n const lastEntity = this.entities[lastIdx];\n this.instances[index] = this.instances[lastIdx];\n this.entities[index] = lastEntity;\n this.indices[lastEntity] = index;\n this.instances.pop();\n this.entities.pop();\n\n // invalidate index\n this.indices[entityId] = -1;\n\n return true;\n }\n\n has(entityId: number) {\n const index = this.indices[entityId];\n return index !== undefined && index !== -1 && this.entities[index] === entityId;\n }\n\n /**\n * Executes a callback for every map, providing the instance and its entity id\n */\n forEach(callback: (value: TComponentInstance, key: number) => void) {\n for (let i = 0; i < this.instances.length; i++) {\n callback(this.instances[i], this.entities[i]);\n }\n }\n\n /**\n * Returns the first entity entry\n */\n firstEntry(): [entityId: number, value: TComponentInstance] | undefined {\n return this.entities.length === 0\n ? undefined\n : [this.entities[0], this.instances[0]];\n }\n\n /**\n * Returns the first entity id\n */\n firstKey(): number | undefined {\n return this.entities.length === 0\n ? undefined\n : this.entities[0];\n }\n\n /**\n * Returns the first entity value\n */\n firstValue(): TComponentInstance | undefined {\n return this.instances.length === 0\n ? undefined\n : this.instances[0];\n }\n\n [Symbol.iterator](): Iterator<[number, TComponentInstance]> {\n return this.entries();\n }\n\n /**\n * Returns an iterator of all entity ids \n */\n keys(): ArrayIterator<number> {\n return this.entities.values();\n }\n\n /**\n * Returns an iterator of all component instances \n */\n values(): ArrayIterator<TComponentInstance> {\n return this.instances.values();\n }\n\n /**\n * Returns an iterator of [entityId, componentInstance] pairs\n */\n entries(): Iterator<[number, TComponentInstance]> {\n let index = 0;\n const entities = this.entities;\n const instances = this.instances;\n\n return {\n next(): IteratorResult<[number, TComponentInstance]> {\n if (index < instances.length) {\n const result: IteratorResult<[number, TComponentInstance]> = {\n value: [entities[index], instances[index]],\n done: false\n };\n index++;\n return result;\n }\n return { value: <any>undefined, done: true };\n },\n reset() {\n index = 0;\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n }\n\n /**\n * Called when using JSON.stringify\n */\n toJSON() {\n return { [ComponentMapKey]: 1, iterable: [...this.entries()] };\n }\n\n toTable(): any[] {\n const table = []\n for (const [key, value] of this.entries()) {\n const entity = value as { new(): TComponentInstance };\n const meta: KeyCollection<any> = {};\n meta[\"entity.key\"] = key;\n meta[\"entity.type\"] = entity.constructor.name;\n table.push({ ...meta, ...entity });\n }\n return table;\n }\n\n /**\n * Prints entity data in a tabular format to the console\n */\n printTable(properties: string[] = []): void {\n console.table(this.toTable(), properties);\n }\n\n}", "/**\n * Thrown when trying to register a component that is missing a 'name' parameter\n * @category Errors\n */\nexport class ComponentTypeKeyMissing extends Error {\n constructor() {\n super(`Component type is missing the 'name' parameter. i.e. a constructor name`);\n }\n}\n\n/**\n * Thrown when trying to access a component that has not been registered\n * @category Errors\n */\nexport class ComponentNotRegistered extends Error {\n constructor(public componentName: string) {\n super(`Component map does not exist for '${componentName}'`);\n }\n}", "import type { ComponentMap } from './component-map.js';\nimport type { ComponentQuery } from './query.js';\nimport type { IteratorResult } from './types.js';\n\n/**\n * @category Iterators\n * @example\n * // construct an instance\n * const iterator = new ComponentIterator(new ComponentQuery(entityMap, Player, Position))\n * \n * // iterate each component value that is related to the Player\n * for(const [entityId, player, position] of iterator) { }\n * \n * // you can also reset the iterator back to the start\n * // without having to create a new ComponentIterator instance\n * iterator.reset()\n * for(const [entityId, player, position] of iterator) { }\n */\nexport class ComponentIterator<TKey, TRelated extends any[]> {\n private keyMap: ComponentMap<TKey>;\n private componentMaps: ComponentMap<any>[] = [];\n // iteration state\n private entries: Iterator<[number, TKey]>;\n\n constructor(query: ComponentQuery<TKey, TRelated>) {\n // @ts-ignore internal private var accessor\n this.keyMap = query.keyMap\n // @ts-ignore internal private var accessor\n this.componentMaps = query.componentMaps\n this.entries = this.keyMap.entries();\n }\n\n /**\n * gets the next iterator value\n */\n next(): IteratorResult<[number, TKey, ...TRelated]> {\n const entry = this.entries.next();\n const { value, done } = entry;\n if (done) return { value, done };\n\n const entityId = value[0];\n\n // append the related components\n for (let i = 0; i < this.componentMaps.length; i++) {\n const map = this.componentMaps[i];\n value.push(map.get(entityId));\n }\n\n return { value: value as any, done: false };\n }\n\n /**\n * resets the iterator back to the first entry\n */\n reset() {\n this.entries = this.keyMap.entries();\n }\n\n [Symbol.iterator]() { return this; }\n\n}", "import type { ComponentMap } from './component-map.js';\nimport type { EntityMap } from './entity-map.js';\nimport { ComponentIterator } from './iterator.js';\nimport type { ComponentClass, ComponentClasses, Iterator, IteratorResult, SingleOrArray } from './types.js';\n\n/**\n * @category Queries\n * @example\n * const query = ecs.query(Player, Position)\n * \n * // get the first entry\n * const [playerId, player, position] = query.firstEntry() ?? []\n * \n * // get the first key\n * const [playerId, position] = query.firstKey() ?? []\n * \n * // get the first value\n * const [player, position] = query.firstValue() ?? []\n * \n * // iterate\n * for (const [playerId, player, position] of query) {\n * \n * }\n */\nexport class ComponentQuery<TKey, TRelated extends any[]> {\n private keyMap: ComponentMap<TKey>\n private componentMaps: ComponentMap<any>[] = []\n\n /**\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n */\n constructor(\n public ecs: EntityMap,\n ...components: [ComponentClass<TKey>, ...ComponentClasses<TRelated>]\n ) {\n this.keyMap = this.ecs.getMap(components[0])!;\n for (let i = 1; i < components.length; i++) {\n this.componentMaps.push(this.ecs.getMap(components[i])!)\n }\n }\n\n /**\n * Returns the first entity entry\n * \n * Optionally returns related components specified in the query constructor\n */\n firstEntry(): [number, TKey, ...TRelated] | undefined;\n firstEntry() {\n if (this.componentMaps.length === 0) return this.keyMap.firstEntry()\n\n const [entityId, entryValue] = this.keyMap.firstEntry() ?? []\n if (entityId === undefined) return undefined;\n\n const results: any[] = [entityId, entryValue]\n for (let i = 0; i < this.componentMaps.length; i++) {\n results.push(this.componentMaps[i].get(entityId));\n }\n\n return results\n }\n\n /**\n * Returns the first entity id\n * \n * Optionally returns related components specified in the query constructor\n */\n firstKey(): SingleOrArray<[number, ...TRelated]> | undefined;\n firstKey() {\n const entityId = this.keyMap.firstKey()\n if (this.componentMaps.length === 0) return entityId;\n if (entityId === undefined) return undefined;\n\n const results: any[] = [entityId]\n for (let i = 0; i < this.componentMaps.length; i++) {\n results.push(this.componentMaps[i].get(entityId));\n }\n\n return results\n }\n\n /**\n * Returns the first value\n * \n * Optionally returns related components specified in the query constructor\n */\n firstValue(): SingleOrArray<[TKey, ...TRelated]> | undefined;\n firstValue() {\n if (this.componentMaps.length === 0) return this.keyMap.firstValue()\n\n const [entityId, keyValue] = this.keyMap.firstEntry() ?? []\n if (entityId === undefined) return undefined;\n\n const results = [keyValue]\n for (let i = 0; i < this.componentMaps.length; i++) {\n results.push(this.componentMaps[i].get(entityId));\n }\n\n return results\n }\n\n /**\n * Returns the count of entities in the query\n */\n get entityCount() {\n return this.keyMap.size\n }\n\n /**\n * Destroys all entities in the query\n * \n * Returns the destroyed count\n * @example\n * const destroyedCount = query.destroyEntities()\n */\n destroyEntities(): number {\n return this.ecs.destroyEntity(...this.keyMap.keys())\n }\n\n /**\n * Returns an iterator of all the entityIds\n */\n keys(): ArrayIterator<number> { return this.keyMap.keys() }\n\n /**\n * Returns an iterator of all ComponentMap instances stored in this container\n */\n values(): Iterator<[TKey, ...TRelated]> {\n const keyMap = this.keyMap;\n const componentMaps = this.componentMaps;\n let keysIterator = keyMap.keys();\n\n return {\n next(): IteratorResult<[TKey, ...TRelated]> {\n const key = keysIterator.next();\n if (key.done) return { value: <any>undefined, done: true };\n\n const entityId = key.value;\n const keyComponent = keyMap.get(entityId);\n\n // append the related components\n const value = [keyComponent];\n for (let i = 0; i < componentMaps.length; i++) {\n const map = componentMaps[i];\n value.push(map.get(entityId));\n }\n\n return { value: value as any, done: false };\n },\n reset() { keysIterator = keyMap.keys(); },\n [Symbol.iterator]() { return this; },\n };\n }\n\n /**\n * Returns an iterator that flattens all internal maps into [entityId, KeyComponent, ...RelatedComponents]\n */\n entries() { return this[Symbol.iterator](); }\n\n /**\n * Returns an iterator that flattens all internal maps into [entityId, KeyComponent, ...RelatedComponents]\n */\n [Symbol.iterator]() {\n return new ComponentIterator(this);\n }\n\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { ComponentClassesMap } from './component-classes.js';\nimport { ComponentMap } from './component-map.js';\nimport { ComponentNotRegistered, ComponentTypeKeyMissing } from './errors.js';\nimport { ComponentIterator } from './iterator.js';\nimport { ComponentQuery } from './query.js';\nimport {\n ComponentClassesMapKey,\n ComponentMapKey,\n type Component,\n type ComponentClass,\n type ComponentClasses,\n type SingleOrArray\n} from './types.js';\n\n/**\n * Class for storing entities and their relationships\n * @category Maps\n */\nexport class EntityMap {\n /**\n * Registered component classes that contain the component instance data\n */\n public components = new ComponentClassesMap()\n\n private nextId: number = 0\n\n /**\n * Registers component classes with the {@link EntityMap}\n * @throwsError {@link ComponentTypeKeyMissing} when the specified component type is missing a 'name' parameter\n * @example\n * // component class\n * class MyComponent {\n * constructor(x) {\n * this.x = x;\n * }\n * }\n *\n * ecs.register(MyComponent);\n * // or mulitple\n * ecs.register(MyComponent1, MyComponent2);\n */\n register<TComponentClasses extends ComponentClass<any>[]>(...componentClasses: TComponentClasses) {\n for (const componentClass of componentClasses) {\n const componentName = componentClass.name;\n if (componentName === undefined) throw new ComponentTypeKeyMissing();\n\n // create the component map\n // const componentDataMap: ComponentMap<any> = new ComponentMap();\n this.components.set(componentClass, new ComponentMap());\n }\n\n // chain\n return this;\n }\n\n /**\n * Gets a component class map\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * const positionMap = ecs.getMap(Position)\n * for(const [entityId, position] of positionMap) {\n * position.x += 1\n * }\n */\n getMap<T>(component: ComponentClass<T>): ComponentMap<T> | undefined {\n const map = this.components.get(component);\n if (map === undefined) throw new ComponentNotRegistered(component.name)\n return map\n }\n\n /**\n * Returns all components for the first entity by component\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * // return the first entity\n * const playerEntity = ecs.first(Player) ?? []\n * )\n */\n first(keyComponent: ComponentClass<any>): Component[] | undefined {\n const entityId = this.getMap(keyComponent)?.firstKey();\n if (entityId === undefined) return undefined;\n\n return this.get(entityId);\n }\n\n /**\n * Gets the first entity entry for a component class\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * // return the first entry\n * const [entityId, player] = ecs.firstEntry(Player) ?? []\n * \n * // or return multiple related components in addition to the first entry\n * const [entityId, player, position, direction] = ecs.firstEntry(\n * Player,\n * Position,\n * Direction\n * )\n */\n firstEntry<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ): [number, TKey, ...TRelated] | undefined;\n firstEntry(keyComponent: ComponentClass<any>, ...components: ComponentClass<any>[]) {\n if (components.length === 0) return this.getMap(keyComponent)?.firstEntry()\n\n return this.firstKey(keyComponent, keyComponent, ...components);\n }\n\n /**\n * Gets the first entity id for a component class \n * and optionally any related component data\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // return the first entity id\n * const entityId = ecs.firstKey(Player)\n * \n * // or return multiple related component in addition to entity id\n * const [entityId, position, direction] = ecs.firstKey(\n * Player,\n * Position,\n * Direction\n * ) ?? []\n */\n firstKey<TKey, TRelated extends any[]>(\n keyComponent: TKey,\n ...components: ComponentClasses<TRelated>\n ): SingleOrArray<[number, ...TRelated]> | undefined;\n firstKey(keyComponent: ComponentClass<any>, ...components: ComponentClass<any>[]) {\n const entityId = this.getMap(keyComponent)?.firstKey();\n\n // single component key\n if (arguments.length === 1) return entityId;\n if (entityId === undefined) return undefined;\n\n // attach related component values\n return [entityId, ...components.map(x => this.getEntity(entityId, x))];\n }\n\n /**\n * Gets the first entity component data for a component class\n * and optionally any related component data\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // return the first component value\n * const player = ecs.firstValue(Player)\n * \n * // or multiple related values in addition to the first component\n * const [player, position, direction] = ecs.firstValue(\n * Player,\n * Position,\n * Direction\n * )\n */\n firstValue<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ): SingleOrArray<[TKey, ...TRelated]> | undefined;\n firstValue(keyComponent: ComponentClass<any>, ...components: ComponentClass<any>[]) {\n // single component\n if (arguments.length === 1) return this.getMap(keyComponent)?.firstValue();\n\n // get the first entry\n const [entityId, keyValue] = this.getMap(keyComponent)?.firstEntry() ?? [];\n if (entityId === undefined) return undefined;\n\n // attach related components\n return [keyValue, ...components.map(x => this.getEntity(entityId, x))]\n }\n\n /**\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered \n */\n private getEntity<T>(entityId: number, component: ComponentClass<T>): T | undefined {\n const map = this.components.get(component);\n if (map === undefined) throw new ComponentNotRegistered(component.name)\n\n return map.get(entityId);\n }\n\n /**\n * Gets component values related to an entity id\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // get one by id\n * const player = ecs.get(entityId, Player)\n * \n * // get multiple by id\n * const [player, position] = ecs.get(entityId, Player, Position) ?? []\n * \n * // get all by id\n * const playerEntity = ecs.get(entityId) ?? []\n */\n get(entityId: number): Component[] | undefined;\n get<T>(entityId: number, component: ComponentClass<T>): T | undefined;\n get<T extends any[]>(entityId: number, ...components: ComponentClasses<T>): SingleOrArray<T> | undefined;\n get(entityId: number, ...components: ComponentClasses<any>): Component | Component[] | undefined {\n // return a single component\n if (components.length === 1) return this.getEntity(entityId, components[0]);\n // return filtered components\n if (components.length > 1) return components.map(x => this.getEntity(entityId, x));\n // return all components\n return [...this.components.values()]\n .filter(v => v.has(entityId))\n .map(v => v.get(entityId));\n }\n\n /**\n * Check if a component exists for an entity\n * @example\n * const exists = ecs.has(entityId, Position)\n */\n has<T>(entityId: number, component: ComponentClass<T>): boolean {\n // get the component map\n const map = this.components.get(component);\n if (map === undefined) return false\n\n return map.has(entityId);\n }\n\n /**\n * Checks if all of the specified components exist for an entity\n * @example\n * const hasAll = ecs.hasAll(entityId, Position, Velocity)\n */\n hasAll<T extends ComponentClass<any>[]>(entityId: number, ...components: T): boolean {\n for (let index = 0; index < components.length; index++) {\n const component = components[index];\n const map = this.components.get(component);\n if (map === undefined) return false;\n if (map.has(entityId) === false) return false;\n }\n return true\n }\n\n /**\n * Checks if any of the specified components exist for an entity\n * @example\n * const hasAny = ecs.hasAny(entityId, Position, Velocity)\n */\n hasAny<T extends ComponentClass<any>[]>(entityId: number, ...components: T): boolean {\n for (let index = 0; index < components.length; index++) {\n const component = components[index];\n const map = this.components.get(component);\n if (map === undefined) continue;\n if (map.has(entityId)) return true;\n }\n return false\n }\n\n private setEntity<T extends Component>(entityId: number, componentData: T): T {\n // get the component map\n const map = this.components.get((<ComponentClass<any>>componentData.constructor));\n if (map === undefined) throw new ComponentNotRegistered(componentData.constructor.name)\n\n // set the entity on the entity map\n map.set(entityId, componentData);\n\n // return instance\n return componentData;\n }\n\n /**\n * Add or update multiple component values for an entity\n * @example\n * // set one\n * const player = ecs.set(entityId, new Player());\n * \n * // or set multiple\n * const [player, position] = ecs.set(\n * entityId,\n * new Player(),\n * new Position()\n * );\n */\n set<T extends Component>(entityId: number, component: T): T;\n set<T extends Component[]>(entityId: number, ...components: T): T;\n set(entityId: number, ...components: Component[]): Component | Component[] {\n if (components.length > 1) return components.map(x => this.setEntity(entityId, x))\n\n // set and return a single component\n return this.setEntity(entityId, components[0])\n }\n\n /**\n * Removes the specified component(s) from an entity\n * @example\n * ecs.remove(entityId, Position);\n */\n remove<T extends ComponentClass<any>[]>(entityId: number, ...components: T) {\n for (const component of components) {\n this.removeByKey(entityId, component)\n }\n }\n\n /**\n * Removes the specified component from an entity\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * ecs.removeByKey(entityId, \"Position\");\n */\n removeByKey(entityId: number, component: ComponentClass<any>) {\n // get the entity map\n const entityMap = this.components.get(component);\n\n // ensure the map is defined\n if (entityMap === undefined) throw new ComponentNotRegistered(component.name);\n\n // get the entity\n const entity = entityMap.get(entityId);\n if (entity === undefined) return false;\n\n // remove the entity from the entity map\n return entityMap.delete(entityId);\n }\n\n /**\n * Deletes all components from an entity\n * @example\n * const destroyedCount = ecs.destroyEntity(entityId1)\n * \n * // or multiple\n * const destroyedCount = ecs.destroyEntity(entityId1, entityId2)\n */\n destroyEntity(...entityIds: number[]): number {\n let deletedCount = 0;\n for (let index = 0; index < entityIds.length; index++) {\n const entityId = entityIds[index];\n for (const map of this.components.values()) {\n if (map.has(entityId)) {\n map.delete(entityId);\n deletedCount++;\n }\n }\n }\n return deletedCount;\n }\n\n // TODO create id generator\n /**\n * Creates a new entity id for the EntityMap\n * @example\n * const newEntityId = ecs.getNextId()\n * ecs.set(newEntityId, new Player())\n */\n getNextId(): number {\n this.nextId++;\n return this.nextId;\n }\n\n /**\n * Clears all registered components\n */\n clear() {\n this.components.clear();\n this.nextId = 0\n return this;\n }\n\n /**\n * Clears all component data\n */\n clearComponents() {\n this.components.forEach(x => x.clear())\n this.nextId = 0\n return this;\n }\n\n /**\n * Iterates over each component value that is related to the key component\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // iterate each component value that is related to the Player entity\n * const iterator = ecs.iterator(Player, Position)\n * \n * for(const [playerId, player, position] of iterator) { }\n * \n * // you can also declare the type of iterator before it's assigned\n * let iterator: IComponentIterator<[Player, Position]>\n * \n * // then with late bound assignment (keeping the iterator intellisense)\n * iterator = ecs.iterator(Player, Position)\n * \n * for(const [playerId, player, position] of iterator) {\n * const moving = player.isMoving\n * }\n */\n iterator<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ) {\n return new ComponentIterator(new ComponentQuery(this, keyComponent, ...components));\n }\n\n /**\n * Creates a query that can be stored and reused\n * \n * @param keyComponent\n * @param components\n * @example\n * const query = ecs.query(Player, Position)\n * \n * // get the first entry\n * const [playerId, player, position] = query.firstEntry() ?? []\n * \n * // get the first key\n * const [playerId, position] = query.firstKey() ?? []\n * \n * // get the first value\n * const [player, position] = query.firstValue() ?? []\n * \n * // iterate\n * for (const [playerId, player, position] of query) {\n * \n * }\n */\n query<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ) {\n return new ComponentQuery(this, keyComponent, ...components)\n }\n\n /**\n * Prints all component maps in a tabular format to the console.\n * \n * Additional generated columns are:\n * \n * 'Entity.Key' is the entity id\n * \n * 'Entity.Type' is the component name\n * \n * @param components - Optional. Filters the output to only include specific components.\n * @param properties - Optional. Specifies which property columns to display in the tables.\n */\n printTable(components?: string[]): this;\n printTable(components?: string[], properties?: string[]): this;\n printTable() {\n const componentsFilter = arguments[0] ?? [];\n const propertiesFilter = arguments[1] ?? [];\n this.components.forEach((map, key) => {\n if (componentsFilter.length === 0 || componentsFilter.includes(key)) {\n console.table(map.toTable(), propertiesFilter);\n }\n });\n return this;\n }\n\n /**\n * Prints all component data for the specified entity id in a tabular format to the console\n * \n * Additional generated columns are:\n * \n * 'Entity.Type' is the component name\n * \n * @param properties - Optional. Specifies which property columns to display in the tables.\n */\n printEntity(entityId: number, properties: string[] = []) {\n for (const map of this.components.values()) {\n if (map.has(entityId) === false) continue;\n\n const data = map.get(entityId);\n const columns = {\n 'entity.type': data.constructor.name,\n ...data\n };\n console.table({ [entityId]: columns }, properties);\n }\n\n return this;\n }\n\n /**\n * Parse's the JSON and returns an EntityMap object\n * @example\n * const json = JSON.stringfy(ecs);\n * const restoredMap = ecs.parse(json);\n */\n static parse(json: string): EntityMap {\n const restored = JSON.parse(json, function (key: string, value: any) {\n if (value.hasOwnProperty('components')) {\n Reflect.setPrototypeOf(value, EntityMap.prototype);\n return value;\n }\n if (value.hasOwnProperty(ComponentMapKey)) return new ComponentMap(value.iterable);\n if (value.hasOwnProperty(ComponentClassesMapKey)) return new ComponentClassesMap(value.iterable);\n return this[key];\n });\n return restored;\n }\n\n /**\n * A tracing method used for debugging.\n * Intercepts all functions specified and logs each call to the console.\n * @param {Array} funcFilter A list of function names you want to intercept. If no function names are specified then will log all functions called\n * @return {EntityMap} A new entity map with tracing enabled\n */\n static createWithTracing(funcFilter: any) {\n const traceHandler = {\n get(target: any, propKey: string) {\n const targetValue = target[propKey]\n\n if (typeof targetValue === 'function' && (funcFilter.length === 0 || funcFilter.includes(propKey))) {\n return function (this: any, ...args: any[]) {\n console.groupCollapsed('ecs trace', propKey, args);\n console.trace();\n console.groupEnd();\n return targetValue.apply(this, args);\n }\n }\n\n return targetValue;\n }\n }\n\n return new Proxy(new EntityMap(), traceHandler)\n }\n\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\n/**\n * An entity component system library for JavaScript\n * @showCategories\n * @module ecsjs\n */\nimport { EntityMap } from './entity-map.js'\nexport { ComponentClassesMap } from './component-classes.js'\nexport { ComponentMap } from './component-map.js'\nexport { EntityMap } from './entity-map.js'\nexport type { ComponentNotRegistered, ComponentTypeKeyMissing } from './errors.js'\nexport { ComponentIterator } from './iterator.js'\nexport { ComponentQuery } from './query.js'\nexport type { ComponentClass, IComponentIterator } from './types.js'\n\n/**\n * Global instance of an {@link EntityMap}\n * \n * See the [cheat sheet](https://gitlab.com/ecsjs/ecs/-/blob/master/docs/cheat-sheet.md) for more examples\n * @category Constants\n * @example\n * \n * // register component(s)\n * ecs.register(Player, Position)\n * \n * // create an entity\n * const [player, position] = ecs.set(ecs.getNextId(), new Player(), new Position(10, 40))\n */\nexport const ecs = new EntityMap()\n\nif (typeof window !== 'undefined') {\n // @ts-ignore: exports to window\n window.ecs = ecs\n} else if (typeof module !== 'undefined' && module !== null) {\n // exports to nodejs\n module.exports = { ecs };\n}"],
|
|
5
|
-
"mappings": "AAAO,IAAMA,EAAkB,eAClBC,EAAyB,sBCD/B,SAASC,EAAWC,EAAa,CACtC,IAAIC,EAAO,EACX,QAASC,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B,KAAK,MAAMA,EAAM,SAAUJ,EAAaK,EAAY,CACnE,OAAIA,EAAM,eAAe,YAAY,GACnC,QAAQ,eAAeA,EAAO7B,EAAU,SAAS,EAC1C6B,GAELA,EAAM,eAAeC,CAAe,EAAU,IAAIzB,EAAawB,EAAM,QAAQ,EAC7EA,EAAM,eAAeE,CAAsB,EAAU,IAAI9B,EAAoB4B,EAAM,QAAQ,EACxF,KAAKL,CAAG,CACjB,CAAC,CAEH,CAQA,OAAO,kBAAkBQ,EAAiB,CACxC,IAAMC,EAAe,CACnB,IAAIC,EAAaC,EAAiB,CAChC,IAAMC,EAAcF,EAAOC,CAAO,EAElC,OAAI,OAAOC,GAAgB,aAAeJ,EAAW,SAAW,GAAKA,EAAW,SAASG,CAAO,GACvF,YAAwBE,EAAa,CAC1C,eAAQ,eAAe,YAAaF,EAASE,CAAI,EACjD,QAAQ,MAAM,EACd,QAAQ,SAAS,EACVD,EAAY,MAAM,KAAMC,CAAI,CACrC,EAGKD,CACT,CACF,EAEA,OAAO,IAAI,MAAM,IAAIpC,EAAaiC,CAAY,CAChD,CAEF,EC1eO,IAAMK,EAAM,IAAIC,EAEnB,OAAO,OAAW,IAEpB,OAAO,IAAMD,EACJ,OAAO,OAAW,KAAe,SAAW,OAErD,OAAO,QAAU,CAAE,IAAAA,CAAI",
|
|
6
|
-
"names": ["ComponentMapKey", "ComponentClassesMapKey", "hashString", "str", "hash", "i", "char", "ComponentClassesMap", "entries", "i", "entry", "componentClass", "index", "map", "hashString", "hash", "existingIndex", "hashId", "lastIndex", "lastHash", "callback", "instances", "hashes", "value", "ComponentClassesMapKey", "ComponentMap", "entries", "i", "entry", "entityId", "component", "index", "lastIdx", "lastEntity", "callback", "entities", "instances", "result", "ComponentMapKey", "table", "key", "value", "entity", "meta", "properties", "ComponentTypeKeyMissing", "ComponentNotRegistered", "componentName", "ComponentIterator", "query", "entry", "value", "done", "entityId", "i", "map", "ComponentQuery", "ecs", "components", "i", "entityId", "entryValue", "results", "keyValue", "keyMap", "componentMaps", "keysIterator", "key", "value", "map", "ComponentIterator", "EntityMap", "_EntityMap", "ComponentClassesMap", "componentClasses", "componentClass", "ComponentTypeKeyMissing", "ComponentMap", "component", "map", "ComponentNotRegistered", "keyComponent", "entityId", "
|
|
4
|
+
"sourcesContent": ["export const ComponentMapKey = \"ComponentMap\"\nexport const ComponentClassesMapKey = \"ComponentClassesMap\"\n\nexport interface Component { }\n\n/**\n * @category Types\n * @example\n * \n * class PositionComponent {\n * constructor(x, y) {\n * this.x = x;\n * this.y = y;\n * }\n * }\n */\nexport type ComponentClass<ComponentInstance> = (new (...args: any[]) => ComponentInstance) & {\n // static property\n hashId?: number;\n};\n\n/**\n* Used for infering generic type spread for classes\n*/\nexport type ComponentClasses<T extends Component[]> =\n { [Index in keyof T]: ComponentClass<T[Index]> }\n\nexport type SingleOrArray<T extends any[]> =\n // return a single variadic item when only 1 item is specified\n T['length'] extends 1 ? T[0]\n // otherwise return an array of variadic types\n : { [Index in keyof T]: T[Index] }\n\nexport type Iterator<T> = {\n next: () => IteratorResult<T>\n reset: () => void\n [Symbol.iterator]: () => Iterator<T>\n}\n\n/**\n * allow late bound assignment type for intellisense\n * @category Types\n * @example\n * \n * let someIterator: IComponentIterator<[Player, Position]>\n * \n * // assignment made somewhere else in the code\n * const [player, position] = someIterator(Player, Position) ?? []\n * position?.x = 123 // position will have intellisense\n */\nexport type IComponentIterator<T extends Component[]>\n = Iterator<ComponentClasses<[number, ...T]>>", "export function hashString(str: string) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash |= 0; // Convert to 32bit\n }\n return hash;\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type { ComponentMap } from './component-map.js';\nimport {\n ComponentClassesMapKey,\n type ComponentClass,\n type Iterator,\n} from './types.js';\nimport { hashString } from './utils.js';\n\n/**\n * Component class map for storing registered component maps\n * @category Maps\n */\nexport class ComponentClassesMap {\n\n private hashIdToName: Map<number, string> = new Map<number, string>()\n private hashIdToIndex = new Map<number, number>();\n private indexToHashId: number[] = [];\n private maps: ComponentMap<any>[] = [];\n\n constructor(entries?: readonly (readonly [number, ComponentMap<any>])[] | null) {\n if (entries) {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n this.setByHashId(entry[0], entry[1]);\n }\n }\n }\n\n /**\n * The number of registered component maps\n */\n get size() {\n return this.maps.length;\n }\n\n /**\n * Clears all maps and internal indices while preserving array references\n */\n clear(): void {\n this.maps.length = 0;\n this.indexToHashId.length = 0;\n this.hashIdToIndex.clear();\n }\n\n /**\n * Retrieves a component map using the static hashId of a component class\n */\n get<T>(componentClass: ComponentClass<T>): ComponentMap<T> | undefined {\n const index = this.hashIdToIndex.get(componentClass.hashId!);\n return index !== undefined ? this.maps[index] : undefined;\n }\n\n /**\n * Registers a component map. Automatically generates a hashId from the class name if missing\n */\n set<T>(componentClass: ComponentClass<T>, map: ComponentMap<T>): this {\n if (componentClass.hashId === undefined) {\n componentClass.hashId = hashString(componentClass.name);\n }\n\n this.hashIdToName.set(componentClass.hashId, componentClass.name);\n return this.setByHashId(componentClass.hashId!, map);\n }\n\n /**\n * Maps a specific numeric hash id to a component map instance.\n */\n setByHashId(hash: number, map: ComponentMap<any>): this {\n const existingIndex = this.hashIdToIndex.get(hash);\n\n if (existingIndex !== undefined) {\n this.maps[existingIndex] = map;\n } else {\n this.hashIdToIndex.set(hash, this.maps.length);\n this.indexToHashId.push(hash);\n this.maps.push(map);\n }\n\n return this;\n }\n\n /**\n * Removes a component map and re-orders internal storage to maintain density\n */\n delete(componentClass: ComponentClass<any>): boolean {\n const hashId = componentClass.hashId!;\n const index = this.hashIdToIndex.get(hashId);\n if (index === undefined) return false;\n\n const lastIndex = this.maps.length - 1;\n const lastHash = this.indexToHashId[lastIndex];\n\n // Swap\n this.maps[index] = this.maps[lastIndex];\n this.indexToHashId[index] = lastHash;\n\n // Update map pointer\n this.hashIdToIndex.set(lastHash, index);\n\n // Pop\n this.maps.pop();\n this.indexToHashId.pop();\n this.hashIdToIndex.delete(hashId);\n return true;\n }\n\n /**\n * Executes a callback for every map, providing the instance and its registered name\n */\n forEach(callback: (value: ComponentMap<any>, name: string) => void) {\n for (let i = 0; i < this.maps.length; i++) {\n callback(this.maps[i], this.hashIdToName.get(this.indexToHashId[i])!);\n }\n }\n\n /**\n * Returns an iterator of all component map instances \n */\n values(): ArrayIterator<ComponentMap<any>> { return this.maps.values() }\n\n /**\n * Returns an iterator of [hashId, componentMap] pairs\n */\n entries(): Iterator<[number, ComponentMap<any>]> {\n let index = 0;\n const instances = this.maps;\n const hashes = this.indexToHashId;\n\n return {\n next(): IteratorResult<[number, ComponentMap<any>]> {\n if (index < instances.length) {\n const value: [number, ComponentMap<any>] = [hashes[index], instances[index]];\n index++;\n return { value, done: false };\n }\n return { value: undefined as any, done: true };\n },\n reset() { index = 0; },\n [Symbol.iterator]() { return this; }\n };\n }\n\n /**\n * Called when using JSON.stringify\n */\n toJSON() {\n return { [ComponentClassesMapKey]: 1, iterable: [...this.entries()] };\n }\n\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n ComponentMapKey,\n type Iterator\n} from './types.js';\n\n/**\n * Component map for storing entity ids and related component data\n * @category Maps\n */\nexport class ComponentMap<TComponentInstance> implements Iterable<[number, TComponentInstance]> {\n\n private indices: number[] = [];\n\n private entities: number[] = [];\n\n private instances: TComponentInstance[] = [];\n\n constructor(entries?: readonly (readonly [number, TComponentInstance])[] | null) {\n if (entries) {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n this.set(entry[0], entry[1]);\n }\n }\n }\n\n get size() {\n return this.instances.length;\n }\n\n clear() {\n this.indices = [];\n this.entities.length = 0;\n this.instances.length = 0;\n }\n\n set(entityId: number, component: TComponentInstance) {\n if (this.has(entityId)) {\n this.instances[this.indices[entityId]] = component;\n return;\n }\n this.indices[entityId] = this.instances.length;\n this.entities.push(entityId);\n this.instances.push(component);\n }\n\n get(entityId: number) {\n const index = this.indices[entityId];\n return index !== undefined && this.entities[index] === entityId\n ? this.instances[index]\n : undefined;\n }\n\n delete(entityId: number) {\n const index = this.indices[entityId];\n if (index === undefined || index === -1 || this.entities[index] !== entityId) return false;\n\n // swap and pop with last element to keep dense\n const lastIdx = this.instances.length - 1;\n const lastEntity = this.entities[lastIdx];\n this.instances[index] = this.instances[lastIdx];\n this.entities[index] = lastEntity;\n this.indices[lastEntity] = index;\n this.instances.pop();\n this.entities.pop();\n\n // invalidate index\n this.indices[entityId] = -1;\n\n return true;\n }\n\n has(entityId: number) {\n const index = this.indices[entityId];\n return index !== undefined && index !== -1 && this.entities[index] === entityId;\n }\n\n /**\n * Executes a callback for every map, providing the instance and its entity id\n */\n forEach(callback: (value: TComponentInstance, key: number) => void) {\n for (let i = 0; i < this.instances.length; i++) {\n callback(this.instances[i], this.entities[i]);\n }\n }\n\n /**\n * Returns the first entity entry\n */\n firstEntry(): [entityId: number, value: TComponentInstance] | undefined {\n return this.entities.length === 0\n ? undefined\n : [this.entities[0], this.instances[0]];\n }\n\n /**\n * Returns the first entity id\n */\n firstKey(): number | undefined {\n return this.entities.length === 0\n ? undefined\n : this.entities[0];\n }\n\n /**\n * Returns the first entity value\n */\n firstValue(): TComponentInstance | undefined {\n return this.instances.length === 0\n ? undefined\n : this.instances[0];\n }\n\n [Symbol.iterator](): Iterator<[number, TComponentInstance]> {\n return this.entries();\n }\n\n /**\n * Returns an iterator of all entity ids \n */\n keys(): ArrayIterator<number> {\n return this.entities.values();\n }\n\n /**\n * Returns an iterator of all component instances \n */\n values(): ArrayIterator<TComponentInstance> {\n return this.instances.values();\n }\n\n /**\n * Returns an iterator of [entityId, componentInstance] pairs\n */\n entries(): Iterator<[number, TComponentInstance]> {\n let index = 0;\n const entities = this.entities;\n const instances = this.instances;\n\n return {\n next(): IteratorResult<[number, TComponentInstance]> {\n if (index < instances.length) {\n const result: IteratorResult<[number, TComponentInstance]> = {\n value: [entities[index], instances[index]],\n done: false\n };\n index++;\n return result;\n }\n return { value: <any>undefined, done: true };\n },\n reset() {\n index = 0;\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n }\n\n /**\n * Called when using JSON.stringify\n */\n toJSON() {\n return { [ComponentMapKey]: 1, iterable: [...this.entries()] };\n }\n\n toTable(): any[] {\n const table = []\n for (const [key, value] of this.entries()) {\n const entity = value as { new(): TComponentInstance };\n const meta: Record<string, any> = {};\n meta[\"entity.key\"] = key;\n meta[\"entity.type\"] = entity.constructor.name;\n table.push({ ...meta, ...entity });\n }\n return table;\n }\n\n /**\n * Prints entity data in a tabular format to the console\n */\n printTable(properties: string[] = []): void {\n console.table(this.toTable(), properties);\n }\n\n}", "/**\n * Thrown when trying to register a component that is missing a 'name' parameter\n * @category Errors\n */\nexport class ComponentTypeKeyMissing extends Error {\n constructor() {\n super(`Component type is missing the 'name' parameter. i.e. a constructor name`);\n }\n}\n\n/**\n * Thrown when trying to access a component that has not been registered\n * @category Errors\n */\nexport class ComponentNotRegistered extends Error {\n constructor(public componentName: string) {\n super(`Component map does not exist for '${componentName}'`);\n }\n}", "import type { ComponentMap } from './component-map.js';\nimport type { ComponentQuery } from './query.js';\n\n/**\n * @category Iterators\n * @example\n * // construct an instance\n * const iterator = new ComponentIterator(new ComponentQuery(entityMap, Player, Position))\n * \n * // iterate each component value that is related to the Player\n * for(const [entityId, player, position] of iterator) { }\n * \n * // you can also reset the iterator back to the start\n * // without having to create a new ComponentIterator instance\n * iterator.reset()\n * for(const [entityId, player, position] of iterator) { }\n */\nexport class ComponentIterator<TKey, TRelated extends any[]> {\n private keyMap: ComponentMap<TKey>;\n private componentMaps: ComponentMap<any>[] = [];\n // iteration state\n private entries: Iterator<[number, TKey]>;\n\n constructor(query: ComponentQuery<TKey, TRelated>) {\n // @ts-ignore internal private var accessor\n this.keyMap = query.keyMap\n // @ts-ignore internal private var accessor\n this.componentMaps = query.componentMaps\n this.entries = this.keyMap.entries();\n }\n\n /**\n * gets the next iterator value\n */\n next(): IteratorResult<[number, TKey, ...TRelated]> {\n const entry = this.entries.next();\n const { value, done } = entry;\n if (done) return { value, done };\n\n const entityId = value[0];\n\n // append the related components\n for (let i = 0; i < this.componentMaps.length; i++) {\n const map = this.componentMaps[i];\n value.push(map.get(entityId));\n }\n\n return { value: value as any, done: false };\n }\n\n /**\n * resets the iterator back to the first entry\n */\n reset() {\n this.entries = this.keyMap.entries();\n }\n\n [Symbol.iterator]() { return this; }\n\n}", "import type { ComponentMap } from './component-map.js';\nimport type { EntityMap } from './entity-map.js';\nimport { ComponentIterator } from './iterator.js';\nimport type { ComponentClass, ComponentClasses, Iterator, SingleOrArray } from './types.js';\n\n/**\n * @category Queries\n * @example\n * const query = ecs.query(Player, Position)\n * \n * // get the first entry\n * const [playerId, player, position] = query.firstEntry() ?? []\n * \n * // get the first key\n * const [playerId, position] = query.firstKey() ?? []\n * \n * // get the first value\n * const [player, position] = query.firstValue() ?? []\n * \n * // iterate\n * for (const [playerId, player, position] of query) {\n * \n * }\n */\nexport class ComponentQuery<TKey, TRelated extends any[]> {\n private keyMap: ComponentMap<TKey>\n private componentMaps: ComponentMap<any>[] = []\n\n /**\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n */\n constructor(\n public ecs: EntityMap,\n ...components: [ComponentClass<TKey>, ...ComponentClasses<TRelated>]\n ) {\n this.keyMap = this.ecs.getMap(components[0])!;\n for (let i = 1; i < components.length; i++) {\n this.componentMaps.push(this.ecs.getMap(components[i])!)\n }\n }\n\n /**\n * Returns the first entity entry\n * \n * Optionally returns related components specified in the query constructor\n */\n firstEntry(): [number, TKey, ...TRelated] | undefined;\n firstEntry() {\n if (this.componentMaps.length === 0) return this.keyMap.firstEntry()\n\n const [entityId, entryValue] = this.keyMap.firstEntry() ?? []\n if (entityId === undefined) return undefined;\n\n const results: any[] = [entityId, entryValue]\n for (let i = 0; i < this.componentMaps.length; i++) {\n results.push(this.componentMaps[i].get(entityId));\n }\n\n return results\n }\n\n /**\n * Returns the first entity id\n * \n * Optionally returns related components specified in the query constructor\n */\n firstKey(): SingleOrArray<[number, ...TRelated]> | undefined;\n firstKey() {\n const entityId = this.keyMap.firstKey()\n if (this.componentMaps.length === 0) return entityId;\n if (entityId === undefined) return undefined;\n\n const results: any[] = [entityId]\n for (let i = 0; i < this.componentMaps.length; i++) {\n results.push(this.componentMaps[i].get(entityId));\n }\n\n return results\n }\n\n /**\n * Returns the first value\n * \n * Optionally returns related components specified in the query constructor\n */\n firstValue(): SingleOrArray<[TKey, ...TRelated]> | undefined;\n firstValue() {\n if (this.componentMaps.length === 0) return this.keyMap.firstValue()\n\n const [entityId, keyValue] = this.keyMap.firstEntry() ?? []\n if (entityId === undefined) return undefined;\n\n const results = [keyValue]\n for (let i = 0; i < this.componentMaps.length; i++) {\n results.push(this.componentMaps[i].get(entityId));\n }\n\n return results\n }\n\n /**\n * Returns the count of entities in the query\n */\n get entityCount() {\n return this.keyMap.size\n }\n\n /**\n * Destroys all entities in the query\n * \n * Returns the destroyed count\n * @example\n * const destroyedCount = query.destroyEntities()\n */\n destroyEntities(): number {\n return this.ecs.destroyEntity(...this.keyMap.keys())\n }\n\n /**\n * Returns an iterator of all the entityIds\n */\n keys(): ArrayIterator<number> { return this.keyMap.keys() }\n\n /**\n * Returns an iterator of all ComponentMap instances stored in this container\n */\n values(): Iterator<[TKey, ...TRelated]> {\n const keyMap = this.keyMap;\n const componentMaps = this.componentMaps;\n let keysIterator = keyMap.keys();\n\n return {\n next(): IteratorResult<[TKey, ...TRelated]> {\n const key = keysIterator.next();\n if (key.done) return { value: <any>undefined, done: true };\n\n const entityId = key.value;\n const keyComponent = keyMap.get(entityId);\n\n // append the related components\n const value = [keyComponent];\n for (let i = 0; i < componentMaps.length; i++) {\n const map = componentMaps[i];\n value.push(map.get(entityId));\n }\n\n return { value: value as any, done: false };\n },\n reset() { keysIterator = keyMap.keys(); },\n [Symbol.iterator]() { return this; },\n };\n }\n\n /**\n * Returns an iterator that flattens all internal maps into [entityId, KeyComponent, ...RelatedComponents]\n */\n entries() { return this[Symbol.iterator](); }\n\n /**\n * Returns an iterator that flattens all internal maps into [entityId, KeyComponent, ...RelatedComponents]\n */\n [Symbol.iterator]() {\n return new ComponentIterator(this);\n }\n\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { ComponentClassesMap } from './component-classes.js';\nimport { ComponentMap } from './component-map.js';\nimport { ComponentNotRegistered, ComponentTypeKeyMissing } from './errors.js';\nimport { ComponentIterator } from './iterator.js';\nimport { ComponentQuery } from './query.js';\nimport {\n ComponentClassesMapKey,\n ComponentMapKey,\n type Component,\n type ComponentClass,\n type ComponentClasses,\n type SingleOrArray\n} from './types.js';\n\n/**\n * Class for storing entities and their relationships\n * @category Maps\n */\nexport class EntityMap {\n /**\n * Registered component classes that contain the component instance data\n */\n public components = new ComponentClassesMap()\n\n private nextId: number = 0\n\n /**\n * Registers component classes with the {@link EntityMap}\n * @throwsError {@link ComponentTypeKeyMissing} when the specified component type is missing a 'name' parameter\n * @example\n * // component class\n * class MyComponent {\n * constructor(x) {\n * this.x = x;\n * }\n * }\n *\n * ecs.register(MyComponent);\n * // or mulitple\n * ecs.register(MyComponent1, MyComponent2);\n */\n register<TComponentClasses extends ComponentClass<any>[]>(...componentClasses: TComponentClasses) {\n for (const componentClass of componentClasses) {\n const componentName = componentClass.name;\n if (componentName === undefined) throw new ComponentTypeKeyMissing();\n\n // create the component map\n // const componentDataMap: ComponentMap<any> = new ComponentMap();\n this.components.set(componentClass, new ComponentMap());\n }\n\n // chain\n return this;\n }\n\n /**\n * Gets a component class map\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * const positionMap = ecs.getMap(Position)\n * for(const [entityId, position] of positionMap) {\n * position.x += 1\n * }\n */\n getMap<T>(component: ComponentClass<T>): ComponentMap<T> | undefined {\n const map = this.components.get(component);\n if (map === undefined) throw new ComponentNotRegistered(component.name)\n return map\n }\n\n /**\n * @deprecated Use <Function>firstEntity instead\n * \n * Returns an array of component data for the first entity associated with the keyComponent\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * // get the first entity\n * const playerEntity = ecs.first(Player) ?? []\n * )\n */\n first(keyComponent: ComponentClass<any>): Component[] | undefined { return this.firstEntity(keyComponent) };\n\n /**\n * Returns an array of component data for the first entity associated with the keyComponent\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * // get the first entity\n * const playerEntity = ecs.first(Player) ?? []\n * )\n */\n firstEntity(keyComponent: ComponentClass<any>): Component[] | undefined {\n const entityId = this.getMap(keyComponent)?.firstKey();\n if (entityId === undefined) return undefined;\n\n return this.get(entityId);\n }\n\n /**\n * Returns an array of component data arrays associated with the keyComponent\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * // get an array of component arrays: e.g. [[Player, Position, Velocity], [Player, Position, Velocity], ...]\n * const entities = ecs.entityValues(Player) ?? []\n */\n entityValues(keyComponent: ComponentClass<any>): Array<Component[]> | undefined {\n const entities = this.getMap(keyComponent)?.keys();\n if (entities === undefined) return undefined;\n\n return [...entities.map(x => this.get(x)!)]\n }\n\n /**\n * Gets the first entity entry for a component class\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * // return the first entry\n * const [entityId, player] = ecs.firstEntry(Player) ?? []\n * \n * // or return multiple related components in addition to the first entry\n * const [entityId, player, position, direction] = ecs.firstEntry(\n * Player,\n * Position,\n * Direction\n * )\n */\n firstEntry<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ): [number, TKey, ...TRelated] | undefined;\n firstEntry(keyComponent: ComponentClass<any>, ...components: ComponentClass<any>[]) {\n if (components.length === 0) return this.getMap(keyComponent)?.firstEntry()\n\n return this.firstKey(keyComponent, keyComponent, ...components);\n }\n\n /**\n * Gets the first entity id for a component class \n * and optionally any related component data\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // return the first entity id\n * const entityId = ecs.firstKey(Player)\n * \n * // or return multiple related component in addition to entity id\n * const [entityId, position, direction] = ecs.firstKey(\n * Player,\n * Position,\n * Direction\n * ) ?? []\n */\n firstKey<TKey, TRelated extends any[]>(\n keyComponent: TKey,\n ...components: ComponentClasses<TRelated>\n ): SingleOrArray<[number, ...TRelated]> | undefined;\n firstKey(keyComponent: ComponentClass<any>, ...components: ComponentClass<any>[]) {\n const entityId = this.getMap(keyComponent)?.firstKey();\n\n // single component key\n if (arguments.length === 1) return entityId;\n if (entityId === undefined) return undefined;\n\n // attach related component values\n return [entityId, ...components.map(x => this.getEntity(entityId, x))];\n }\n\n /**\n * Gets the first entity component data for a component class\n * and optionally any related component data\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // return the first component value\n * const player = ecs.firstValue(Player)\n * \n * // or multiple related values in addition to the first component\n * const [player, position, direction] = ecs.firstValue(\n * Player,\n * Position,\n * Direction\n * )\n */\n firstValue<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ): SingleOrArray<[TKey, ...TRelated]> | undefined;\n firstValue(keyComponent: ComponentClass<any>, ...components: ComponentClass<any>[]) {\n // single component\n if (arguments.length === 1) return this.getMap(keyComponent)?.firstValue();\n\n // get the first entry\n const [entityId, keyValue] = this.getMap(keyComponent)?.firstEntry() ?? [];\n if (entityId === undefined) return undefined;\n\n // attach related components\n return [keyValue, ...components.map(x => this.getEntity(entityId, x))]\n }\n\n /**\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered \n */\n private getEntity<T>(entityId: number, component: ComponentClass<T>): T | undefined {\n const map = this.components.get(component);\n if (map === undefined) throw new ComponentNotRegistered(component.name)\n\n return map.get(entityId);\n }\n\n /**\n * Gets component values related to an entity id\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // get one by id\n * const player = ecs.get(entityId, Player)\n * \n * // get multiple by id\n * const [player, position] = ecs.get(entityId, Player, Position) ?? []\n * \n * // get all by id\n * const playerEntity = ecs.get(entityId) ?? []\n */\n get(entityId: number): Component[] | undefined;\n get<T>(entityId: number, component: ComponentClass<T>): T | undefined;\n get<T extends any[]>(entityId: number, ...components: ComponentClasses<T>): SingleOrArray<T> | undefined;\n get(entityId: number, ...components: ComponentClasses<any>): Component | Component[] | undefined {\n // return a single component\n if (components.length === 1) return this.getEntity(entityId, components[0]);\n // return filtered components\n if (components.length > 1) return components.map(x => this.getEntity(entityId, x));\n // return all components\n return [...this.components.values()]\n .filter(v => v.has(entityId))\n .map(v => v.get(entityId));\n }\n\n /**\n * Check if a component exists for an entity\n * @example\n * const exists = ecs.has(entityId, Position)\n */\n has<T>(entityId: number, component: ComponentClass<T>): boolean {\n // get the component map\n const map = this.components.get(component);\n if (map === undefined) return false\n\n return map.has(entityId);\n }\n\n /**\n * Checks if all of the specified components exist for an entity\n * @example\n * const hasAll = ecs.hasAll(entityId, Position, Velocity)\n */\n hasAll<T extends ComponentClass<any>[]>(entityId: number, ...components: T): boolean {\n for (let index = 0; index < components.length; index++) {\n const component = components[index];\n const map = this.components.get(component);\n if (map === undefined) return false;\n if (map.has(entityId) === false) return false;\n }\n return true\n }\n\n /**\n * Checks if any of the specified components exist for an entity\n * @example\n * const hasAny = ecs.hasAny(entityId, Position, Velocity)\n */\n hasAny<T extends ComponentClass<any>[]>(entityId: number, ...components: T): boolean {\n for (let index = 0; index < components.length; index++) {\n const component = components[index];\n const map = this.components.get(component);\n if (map === undefined) continue;\n if (map.has(entityId)) return true;\n }\n return false\n }\n\n private setEntity<T extends Component>(entityId: number, componentData: T): T {\n // get the component map\n const map = this.components.get((<ComponentClass<any>>componentData.constructor));\n if (map === undefined) throw new ComponentNotRegistered(componentData.constructor.name)\n\n // set the entity on the entity map\n map.set(entityId, componentData);\n\n // return instance\n return componentData;\n }\n\n /**\n * Add or update multiple component values for an entity\n * @example\n * // set one\n * const player = ecs.set(entityId, new Player());\n * \n * // or set multiple\n * const [player, position] = ecs.set(\n * entityId,\n * new Player(),\n * new Position()\n * );\n */\n set<T extends Component>(entityId: number, component: T): T;\n set<T extends Component[]>(entityId: number, ...components: T): T;\n set(entityId: number, ...components: Component[]): Component | Component[] {\n if (components.length > 1) return components.map(x => this.setEntity(entityId, x))\n\n // set and return a single component\n return this.setEntity(entityId, components[0])\n }\n\n /**\n * Removes the specified component(s) from an entity\n * @example\n * ecs.remove(entityId, Position);\n */\n remove<T extends ComponentClass<any>[]>(entityId: number, ...components: T) {\n for (const component of components) {\n this.removeByKey(entityId, component)\n }\n }\n\n /**\n * Removes the specified component from an entity\n * @throwsError {@link ComponentNotRegistered} when the specified component is not registered\n * @example\n * ecs.removeByKey(entityId, \"Position\");\n */\n removeByKey(entityId: number, component: ComponentClass<any>) {\n // get the entity map\n const entityMap = this.components.get(component);\n\n // ensure the map is defined\n if (entityMap === undefined) throw new ComponentNotRegistered(component.name);\n\n // get the entity\n const entity = entityMap.get(entityId);\n if (entity === undefined) return false;\n\n // remove the entity from the entity map\n return entityMap.delete(entityId);\n }\n\n /**\n * Deletes all components from an entity\n * @example\n * const destroyedCount = ecs.destroyEntity(entityId1)\n * \n * // or multiple\n * const destroyedCount = ecs.destroyEntity(entityId1, entityId2)\n */\n destroyEntity(...entityIds: number[]): number {\n let deletedCount = 0;\n for (let index = 0; index < entityIds.length; index++) {\n const entityId = entityIds[index];\n for (const map of this.components.values()) {\n if (map.has(entityId)) {\n map.delete(entityId);\n deletedCount++;\n }\n }\n }\n return deletedCount;\n }\n\n // TODO create id generator\n /**\n * Creates a new entity id for the EntityMap\n * @example\n * const newEntityId = ecs.getNextId()\n * ecs.set(newEntityId, new Player())\n */\n getNextId(): number {\n this.nextId++;\n return this.nextId;\n }\n\n /**\n * Clears all registered components\n */\n clear() {\n this.components.clear();\n this.nextId = 0\n return this;\n }\n\n /**\n * Clears all component data\n */\n clearComponents() {\n this.components.forEach(x => x.clear())\n this.nextId = 0\n return this;\n }\n\n /**\n * Iterates over each component value that is related to the key component\n * @throwsError {@link ComponentNotRegistered} when any of specified component(s) are not registered\n * @example\n * // iterate each component value that is related to the Player entity\n * const iterator = ecs.iterator(Player, Position)\n * \n * for(const [playerId, player, position] of iterator) { }\n * \n * // you can also declare the type of iterator before it's assigned\n * let iterator: IComponentIterator<[Player, Position]>\n * \n * // then with late bound assignment (keeping the iterator intellisense)\n * iterator = ecs.iterator(Player, Position)\n * \n * for(const [playerId, player, position] of iterator) {\n * const moving = player.isMoving\n * }\n */\n iterator<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ) {\n return new ComponentIterator(new ComponentQuery(this, keyComponent, ...components));\n }\n\n /**\n * Creates a query that can be stored and reused\n * \n * @param keyComponent\n * @param components\n * @example\n * const query = ecs.query(Player, Position)\n * \n * // get the first entry\n * const [playerId, player, position] = query.firstEntry() ?? []\n * \n * // get the first key\n * const [playerId, position] = query.firstKey() ?? []\n * \n * // get the first value\n * const [player, position] = query.firstValue() ?? []\n * \n * // iterate\n * for (const [playerId, player, position] of query) {\n * \n * }\n */\n query<TKey, TRelated extends any[]>(\n keyComponent: ComponentClass<TKey>,\n ...components: ComponentClasses<TRelated>\n ) {\n return new ComponentQuery(this, keyComponent, ...components)\n }\n\n /**\n * Prints all component maps in a tabular format to the console.\n * \n * Additional generated columns are:\n * \n * 'Entity.Key' is the entity id\n * \n * 'Entity.Type' is the component name\n * \n * @param components - Optional. Filters the output to only include specific components.\n * @param properties - Optional. Specifies which property columns to display in the tables.\n */\n printTable(components?: string[]): this;\n printTable(components?: string[], properties?: string[]): this;\n printTable() {\n const componentsFilter = arguments[0] ?? [];\n const propertiesFilter = arguments[1] ?? [];\n this.components.forEach((map, key) => {\n if (componentsFilter.length === 0 || componentsFilter.includes(key)) {\n console.table(map.toTable(), propertiesFilter);\n }\n });\n return this;\n }\n\n /**\n * Prints all component data for the specified entity id in a tabular format to the console\n * \n * Additional generated columns are:\n * \n * 'Entity.Type' is the component name\n * \n * @param properties - Optional. Specifies which property columns to display in the tables.\n */\n printEntity(entityId: number, properties: string[] = []) {\n for (const map of this.components.values()) {\n if (map.has(entityId) === false) continue;\n\n const data = map.get(entityId);\n const columns = {\n 'entity.type': data.constructor.name,\n ...data\n };\n console.table({ [entityId]: columns }, properties);\n }\n\n return this;\n }\n\n /**\n * Parse's the JSON and returns an EntityMap object\n * @example\n * const json = JSON.stringfy(ecs);\n * const restoredMap = ecs.parse(json);\n */\n static parse(json: string): EntityMap {\n const restored = JSON.parse(json, function (key: string, value: any) {\n if (value.hasOwnProperty('components')) {\n Reflect.setPrototypeOf(value, EntityMap.prototype);\n return value;\n }\n if (value.hasOwnProperty(ComponentMapKey)) return new ComponentMap(value.iterable);\n if (value.hasOwnProperty(ComponentClassesMapKey)) return new ComponentClassesMap(value.iterable);\n return this[key];\n });\n return restored;\n }\n\n /**\n * A tracing method used for debugging.\n * Intercepts all functions specified and logs each call to the console.\n * @param {Array} funcFilter A list of function names you want to intercept. If no function names are specified then will log all functions called\n * @return {EntityMap} A new entity map with tracing enabled\n */\n static createWithTracing(funcFilter: any) {\n const traceHandler = {\n get(target: any, propKey: string) {\n const targetValue = target[propKey]\n\n if (typeof targetValue === 'function' && (funcFilter.length === 0 || funcFilter.includes(propKey))) {\n return function (this: any, ...args: any[]) {\n console.groupCollapsed('ecs trace', propKey, args);\n console.trace();\n console.groupEnd();\n return targetValue.apply(this, args);\n }\n }\n\n return targetValue;\n }\n }\n\n return new Proxy(new EntityMap(), traceHandler)\n }\n\n}", "/*\n ecsjs is an entity component system library for JavaScript\n Copyright (C) 2014 Peter Flannery\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Affero General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Affero General Public License for more details.\n\n You should have received a copy of the GNU Affero General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\n/**\n * An entity component system library for JavaScript\n * @showCategories\n * @module ecsjs\n */\nimport { EntityMap } from './entity-map.js'\nexport { ComponentClassesMap } from './component-classes.js'\nexport { ComponentMap } from './component-map.js'\nexport { EntityMap } from './entity-map.js'\nexport type { ComponentNotRegistered, ComponentTypeKeyMissing } from './errors.js'\nexport { ComponentIterator } from './iterator.js'\nexport { ComponentQuery } from './query.js'\nexport type { ComponentClass, IComponentIterator } from './types.js'\n\n/**\n * Global instance of an {@link EntityMap}\n * \n * See the [cheat sheet](https://gitlab.com/ecsjs/ecs/-/blob/master/docs/cheat-sheet.md) for more examples\n * @category Constants\n * @example\n * \n * // register component(s)\n * ecs.register(Player, Position)\n * \n * // create an entity\n * const [player, position] = ecs.set(ecs.getNextId(), new Player(), new Position(10, 40))\n */\nexport const ecs = new EntityMap()\n\nif (typeof window !== 'undefined') {\n // @ts-ignore: exports to window\n window.ecs = ecs\n} else if (typeof module !== 'undefined' && module !== null) {\n // exports to nodejs\n module.exports = { ecs };\n}"],
|
|
5
|
+
"mappings": "AAAO,IAAMA,EAAkB,eAClBC,EAAyB,sBCD/B,SAASC,EAAWC,EAAa,CACtC,IAAIC,EAAO,EACX,QAASC,EAAI,EAAGA,EAAIF,EAAI,OAAQE,IAAK,CACnC,IAAMC,EAAOH,EAAI,WAAWE,CAAC,EAC7BD,GAASA,GAAQ,GAAKA,EAAQE,EAC9BF,GAAQ,CACV,CACA,OAAOA,CACT,CCqBO,IAAMG,EAAN,KAA0B,CAEvB,aAAoC,IAAI,IACxC,cAAgB,IAAI,IACpB,cAA0B,CAAC,EAC3B,KAA4B,CAAC,EAErC,YAAYC,EAAoE,CAC9E,GAAIA,EACF,QAASC,EAAI,EAAGA,EAAID,EAAQ,OAAQC,IAAK,CACvC,IAAMC,EAAQF,EAAQC,CAAC,EACvB,KAAK,YAAYC,EAAM,CAAC,EAAGA,EAAM,CAAC,CAAC,CACrC,CAEJ,CAKA,IAAI,MAAO,CACT,OAAO,KAAK,KAAK,MACnB,CAKA,OAAc,CACZ,KAAK,KAAK,OAAS,EACnB,KAAK,cAAc,OAAS,EAC5B,KAAK,cAAc,MAAM,CAC3B,CAKA,IAAOC,EAAgE,CACrE,IAAMC,EAAQ,KAAK,cAAc,IAAID,EAAe,MAAO,EAC3D,OAAOC,IAAU,OAAY,KAAK,KAAKA,CAAK,EAAI,MAClD,CAKA,IAAOD,EAAmCE,EAA4B,CACpE,OAAIF,EAAe,SAAW,SAC5BA,EAAe,OAAS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,SAAS,EACVD,EAAY,MAAM,KAAMC,CAAI,CACrC,EAGKD,CACT,CACF,EAEA,OAAO,IAAI,MAAM,IAAIrC,EAAakC,CAAY,CAChD,CAEF,ECpgBO,IAAMK,EAAM,IAAIC,EAEnB,OAAO,OAAW,IAEpB,OAAO,IAAMD,EACJ,OAAO,OAAW,KAAe,SAAW,OAErD,OAAO,QAAU,CAAE,IAAAA,CAAI",
|
|
6
|
+
"names": ["ComponentMapKey", "ComponentClassesMapKey", "hashString", "str", "hash", "i", "char", "ComponentClassesMap", "entries", "i", "entry", "componentClass", "index", "map", "hashString", "hash", "existingIndex", "hashId", "lastIndex", "lastHash", "callback", "instances", "hashes", "value", "ComponentClassesMapKey", "ComponentMap", "entries", "i", "entry", "entityId", "component", "index", "lastIdx", "lastEntity", "callback", "entities", "instances", "result", "ComponentMapKey", "table", "key", "value", "entity", "meta", "properties", "ComponentTypeKeyMissing", "ComponentNotRegistered", "componentName", "ComponentIterator", "query", "entry", "value", "done", "entityId", "i", "map", "ComponentQuery", "ecs", "components", "i", "entityId", "entryValue", "results", "keyValue", "keyMap", "componentMaps", "keysIterator", "key", "value", "map", "ComponentIterator", "EntityMap", "_EntityMap", "ComponentClassesMap", "componentClasses", "componentClass", "ComponentTypeKeyMissing", "ComponentMap", "component", "map", "ComponentNotRegistered", "keyComponent", "entityId", "entities", "x", "components", "keyValue", "v", "index", "componentData", "entityMap", "entityIds", "deletedCount", "ComponentIterator", "ComponentQuery", "componentsFilter", "propertiesFilter", "key", "properties", "data", "columns", "json", "value", "ComponentMapKey", "ComponentClassesMapKey", "funcFilter", "traceHandler", "target", "propKey", "targetValue", "args", "ecs", "EntityMap"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-classes.d.ts","sourceRoot":"","sources":["../../../src/component-classes.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAEL,KAAK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OAEG;IACH,OAAO,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAmBhD;;OAEG;IACH,MAAM;;;;CAIP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-map.d.ts","sourceRoot":"","sources":["../../../src/component-map.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"component-map.d.ts","sourceRoot":"","sources":["../../../src/component-map.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,YAAY,CAAC,kBAAkB,CAAE,YAAW,QAAQ,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAE7F,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,QAAQ,CAAgB;IAEhC,OAAO,CAAC,SAAS,CAA4B;gBAEjC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,EAAE,GAAG,IAAI;IAS/E,IAAI,IAAI,WAEP;IAED,KAAK;IAML,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB;IAUnD,GAAG,CAAC,QAAQ,EAAE,MAAM;IAOpB,MAAM,CAAC,QAAQ,EAAE,MAAM;IAmBvB,GAAG,CAAC,QAAQ,EAAE,MAAM;IAKpB;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI;IAMlE;;OAEG;IACH,UAAU,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,CAAC,GAAG,SAAS;IAMvE;;OAEG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS;IAM9B;;OAEG;IACH,UAAU,IAAI,kBAAkB,GAAG,SAAS;IAM5C,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAI3D;;OAEG;IACH,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC;IAI7B;;OAEG;IACH,MAAM,IAAI,aAAa,CAAC,kBAAkB,CAAC;IAI3C;;OAEG;IACH,OAAO,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IA0BjD;;OAEG;IACH,MAAM;;;;IAIN,OAAO,IAAI,GAAG,EAAE;IAYhB;;OAEG;IACH,UAAU,CAAC,UAAU,GAAE,MAAM,EAAO,GAAG,IAAI;CAI5C"}
|
|
@@ -40,14 +40,33 @@ export declare class EntityMap {
|
|
|
40
40
|
*/
|
|
41
41
|
getMap<T>(component: ComponentClass<T>): ComponentMap<T> | undefined;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* @deprecated Use <Function>firstEntity instead
|
|
44
|
+
*
|
|
45
|
+
* Returns an array of component data for the first entity associated with the keyComponent
|
|
44
46
|
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
45
47
|
* @example
|
|
46
|
-
* //
|
|
48
|
+
* // get the first entity
|
|
47
49
|
* const playerEntity = ecs.first(Player) ?? []
|
|
48
50
|
* )
|
|
49
51
|
*/
|
|
50
52
|
first(keyComponent: ComponentClass<any>): Component[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Returns an array of component data for the first entity associated with the keyComponent
|
|
55
|
+
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
56
|
+
* @example
|
|
57
|
+
* // get the first entity
|
|
58
|
+
* const playerEntity = ecs.first(Player) ?? []
|
|
59
|
+
* )
|
|
60
|
+
*/
|
|
61
|
+
firstEntity(keyComponent: ComponentClass<any>): Component[] | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Returns an array of component data arrays associated with the keyComponent
|
|
64
|
+
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
65
|
+
* @example
|
|
66
|
+
* // get an array of component arrays: e.g. [[Player, Position, Velocity], [Player, Position, Velocity], ...]
|
|
67
|
+
* const entities = ecs.entityValues(Player) ?? []
|
|
68
|
+
*/
|
|
69
|
+
entityValues(keyComponent: ComponentClass<any>): Array<Component[]> | undefined;
|
|
51
70
|
/**
|
|
52
71
|
* Gets the first entity entry for a component class
|
|
53
72
|
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-map.d.ts","sourceRoot":"","sources":["../../../src/entity-map.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,SAAS;IACpB;;OAEG;IACI,UAAU,sBAA4B;IAE7C,OAAO,CAAC,MAAM,CAAY;IAE1B;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,iBAAiB,SAAS,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,gBAAgB,EAAE,iBAAiB;IAchG;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS;IAMpE;;;;;;;OAOG;IACH,
|
|
1
|
+
{"version":3,"file":"entity-map.d.ts","sourceRoot":"","sources":["../../../src/entity-map.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;A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;;OAQG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAO;IAevD;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAarC;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,GAAG;CAqBzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterator.d.ts","sourceRoot":"","sources":["../../../src/iterator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"iterator.d.ts","sourceRoot":"","sources":["../../../src/iterator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAiB,CAAC,IAAI,EAAE,QAAQ,SAAS,GAAG,EAAE;IACzD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,aAAa,CAA2B;IAEhD,OAAO,CAAC,OAAO,CAA2B;gBAE9B,KAAK,EAAE,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC;IAQjD;;OAEG;IACH,IAAI,IAAI,cAAc,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;IAgBnD;;OAEG;IACH,KAAK;IAIL,CAAC,MAAM,CAAC,QAAQ,CAAC;CAElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":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
2
|
export declare const ComponentClassesMapKey = "ComponentClassesMap";
|
|
3
|
-
export type KeyCollection<T> = {
|
|
4
|
-
[key: string]: T;
|
|
5
|
-
};
|
|
6
3
|
export interface Component {
|
|
7
4
|
}
|
|
8
5
|
/**
|
|
@@ -28,10 +25,6 @@ export type ComponentClasses<T extends Component[]> = {
|
|
|
28
25
|
export type SingleOrArray<T extends any[]> = T['length'] extends 1 ? T[0] : {
|
|
29
26
|
[Index in keyof T]: T[Index];
|
|
30
27
|
};
|
|
31
|
-
export type IteratorResult<T> = {
|
|
32
|
-
done: boolean;
|
|
33
|
-
value: T;
|
|
34
|
-
};
|
|
35
28
|
export type Iterator<T> = {
|
|
36
29
|
next: () => IteratorResult<T>;
|
|
37
30
|
reset: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,iBAAiB,CAAA;AAC7C,eAAO,MAAM,sBAAsB,wBAAwB,CAAA;AAE3D,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,iBAAiB,CAAA;AAC7C,eAAO,MAAM,sBAAsB,wBAAwB,CAAA;AAE3D,MAAM,WAAW,SAAS;CAAI;AAE9B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,CAAC,iBAAiB,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,CAAC,GAAG;IAE5F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;EAEE;AACF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,SAAS,EAAE,IAChD;KAAG,KAAK,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;CAAE,CAAA;AAElD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,GAAG,EAAE,IAEvC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAE1B;KAAG,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;CAAE,CAAA;AAEpC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACxB,IAAI,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,CAAA;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAA;CACrC,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,SAAS,EAAE,IAChD,QAAQ,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
package/src/component-classes.ts
CHANGED
package/src/component-map.ts
CHANGED
|
@@ -17,9 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import {
|
|
19
19
|
ComponentMapKey,
|
|
20
|
-
type Iterator
|
|
21
|
-
type IteratorResult,
|
|
22
|
-
type KeyCollection
|
|
20
|
+
type Iterator
|
|
23
21
|
} from './types.js';
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -188,7 +186,7 @@ export class ComponentMap<TComponentInstance> implements Iterable<[number, TComp
|
|
|
188
186
|
const table = []
|
|
189
187
|
for (const [key, value] of this.entries()) {
|
|
190
188
|
const entity = value as { new(): TComponentInstance };
|
|
191
|
-
const meta:
|
|
189
|
+
const meta: Record<string, any> = {};
|
|
192
190
|
meta["entity.key"] = key;
|
|
193
191
|
meta["entity.type"] = entity.constructor.name;
|
|
194
192
|
table.push({ ...meta, ...entity });
|
package/src/entity-map.ts
CHANGED
|
@@ -86,20 +86,46 @@ export class EntityMap {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* @deprecated Use <Function>firstEntity instead
|
|
90
|
+
*
|
|
91
|
+
* Returns an array of component data for the first entity associated with the keyComponent
|
|
92
|
+
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
93
|
+
* @example
|
|
94
|
+
* // get the first entity
|
|
95
|
+
* const playerEntity = ecs.first(Player) ?? []
|
|
96
|
+
* )
|
|
97
|
+
*/
|
|
98
|
+
first(keyComponent: ComponentClass<any>): Component[] | undefined { return this.firstEntity(keyComponent) };
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns an array of component data for the first entity associated with the keyComponent
|
|
90
102
|
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
91
103
|
* @example
|
|
92
|
-
* //
|
|
104
|
+
* // get the first entity
|
|
93
105
|
* const playerEntity = ecs.first(Player) ?? []
|
|
94
106
|
* )
|
|
95
107
|
*/
|
|
96
|
-
|
|
108
|
+
firstEntity(keyComponent: ComponentClass<any>): Component[] | undefined {
|
|
97
109
|
const entityId = this.getMap(keyComponent)?.firstKey();
|
|
98
110
|
if (entityId === undefined) return undefined;
|
|
99
111
|
|
|
100
112
|
return this.get(entityId);
|
|
101
113
|
}
|
|
102
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Returns an array of component data arrays associated with the keyComponent
|
|
117
|
+
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
|
118
|
+
* @example
|
|
119
|
+
* // get an array of component arrays: e.g. [[Player, Position, Velocity], [Player, Position, Velocity], ...]
|
|
120
|
+
* const entities = ecs.entityValues(Player) ?? []
|
|
121
|
+
*/
|
|
122
|
+
entityValues(keyComponent: ComponentClass<any>): Array<Component[]> | undefined {
|
|
123
|
+
const entities = this.getMap(keyComponent)?.keys();
|
|
124
|
+
if (entities === undefined) return undefined;
|
|
125
|
+
|
|
126
|
+
return [...entities.map(x => this.get(x)!)]
|
|
127
|
+
}
|
|
128
|
+
|
|
103
129
|
/**
|
|
104
130
|
* Gets the first entity entry for a component class
|
|
105
131
|
* @throwsError {@link ComponentNotRegistered} when the specified component is not registered
|
package/src/iterator.ts
CHANGED
package/src/query.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentMap } from './component-map.js';
|
|
2
2
|
import type { EntityMap } from './entity-map.js';
|
|
3
3
|
import { ComponentIterator } from './iterator.js';
|
|
4
|
-
import type { ComponentClass, ComponentClasses, Iterator,
|
|
4
|
+
import type { ComponentClass, ComponentClasses, Iterator, SingleOrArray } from './types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @category Queries
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export const ComponentMapKey = "ComponentMap"
|
|
2
2
|
export const ComponentClassesMapKey = "ComponentClassesMap"
|
|
3
3
|
|
|
4
|
-
export type KeyCollection<T> = { [key: string]: T }
|
|
5
|
-
|
|
6
4
|
export interface Component { }
|
|
7
5
|
|
|
8
6
|
/**
|
|
@@ -33,11 +31,6 @@ export type SingleOrArray<T extends any[]> =
|
|
|
33
31
|
// otherwise return an array of variadic types
|
|
34
32
|
: { [Index in keyof T]: T[Index] }
|
|
35
33
|
|
|
36
|
-
export type IteratorResult<T> = {
|
|
37
|
-
done: boolean,
|
|
38
|
-
value: T
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
export type Iterator<T> = {
|
|
42
35
|
next: () => IteratorResult<T>
|
|
43
36
|
reset: () => void
|