@perplexdotgg/mecs 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +5 -5
- package/build/mecs.js +2 -2
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { MonomorphClass } from 'monomorph';
|
|
|
3
3
|
import { MonomorphInstance } from 'monomorph';
|
|
4
4
|
import { NumberArray } from 'monomorph';
|
|
5
5
|
import { PartialRecursive } from 'monomorph';
|
|
6
|
+
import { PoolClass } from 'monomorph';
|
|
6
7
|
import { WithPool } from 'monomorph';
|
|
7
8
|
|
|
8
9
|
export declare type ComponentConfig<ComponentType, ComponentInputType extends any = InputType<ComponentType> extends never ? ComponentType : InputType<ComponentType>> = {
|
|
@@ -11,10 +12,11 @@ export declare type ComponentConfig<ComponentType, ComponentInputType extends an
|
|
|
11
12
|
afterComponentAddedCode?: string | ComponentConfigFunction<ComponentType, ComponentInputType>;
|
|
12
13
|
beforeComponentRemoved?: (componentInstance: ComponentType extends abstract new (...args: any) => any ? InstanceType<ComponentType> : ComponentType, entity: any, componentKey: string) => void;
|
|
13
14
|
beforeComponentRemovedCode?: string | ComponentConfigFunction<ComponentType, ComponentInputType>;
|
|
14
|
-
processDataOnAdd?: (data: ComponentInputType) => ComponentInputType;
|
|
15
|
+
processDataOnAdd?: (data: ComponentInputType, entity: any, componentKey: string) => ComponentInputType;
|
|
15
16
|
processDataOnAddCode?: string | ((options: {
|
|
16
17
|
dataVariableName: string;
|
|
17
18
|
componentConfigReference: string;
|
|
19
|
+
entityVariableName: string;
|
|
18
20
|
}) => string);
|
|
19
21
|
nullComponent?: (entity: any, componentKey: string) => void;
|
|
20
22
|
nullComponentCode?: string | ComponentConfigFunction<ComponentType, ComponentInputType>;
|
|
@@ -105,9 +107,7 @@ export declare interface EntityConstructor<QM extends QueryMap<any, CM>, E exten
|
|
|
105
107
|
};
|
|
106
108
|
};
|
|
107
109
|
components: {
|
|
108
|
-
[K in keyof CM as ExtractMonomorphClass<CM[K]> extends MonomorphClass<infer P, infer I, infer M> ? LowercaseFirstLetter<K> : never]:
|
|
109
|
-
[Symbol.iterator](): IterableIterator<WithPool<InstanceType<ExtractMonomorphClass<CM[K]>>>>;
|
|
110
|
-
};
|
|
110
|
+
[K in keyof CM as ExtractMonomorphClass<CM[K]> extends MonomorphClass<infer P, infer I, infer M> ? LowercaseFirstLetter<K> : never]: PoolClass<ExtractMonomorphClass<CM[K]>>;
|
|
111
111
|
};
|
|
112
112
|
queries: {
|
|
113
113
|
[K in keyof QM]: {
|
|
@@ -124,7 +124,7 @@ export declare interface EntityConstructor<QM extends QueryMap<any, CM>, E exten
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export declare type EntityInput<X extends ComponentMap | EntityClass<any, any, any, any> | EntityInstanceWithPool<any, any, any> | EntityInstance<any, any>> = X extends ComponentMap ? ComponentMapInput<X> : X extends EntityConstructor<infer QM, infer E, infer I, infer CM> ? I : X extends EntityInstanceWithPool<infer CM, infer I, infer E> ? I : X extends EntityInstance<infer CM, infer I> ? I : never
|
|
127
|
+
export declare type EntityInput<X extends ComponentMap | EntityClass<any, any, any, any> | EntityInstanceWithPool<any, any, any> | EntityInstance<any, any>> = Writeable<X extends ComponentMap ? ComponentMapInput<X> : X extends EntityConstructor<infer QM, infer E, infer I, infer CM> ? I : X extends EntityInstanceWithPool<infer CM, infer I, infer E> ? I : X extends EntityInstance<infer CM, infer I> ? I : never>;
|
|
128
128
|
|
|
129
129
|
export declare type EntityInstance<CM extends ComponentMap, I extends any = ComponentMapInput<CM>> = ComponentMapClassProperties<CM> & EntityBaseProperties<CM, I>;
|
|
130
130
|
|
package/build/mecs.js
CHANGED
|
@@ -107,12 +107,12 @@ function getEntityClassCode(componentMap, queries, options) {
|
|
|
107
107
|
referenceComponentFunctionsCode += `
|
|
108
108
|
const ${componentKey}ProcessDataOnAdd = componentMap.${key}.processDataOnAdd;
|
|
109
109
|
`;
|
|
110
|
-
processedDataCode = `${componentKey}ProcessDataOnAdd(data)`;
|
|
110
|
+
processedDataCode = `${componentKey}ProcessDataOnAdd(data, entity, '${componentKey}')`;
|
|
111
111
|
} else if ("processDataOnAddCode" in component) {
|
|
112
112
|
if (typeof component.processDataOnAddCode === "string") {
|
|
113
113
|
processedDataCode = component.processDataOnAddCode;
|
|
114
114
|
} else {
|
|
115
|
-
processedDataCode = component.processDataOnAddCode({ dataVariableName: "data", componentConfigReference: "componentMap." + key });
|
|
115
|
+
processedDataCode = component.processDataOnAddCode({ dataVariableName: "data", entityVariableName: "entity", componentConfigReference: "componentMap." + key });
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
if ("nullComponent" in component) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perplexdotgg/mecs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "MECS - Monomorph ECS - A high-performance Entity Component System for TypeScript and JavaScript projects, designed for games and simulations.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|