mani-game-engine 1.0.0-pre.2 → 1.0.0-pre.20

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.
@@ -1,121 +1,140 @@
1
- import { createDependencyAnnotation, Injector, putIfAbsent } from 'mani-injector';
2
- import { Signal } from 'mani-signal';
3
- export const entityComponents = new Map();
4
- export const GetComponent = createDependencyAnnotation((type, index) => ({ kind: 'component', type, index }));
5
- export const GetEntity = createDependencyAnnotation((_type, index) => ({ kind: 'entity', index }));
6
- export const GetSignal = (id) => createDependencyAnnotation((_type, index) => ({ kind: 'signal', index, id }));
7
- export const EntityComponent = (target, propertyKey) => {
8
- const entityClass = target.constructor;
9
- const componentClass = Reflect.getMetadata('design:type', target, propertyKey);
10
- if (componentClass === Object) {
11
- throw new Error(`Object component type not allowed. Forgot to specify type of ${entityClass.name}.${propertyKey}?`);
12
- }
13
- const componentSet = putIfAbsent(entityComponents, entityClass, () => new Map());
14
- componentSet.set(componentClass, propertyKey);
15
- };
16
- export const signalHandlers = new Map();
17
- export const OnSignal = (id) => (target, propertyKey, descriptor) => {
18
- if (target instanceof Function) {
19
- throw new Error('@OnSignal annotation only allowed on instance members.');
20
- }
21
- let mappingList = putIfAbsent(signalHandlers, target.constructor, () => []);
22
- mappingList.push([propertyKey, id]);
23
- };
24
- const getComponentDependencies = (system) => {
25
- const dependencies = Injector.dependencyMap.get(system);
26
- return dependencies
27
- ? dependencies.filter((dependency) => dependency.kind === 'component')
28
- : [];
29
- };
30
- const getEntityClassesForComponentDependencies = (componentTypes) => {
31
- const result = [];
32
- for (const [entityClass, componentMap] of entityComponents) {
33
- let allDependenciesMet = true;
34
- for (const componentType of componentTypes) {
35
- if (!componentMap.has(componentType)) {
36
- allDependenciesMet = false;
37
- break;
38
- }
39
- }
40
- if (allDependenciesMet) {
41
- result.push(entityClass);
42
- }
43
- }
44
- return result;
45
- };
46
- const componentResolver = (context, dependency) => {
47
- const kind = context.kind;
48
- const type = context.type;
49
- if (kind !== 'system') {
50
- throw new Error(`Could not resolve Component ${type.name}. @GetComponent only allowed in system scope.`);
51
- }
52
- const entityClass = context.entityClass;
53
- const key = entityComponents.get(entityClass).get(dependency.type);
54
- return (entity) => entity[key];
55
- };
56
- const entityResolver = ({ type, kind }, _dependency) => {
57
- if (kind !== 'system') {
58
- throw new Error(`Could not resolve Entity in ${type.name}. @GetEntity only allowed in system scope.`);
59
- }
60
- return (entity) => entity;
61
- };
62
- export class EcsInjector extends Injector {
63
- constructor(parent) {
64
- super(parent);
65
- this.signalMap = parent ? parent.signalMap : new Map();
66
- this.entitySystemMap = parent ? parent.entitySystemMap : new Map();
67
- this.entitySystemResolverTuples = parent ? parent.entitySystemResolverTuples : new Map();
68
- if (!parent) {
69
- this.addExtensionResolver('entity', entityResolver);
70
- this.addExtensionResolver('component', componentResolver);
71
- const signalResolver = ({ kind }, dependency) => {
72
- const signal = putIfAbsent(this.signalMap, dependency.id, () => new Signal());
73
- return (entity) => signal;
74
- };
75
- this.addExtensionResolver('signal', signalResolver);
76
- }
77
- }
78
- registerSystem(systemClass) {
79
- const componentDependencies = getComponentDependencies(systemClass).map(dependency => dependency.type);
80
- if (componentDependencies.length === 0) {
81
- throw new Error(`${systemClass.name} needs at least one component dependency.`);
82
- }
83
- const entityClasses = getEntityClassesForComponentDependencies(componentDependencies);
84
- if (entityClasses.length === 0) {
85
- console.warn(`System '${systemClass.name}' has no matching entities.`);
86
- return;
87
- }
88
- for (let entityClass of entityClasses) {
89
- const systemClasses = putIfAbsent(this.entitySystemMap, entityClass, () => []);
90
- systemClasses.push(systemClass);
91
- }
92
- }
93
- createSystems(entity) {
94
- const systemResolverTuples = putIfAbsent(this.entitySystemResolverTuples, entity.constructor, () => {
95
- const systems = this.entitySystemMap.get(entity.constructor);
96
- if (!systems) {
97
- console.warn('no system for entity ' + entity.constructor.name);
98
- return [];
99
- }
100
- const result = [];
101
- for (const systemClass of systems) {
102
- result.push([systemClass, this.createResolverArray({ type: systemClass, kind: 'system', entityClass: entity.constructor })]);
103
- }
104
- return result;
105
- });
106
- const systemInstances = [];
107
- for (const [system, resolver] of systemResolverTuples) {
108
- const args = new Array(resolver.length);
109
- for (let i = 0; i < args.length; i++) {
110
- args[i] = resolver[i](entity);
111
- }
112
- let systemInstance = new system(...args);
113
- systemInstances.push(systemInstance);
114
- }
115
- return systemInstances;
116
- }
117
- getSignal(id) {
118
- return putIfAbsent(this.signalMap, id, () => new Signal());
119
- }
120
- }
1
+ import { createDependencyAnnotation, Injector, putIfAbsent } from 'mani-injector';
2
+ import { Signal } from 'mani-signal';
3
+ import { SystemContext } from './systemContext';
4
+ export const entityComponents = new Map();
5
+ export const GetComponent = createDependencyAnnotation((type, index) => ({ kind: 'component', type, index }));
6
+ export const GetEntity = createDependencyAnnotation((_type, index) => ({ kind: 'entity', index }));
7
+ export const GetContext = createDependencyAnnotation((_type, index) => ({ kind: 'context', index }));
8
+ export const GetSignal = (id) => createDependencyAnnotation((_type, index) => ({ kind: 'signal', index, id }));
9
+ export const EntityComponent = (target, propertyKey) => {
10
+ const entityClass = target.constructor;
11
+ const componentClass = Reflect.getMetadata('design:type', target, propertyKey);
12
+ if (componentClass === Object) {
13
+ throw new Error(`Object component type not allowed. Forgot to specify type of ${entityClass.name}.${propertyKey}?`);
14
+ }
15
+ const componentSet = putIfAbsent(entityComponents, entityClass, () => new Map());
16
+ componentSet.set(componentClass, propertyKey);
17
+ };
18
+ export const signalHandlers = new Map();
19
+ export const staticSignalHandlers = new Map();
20
+ export const OnSignal = (id) => (target, propertyKey, descriptor) => {
21
+ if (target instanceof Function) {
22
+ let mappingList = putIfAbsent(staticSignalHandlers, target, () => []);
23
+ mappingList.push([propertyKey, id]);
24
+ }
25
+ else {
26
+ let mappingList = putIfAbsent(signalHandlers, target.constructor, () => []);
27
+ mappingList.push([propertyKey, id]);
28
+ }
29
+ };
30
+ const getComponentDependencies = (system) => {
31
+ const dependencies = Injector.dependencyMap.get(system);
32
+ return dependencies
33
+ ? dependencies.filter((dependency) => dependency.kind === 'component')
34
+ : [];
35
+ };
36
+ const getEntityClassesForComponentDependencies = (componentTypes) => {
37
+ const result = [];
38
+ for (const [entityClass, componentMap] of entityComponents) {
39
+ let allDependenciesMet = true;
40
+ for (const componentType of componentTypes) {
41
+ if (!componentMap.has(componentType)) {
42
+ allDependenciesMet = false;
43
+ break;
44
+ }
45
+ }
46
+ if (allDependenciesMet) {
47
+ result.push(entityClass);
48
+ }
49
+ }
50
+ return result;
51
+ };
52
+ const componentResolver = (context, dependency) => {
53
+ const kind = context.kind;
54
+ const type = context.type;
55
+ if (kind !== 'system') {
56
+ throw new Error(`Could not resolve Component ${type.name}. @GetComponent only allowed in system scope.`);
57
+ }
58
+ const entityClass = context.entityClass;
59
+ const key = entityComponents.get(entityClass).get(dependency.type);
60
+ return (context) => context.entity[key];
61
+ };
62
+ const entityResolver = ({ type, kind }, _dependency) => {
63
+ if (kind !== 'system') {
64
+ throw new Error(`Could not resolve Entity in ${type.name}. @GetEntity only allowed in system scope.`);
65
+ }
66
+ return (context) => context.entity;
67
+ };
68
+ const contextResolver = ({ type, kind }, _dependency) => {
69
+ if (kind !== 'system') {
70
+ throw new Error(`Could not resolve Context in ${type.name}. @GetContext only allowed in system scope.`);
71
+ }
72
+ return (context) => context;
73
+ };
74
+ export class EcsInjector extends Injector {
75
+ constructor(parent) {
76
+ super(parent);
77
+ this.signalMap = parent ? parent.signalMap : new Map();
78
+ this.entitySystemMap = new Map();
79
+ this.entitySystemResolverTuples = new Map();
80
+ this.map(EcsInjector).toValue(this);
81
+ if (!parent) {
82
+ this.addExtensionResolver('entity', entityResolver);
83
+ this.addExtensionResolver('component', componentResolver);
84
+ this.addExtensionResolver('context', contextResolver);
85
+ const signalResolver = ({ kind }, dependency) => {
86
+ const signal = putIfAbsent(this.signalMap, dependency.id, () => new Signal());
87
+ return (entity) => signal;
88
+ };
89
+ this.addExtensionResolver('signal', signalResolver);
90
+ }
91
+ }
92
+ registerSystem(systemClass) {
93
+ const componentDependencies = getComponentDependencies(systemClass).map(dependency => dependency.type);
94
+ if (componentDependencies.length === 0) {
95
+ throw new Error(`${systemClass.name} needs at least one component dependency.`);
96
+ }
97
+ const entityClasses = getEntityClassesForComponentDependencies(componentDependencies);
98
+ if (entityClasses.length === 0) {
99
+ console.warn(`System '${systemClass.name}' has no matching entities.`);
100
+ return;
101
+ }
102
+ for (let entityClass of entityClasses) {
103
+ const systemClasses = putIfAbsent(this.entitySystemMap, entityClass, () => []);
104
+ systemClasses.push(systemClass);
105
+ }
106
+ }
107
+ createSystems(entity) {
108
+ const systemResolverTuples = putIfAbsent(this.entitySystemResolverTuples, entity.constructor, () => {
109
+ const systems = this.entitySystemMap.get(entity.constructor);
110
+ if (!systems) {
111
+ return [];
112
+ }
113
+ const result = [];
114
+ for (const systemClass of systems) {
115
+ result.push([systemClass, this.createResolverArray({ type: systemClass, kind: 'system', entityClass: entity.constructor })]);
116
+ }
117
+ return result;
118
+ });
119
+ const systemInstances = [];
120
+ for (const [system, resolver] of systemResolverTuples) {
121
+ const args = new Array(resolver.length);
122
+ const systemContext = new SystemContext(entity);
123
+ for (let i = 0; i < args.length; i++) {
124
+ args[i] = resolver[i](systemContext);
125
+ }
126
+ systemContext.system = new system(...args);
127
+ systemInstances.push(systemContext);
128
+ }
129
+ return systemInstances;
130
+ }
131
+ getSignal(id) {
132
+ return putIfAbsent(this.signalMap, id, () => new Signal());
133
+ }
134
+ dispose() {
135
+ for (const [key, signal] of this.signalMap) {
136
+ signal.detachAll();
137
+ }
138
+ }
139
+ }
121
140
  //# sourceMappingURL=ecsInjector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ecsInjector.js","sourceRoot":"","sources":["../src/ecsInjector.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,0BAA0B,EAAkB,QAAQ,EAAE,WAAW,EAAoC,MAAM,eAAe,CAAC;AAC1I,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAYnC,MAAM,CAAC,MAA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CHANGED
@@ -1,22 +1,23 @@
1
- import { Signal } from 'mani-signal';
2
- import { Class } from './types';
3
- export declare class Entity {
4
- readonly id: number;
5
- children: Set<Entity>;
6
- private gameEngine?;
7
- private _parent?;
8
- readonly parentChanged: Signal<any>;
9
- readonly onRemove: Signal<any>;
10
- private markRemoval;
11
- constructor();
12
- onBeforeRemove?(): Promise<void>;
13
- private setParent;
14
- readonly parent: Entity | undefined;
15
- getComponent<T extends Class>(componentClass: T): InstanceType<T> | undefined;
16
- add(entity: Entity): Promise<void>;
17
- remove(entity: Entity): void;
18
- detach(): Promise<void>;
19
- has(entity: Entity): boolean;
20
- toString(): string;
21
- getAllChildren(target?: Entity[]): Entity[];
22
- }
1
+ import { Signal } from 'mani-signal';
2
+ import { Class } from './types';
3
+ export declare class Entity {
4
+ readonly id: number;
5
+ readonly children: Set<Entity>;
6
+ private gameEngine?;
7
+ private _parent?;
8
+ readonly parentChanged: Signal<unknown>;
9
+ readonly onRemove: Signal<unknown>;
10
+ private markRemoval;
11
+ private _detached;
12
+ get detached(): boolean;
13
+ constructor();
14
+ onBeforeRemove?(): Promise<void>;
15
+ private setParent;
16
+ get parent(): Entity | undefined;
17
+ getComponent<T extends Class>(componentClass: T): InstanceType<T> | undefined;
18
+ add(entity: Entity): Promise<void>;
19
+ remove(entity: Entity): Promise<void>;
20
+ detach(): Promise<void>;
21
+ has(entity: Entity): boolean;
22
+ getAllEntities(target?: Entity[]): Entity[];
23
+ }
package/lib/entity.js CHANGED
@@ -1,84 +1,92 @@
1
- import { Signal } from 'mani-signal';
2
- import { entityComponents } from './ecsInjector';
3
- let idCounter = 0;
4
- export class Entity {
5
- constructor() {
6
- this.children = new Set();
7
- this.parentChanged = new Signal();
8
- this.onRemove = new Signal();
9
- this.markRemoval = false;
10
- this.id = idCounter++;
11
- }
12
- setParent(parent) {
13
- if (parent === this._parent) {
14
- throw Error('same parent');
15
- }
16
- this._parent = parent;
17
- this.parentChanged.dispatch();
18
- }
19
- get parent() {
20
- return this._parent;
21
- }
22
- getComponent(componentClass) {
23
- const componentMap = entityComponents.get(this.constructor);
24
- if (!componentMap) {
25
- throw new Error(`No components in entity of type '${this.constructor.name}'.`);
26
- }
27
- const key = componentMap.get(componentClass);
28
- return key && this[key];
29
- }
30
- async add(entity) {
31
- if (entity.parent === this) {
32
- throw new Error('Entity is already a child');
33
- }
34
- if (entity === this) {
35
- throw new Error('Could not add Entity as a child of itself.');
36
- }
37
- if (entity.parent) {
38
- entity.parent.children.delete(entity);
39
- }
40
- this.children.add(entity);
41
- entity.setParent(this);
42
- if (entity.gameEngine) {
43
- if (this.gameEngine !== entity.gameEngine) {
44
- throw new Error('cant add an active to a passive entity');
45
- }
46
- }
47
- else {
48
- if (this.gameEngine) {
49
- await this.gameEngine.addEntity(entity);
50
- }
51
- }
52
- if (this.gameEngine && this.gameEngine !== entity.gameEngine) {
53
- }
54
- }
55
- remove(entity) {
56
- if (!this.children.delete(entity)) {
57
- throw new Error('Could not remove. Entity is not a child.');
58
- }
59
- entity.setParent(undefined);
60
- }
61
- async detach() {
62
- if (!this.gameEngine) {
63
- throw new Error('Could not detach passive entity.');
64
- }
65
- if (this.parent) {
66
- this.parent.remove(this);
67
- }
68
- await this.gameEngine.removeEntity(this);
69
- }
70
- has(entity) {
71
- return this.children.has(entity);
72
- }
73
- toString() {
74
- return 'Deine Vater';
75
- }
76
- getAllChildren(target = []) {
77
- target.push(this);
78
- for (const child of this.children) {
79
- child.getAllChildren(target);
80
- }
81
- return target;
82
- }
83
- }
1
+ import { Signal } from 'mani-signal';
2
+ import { entityComponents } from './ecsInjector';
3
+ let idCounter = 0;
4
+ export class Entity {
5
+ constructor() {
6
+ this.children = new Set();
7
+ this.parentChanged = new Signal();
8
+ this.onRemove = new Signal();
9
+ this.markRemoval = false;
10
+ this._detached = false;
11
+ this.id = idCounter++;
12
+ }
13
+ get detached() { return this._detached; }
14
+ setParent(parent) {
15
+ if (parent === this._parent) {
16
+ throw Error('same parent');
17
+ }
18
+ this._parent = parent;
19
+ this.parentChanged.dispatch();
20
+ }
21
+ get parent() {
22
+ return this._parent;
23
+ }
24
+ getComponent(componentClass) {
25
+ const componentMap = entityComponents.get(this.constructor);
26
+ if (!componentMap) {
27
+ throw new Error(`No components in entity of type '${this.constructor.name}'.`);
28
+ }
29
+ const key = componentMap.get(componentClass);
30
+ return key && this[key];
31
+ }
32
+ async add(entity) {
33
+ if (entity.parent === this) {
34
+ throw new Error('Entity is already a child');
35
+ }
36
+ if (entity === this) {
37
+ throw new Error('Could not add Entity as a child of itself.');
38
+ }
39
+ if (entity.parent) {
40
+ entity.parent.children.delete(entity);
41
+ }
42
+ this.children.add(entity);
43
+ entity.setParent(this);
44
+ if (entity.gameEngine) {
45
+ if (this.gameEngine !== entity.gameEngine) {
46
+ throw new Error('cant add an active to a passive entity');
47
+ }
48
+ }
49
+ else {
50
+ if (this.gameEngine) {
51
+ await this.gameEngine.add(entity);
52
+ }
53
+ }
54
+ if (this.gameEngine && this.gameEngine !== entity.gameEngine) {
55
+ }
56
+ }
57
+ async remove(entity) {
58
+ if (!this.children.delete(entity)) {
59
+ throw new Error('Could not remove. Entity is not a child.');
60
+ }
61
+ entity.setParent(undefined);
62
+ if (this.gameEngine) {
63
+ return await this.gameEngine.remove(entity);
64
+ }
65
+ }
66
+ async detach() {
67
+ if (this._detached) {
68
+ throw new Error('entity already detached');
69
+ }
70
+ this._detached = true;
71
+ if (this.parent) {
72
+ await this.parent.remove(this);
73
+ }
74
+ else {
75
+ if (!this.gameEngine) {
76
+ throw new Error('entity isn\'t attached to a parent or the game engine');
77
+ }
78
+ await this.gameEngine.remove(this);
79
+ }
80
+ }
81
+ has(entity) {
82
+ return this.children.has(entity);
83
+ }
84
+ getAllEntities(target = []) {
85
+ target.push(this);
86
+ for (const child of this.children) {
87
+ child.getAllEntities(target);
88
+ }
89
+ return target;
90
+ }
91
+ }
84
92
  //# sourceMappingURL=entity.js.map
package/lib/entity.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,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