mani-game-engine 1.0.0-pre.34 → 1.0.0-pre.36
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/LICENSE +21 -21
- package/README.md +69 -69
- package/lib/clock.d.ts +55 -55
- package/lib/clock.js +117 -117
- package/lib/ecsInjector.d.ts +28 -27
- package/lib/ecsInjector.js +169 -149
- package/lib/ecsInjector.js.map +1 -1
- package/lib/entity.d.ts +26 -23
- package/lib/entity.js +101 -95
- package/lib/entity.js.map +1 -1
- package/lib/gameEngine.d.ts +83 -83
- package/lib/gameEngine.js +340 -340
- package/lib/gameEngine.js.map +1 -1
- package/lib/index.d.ts +12 -12
- package/lib/index.js +34 -32
- package/lib/index.js.map +1 -1
- package/lib/injector.d.ts +121 -121
- package/lib/injector.js +289 -289
- package/lib/scope/scopeContext.d.ts +57 -57
- package/lib/scope/scopeContext.js +254 -254
- package/lib/scope/scopeContext.js.map +1 -1
- package/lib/systemContext.d.ts +14 -12
- package/lib/systemContext.js +35 -23
- package/lib/systemContext.js.map +1 -1
- package/lib/types.d.ts +73 -73
- package/lib/types.js +17 -17
- package/lib/utils/map2k.d.ts +6 -6
- package/lib/utils/map2k.js +43 -43
- package/package.json +39 -39
- package/src/clock.ts +163 -163
- package/src/ecsInjector.ts +212 -189
- package/src/entity.ts +131 -123
- package/src/gameEngine.ts +433 -433
- package/src/index.ts +32 -32
- package/src/injector.ts +363 -363
- package/src/scope/scopeContext.ts +322 -320
- package/src/systemContext.ts +37 -27
- package/src/types.ts +87 -87
- package/src/utils/map2k.ts +52 -52
package/lib/ecsInjector.js
CHANGED
|
@@ -1,150 +1,170 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EcsInjector = exports.OnSignal = exports.staticSignalHandlers = exports.signalHandlers = exports.EntityComponent = exports.GetSignal = exports.GetContext = exports.GetEntity = exports.GetComponent = exports.entityComponents = void 0;
|
|
4
|
-
const mani_signal_1 = require("mani-signal");
|
|
5
|
-
const injector_1 = require("./injector");
|
|
6
|
-
const systemContext_1 = require("./systemContext");
|
|
7
|
-
exports.entityComponents = new Map();
|
|
8
|
-
exports.GetComponent = (0, injector_1.createDependencyAnnotation)((type, index) => ({ kind: 'component', type, index }));
|
|
9
|
-
exports.GetEntity = (0, injector_1.createDependencyAnnotation)((_type, index) => ({ kind: 'entity', index }));
|
|
10
|
-
exports.GetContext = (0, injector_1.createDependencyAnnotation)((_type, index) => ({ kind: 'context', index }));
|
|
11
|
-
const GetSignal = (id) => (0, injector_1.createDependencyAnnotation)((_type, index) => ({ kind: 'signal', index, id }));
|
|
12
|
-
exports.GetSignal = GetSignal;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return (context) => context.entity;
|
|
73
|
-
};
|
|
74
|
-
const
|
|
75
|
-
if (kind !== 'system') {
|
|
76
|
-
throw new Error(`Could not resolve
|
|
77
|
-
}
|
|
78
|
-
return (context) => context;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EcsInjector = exports.OnSignal = exports.staticSignalHandlers = exports.signalHandlers = exports.EntityComponent = exports.GetEntitySignal = exports.GetSignal = exports.GetContext = exports.GetEntity = exports.GetComponent = exports.entityComponents = void 0;
|
|
4
|
+
const mani_signal_1 = require("mani-signal");
|
|
5
|
+
const injector_1 = require("./injector");
|
|
6
|
+
const systemContext_1 = require("./systemContext");
|
|
7
|
+
exports.entityComponents = new Map();
|
|
8
|
+
exports.GetComponent = (0, injector_1.createDependencyAnnotation)((type, index) => ({ kind: 'component', type, index }));
|
|
9
|
+
exports.GetEntity = (0, injector_1.createDependencyAnnotation)((_type, index) => ({ kind: 'entity', index }));
|
|
10
|
+
exports.GetContext = (0, injector_1.createDependencyAnnotation)((_type, index) => ({ kind: 'context', index }));
|
|
11
|
+
const GetSignal = (id) => (0, injector_1.createDependencyAnnotation)((_type, index) => ({ kind: 'signal', index, id }));
|
|
12
|
+
exports.GetSignal = GetSignal;
|
|
13
|
+
const GetEntitySignal = (id) => (0, injector_1.createDependencyAnnotation)((_type, index) => ({
|
|
14
|
+
kind: 'entitySignal',
|
|
15
|
+
index,
|
|
16
|
+
id,
|
|
17
|
+
}));
|
|
18
|
+
exports.GetEntitySignal = GetEntitySignal;
|
|
19
|
+
const EntityComponent = (target, propertyKey) => {
|
|
20
|
+
const entityClass = target.constructor;
|
|
21
|
+
const componentClass = Reflect.getMetadata('design:type', target, propertyKey);
|
|
22
|
+
if (componentClass === Object) {
|
|
23
|
+
throw new Error(`Object component type not allowed. Forgot to specify type of ${entityClass.name}.${propertyKey}?`);
|
|
24
|
+
}
|
|
25
|
+
const componentSet = (0, injector_1.putIfAbsent)(exports.entityComponents, entityClass, () => new Map());
|
|
26
|
+
componentSet.set(componentClass, propertyKey);
|
|
27
|
+
};
|
|
28
|
+
exports.EntityComponent = EntityComponent;
|
|
29
|
+
exports.signalHandlers = new Map();
|
|
30
|
+
exports.staticSignalHandlers = new Map();
|
|
31
|
+
const OnSignal = (id) => (target, propertyKey, descriptor) => {
|
|
32
|
+
if (target instanceof Function) {
|
|
33
|
+
let mappingList = (0, injector_1.putIfAbsent)(exports.staticSignalHandlers, target, () => []);
|
|
34
|
+
mappingList.push([propertyKey, id]);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
let mappingList = (0, injector_1.putIfAbsent)(exports.signalHandlers, target.constructor, () => []);
|
|
38
|
+
mappingList.push([propertyKey, id]);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.OnSignal = OnSignal;
|
|
42
|
+
const getComponentDependencies = (system) => {
|
|
43
|
+
const dependencies = injector_1.Injector.dependencyMap.get(system);
|
|
44
|
+
return dependencies
|
|
45
|
+
? dependencies.filter((dependency) => dependency.kind === 'component')
|
|
46
|
+
: [];
|
|
47
|
+
};
|
|
48
|
+
const getEntityClassesForComponentDependencies = (componentTypes) => {
|
|
49
|
+
const result = [];
|
|
50
|
+
for (const [entityClass, componentMap] of exports.entityComponents) {
|
|
51
|
+
let allDependenciesMet = true;
|
|
52
|
+
for (const componentType of componentTypes) {
|
|
53
|
+
if (!componentMap.has(componentType)) {
|
|
54
|
+
allDependenciesMet = false;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (allDependenciesMet) {
|
|
59
|
+
result.push(entityClass);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
const componentResolver = (context, dependency) => {
|
|
65
|
+
const kind = context.kind;
|
|
66
|
+
const type = context.type;
|
|
67
|
+
if (kind !== 'system') {
|
|
68
|
+
throw new Error(`Could not resolve Component ${type.name}. @GetComponent only allowed in system scope.`);
|
|
69
|
+
}
|
|
70
|
+
const entityClass = context.entityClass;
|
|
71
|
+
const key = exports.entityComponents.get(entityClass).get(dependency.type);
|
|
72
|
+
return (context) => context.entity[key];
|
|
73
|
+
};
|
|
74
|
+
const entityResolver = ({ type, kind }, _dependency) => {
|
|
75
|
+
if (kind !== 'system') {
|
|
76
|
+
throw new Error(`Could not resolve Entity in ${type.name}. @GetEntity only allowed in system scope.`);
|
|
77
|
+
}
|
|
78
|
+
return (context) => context.entity;
|
|
79
|
+
};
|
|
80
|
+
const entitySignalResolver = ({ type, kind }, dependency) => {
|
|
81
|
+
if (kind !== 'system') {
|
|
82
|
+
throw new Error(`Could not resolve Entity in ${type.name}. @GetEntity only allowed in system scope.`);
|
|
83
|
+
}
|
|
84
|
+
return (context) => context.entity.getSignal(dependency.id);
|
|
85
|
+
};
|
|
86
|
+
const contextResolver = ({ type, kind }, _dependency) => {
|
|
87
|
+
if (kind !== 'system') {
|
|
88
|
+
throw new Error(`Could not resolve Context in ${type.name}. @GetContext only allowed in system scope.`);
|
|
89
|
+
}
|
|
90
|
+
return (context) => context;
|
|
91
|
+
};
|
|
92
|
+
class EcsInjector extends injector_1.Injector {
|
|
93
|
+
constructor(parent) {
|
|
94
|
+
super(parent);
|
|
95
|
+
this.signalMap = parent ? parent.signalMap : new Map();
|
|
96
|
+
this.entitySystemMap = new Map();
|
|
97
|
+
this.entitySystemResolverTuples = new Map();
|
|
98
|
+
this.map(EcsInjector).toValue(this);
|
|
99
|
+
if (!parent) {
|
|
100
|
+
this.addExtensionResolver('entity', entityResolver);
|
|
101
|
+
this.addExtensionResolver('component', componentResolver);
|
|
102
|
+
this.addExtensionResolver('context', contextResolver);
|
|
103
|
+
const signalResolver = ({ kind }, dependency) => {
|
|
104
|
+
const signal = (0, injector_1.putIfAbsent)(this.signalMap, dependency.id, () => new mani_signal_1.Signal());
|
|
105
|
+
return (entity) => signal;
|
|
106
|
+
};
|
|
107
|
+
this.addExtensionResolver('signal', signalResolver);
|
|
108
|
+
this.addExtensionResolver('entitySignal', entitySignalResolver);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
newSignalScope() {
|
|
112
|
+
this.signalMap = new Map();
|
|
113
|
+
}
|
|
114
|
+
registerSystem(systemClass) {
|
|
115
|
+
const componentDependencies = getComponentDependencies(systemClass).map(dependency => dependency.type);
|
|
116
|
+
if (componentDependencies.length === 0) {
|
|
117
|
+
throw new Error(`${systemClass.name} needs at least one component dependency.`);
|
|
118
|
+
}
|
|
119
|
+
const entityClasses = getEntityClassesForComponentDependencies(componentDependencies);
|
|
120
|
+
if (entityClasses.length === 0) {
|
|
121
|
+
console.warn(`System '${systemClass.name}' has no matching entities.`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
for (let entityClass of entityClasses) {
|
|
125
|
+
const systemClasses = (0, injector_1.putIfAbsent)(this.entitySystemMap, entityClass, () => []);
|
|
126
|
+
systemClasses.push(systemClass);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
createSystems(entity) {
|
|
130
|
+
const systemResolverTuples = (0, injector_1.putIfAbsent)(this.entitySystemResolverTuples, entity.constructor, () => {
|
|
131
|
+
const systems = this.entitySystemMap.get(entity.constructor);
|
|
132
|
+
if (!systems) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const result = [];
|
|
136
|
+
for (const systemClass of systems) {
|
|
137
|
+
result.push([systemClass, this.createResolverArray({ type: systemClass, kind: 'system', entityClass: entity.constructor })]);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
});
|
|
141
|
+
const systemInstances = [];
|
|
142
|
+
for (const [system, resolver] of systemResolverTuples) {
|
|
143
|
+
const args = new Array(resolver.length);
|
|
144
|
+
const systemContext = new systemContext_1.SystemContext(entity);
|
|
145
|
+
for (let i = 0; i < args.length; i++) {
|
|
146
|
+
args[i] = resolver[i](systemContext);
|
|
147
|
+
}
|
|
148
|
+
const newSystem = new system(...args);
|
|
149
|
+
const entitySignals = systemContext_1.entitySignalHandlers.get(system);
|
|
150
|
+
if (entitySignals === null || entitySignals === void 0 ? void 0 : entitySignals.length) {
|
|
151
|
+
for (const [propertyKey, id] of entitySignals) {
|
|
152
|
+
entity.getSignal(id).add(newSystem[propertyKey], newSystem);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
systemContext.system = newSystem;
|
|
156
|
+
systemInstances.push(systemContext);
|
|
157
|
+
}
|
|
158
|
+
return systemInstances;
|
|
159
|
+
}
|
|
160
|
+
getSignal(id) {
|
|
161
|
+
return (0, injector_1.putIfAbsent)(this.signalMap, id, () => new mani_signal_1.Signal());
|
|
162
|
+
}
|
|
163
|
+
dispose() {
|
|
164
|
+
for (const [key, signal] of this.signalMap) {
|
|
165
|
+
signal.detachAll();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.EcsInjector = EcsInjector;
|
|
150
170
|
//# sourceMappingURL=ecsInjector.js.map
|
package/lib/ecsInjector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecsInjector.js","sourceRoot":"","sources":["../src/ecsInjector.ts"],"names":[],"mappings":";;;AACA,6CAAmC;AACnC,yCAAuI;AACvI,
|
|
1
|
+
{"version":3,"file":"ecsInjector.js","sourceRoot":"","sources":["../src/ecsInjector.ts"],"names":[],"mappings":";;;AACA,6CAAmC;AACnC,yCAAuI;AACvI,mDAAoE;AAevD,QAAA,gBAAgB,GAAG,IAAI,GAAG,EAA4C,CAAC;AAEvE,QAAA,YAAY,GAAG,IAAA,qCAA0B,EAAC,CAAC,IAAI,EAAE,KAAK,EAAuB,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC;AACpH,QAAA,SAAS,GAAG,IAAA,qCAA0B,EAAC,CAAC,KAAK,EAAE,KAAK,EAAoB,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC;AACtG,QAAA,UAAU,GAAG,IAAA,qCAA0B,EAAC,CAAC,KAAK,EAAE,KAAK,EAAqB,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC;AAC/G,MAAM,SAAS,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,IAAA,qCAA0B,EAAC,CAAC,KAAK,EAAE,KAAK,EAAoB,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC;AAAtH,QAAA,SAAS,aAA6G;AA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;IACL,CAAC;CACJ;AArGD,kCAqGC"}
|
package/lib/entity.d.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import { Signal } from 'mani-signal';
|
|
2
|
-
import { Class } from './types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { Signal } from 'mani-signal';
|
|
2
|
+
import { Class } from './types';
|
|
3
|
+
import { ID } from './injector';
|
|
4
|
+
export declare class Entity {
|
|
5
|
+
readonly id: number;
|
|
6
|
+
readonly children: Set<Entity>;
|
|
7
|
+
private gameEngine?;
|
|
8
|
+
private _parent?;
|
|
9
|
+
readonly parentChanged: Signal<unknown>;
|
|
10
|
+
readonly onRemove: Signal<unknown>;
|
|
11
|
+
private markRemoval;
|
|
12
|
+
private _detached;
|
|
13
|
+
private readonly signalMap;
|
|
14
|
+
get detached(): boolean;
|
|
15
|
+
constructor();
|
|
16
|
+
onBeforeRemove?(): Promise<void>;
|
|
17
|
+
getSignal<T>(id: ID): Signal<T>;
|
|
18
|
+
private setParent;
|
|
19
|
+
get parent(): Entity | undefined;
|
|
20
|
+
getComponent<T extends Class>(componentClass: T): InstanceType<T> | undefined;
|
|
21
|
+
add(entity: Entity): Promise<void>;
|
|
22
|
+
remove(entity: Entity): Promise<void>;
|
|
23
|
+
detach(): Promise<void>;
|
|
24
|
+
has(entity: Entity): boolean;
|
|
25
|
+
getAllEntities(target?: Entity[]): Entity[];
|
|
26
|
+
}
|
package/lib/entity.js
CHANGED
|
@@ -1,96 +1,102 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Entity = void 0;
|
|
4
|
-
const mani_signal_1 = require("mani-signal");
|
|
5
|
-
const ecsInjector_1 = require("./ecsInjector");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (entity.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (this.gameEngine) {
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (this.
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
await this.
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Entity = void 0;
|
|
4
|
+
const mani_signal_1 = require("mani-signal");
|
|
5
|
+
const ecsInjector_1 = require("./ecsInjector");
|
|
6
|
+
const injector_1 = require("./injector");
|
|
7
|
+
let idCounter = 0;
|
|
8
|
+
class Entity {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.children = new Set();
|
|
11
|
+
this.parentChanged = new mani_signal_1.Signal();
|
|
12
|
+
this.onRemove = new mani_signal_1.Signal();
|
|
13
|
+
this.markRemoval = false;
|
|
14
|
+
this._detached = false;
|
|
15
|
+
this.signalMap = new Map();
|
|
16
|
+
this.id = idCounter++;
|
|
17
|
+
}
|
|
18
|
+
get detached() { return this._detached; }
|
|
19
|
+
getSignal(id) {
|
|
20
|
+
return (0, injector_1.putIfAbsent)(this.signalMap, id, () => new mani_signal_1.Signal());
|
|
21
|
+
}
|
|
22
|
+
setParent(parent) {
|
|
23
|
+
if (parent === this._parent) {
|
|
24
|
+
throw Error('same parent');
|
|
25
|
+
}
|
|
26
|
+
this._parent = parent;
|
|
27
|
+
this.parentChanged.dispatch();
|
|
28
|
+
}
|
|
29
|
+
get parent() {
|
|
30
|
+
return this._parent;
|
|
31
|
+
}
|
|
32
|
+
getComponent(componentClass) {
|
|
33
|
+
const componentMap = ecsInjector_1.entityComponents.get(this.constructor);
|
|
34
|
+
if (!componentMap) {
|
|
35
|
+
throw new Error(`No components in entity of type '${this.constructor.name}'.`);
|
|
36
|
+
}
|
|
37
|
+
const key = componentMap.get(componentClass);
|
|
38
|
+
return key && this[key];
|
|
39
|
+
}
|
|
40
|
+
async add(entity) {
|
|
41
|
+
if (entity.parent === this) {
|
|
42
|
+
throw new Error('Entity is already a child');
|
|
43
|
+
}
|
|
44
|
+
if (entity === this) {
|
|
45
|
+
throw new Error('Could not add Entity as a child of itself.');
|
|
46
|
+
}
|
|
47
|
+
if (entity.parent) {
|
|
48
|
+
entity.parent.children.delete(entity);
|
|
49
|
+
}
|
|
50
|
+
this.children.add(entity);
|
|
51
|
+
entity.setParent(this);
|
|
52
|
+
if (entity.gameEngine) {
|
|
53
|
+
if (this.gameEngine !== entity.gameEngine) {
|
|
54
|
+
throw new Error('cant add an active to a passive entity');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (this.gameEngine) {
|
|
59
|
+
await this.gameEngine.add(entity);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (this.gameEngine && this.gameEngine !== entity.gameEngine) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async remove(entity) {
|
|
66
|
+
if (!this.children.delete(entity)) {
|
|
67
|
+
throw new Error('Could not remove. Entity is not a child.');
|
|
68
|
+
}
|
|
69
|
+
entity.setParent(undefined);
|
|
70
|
+
if (this.gameEngine) {
|
|
71
|
+
return await this.gameEngine.remove(entity);
|
|
72
|
+
}
|
|
73
|
+
this.signalMap.forEach(signal => signal.detachAll());
|
|
74
|
+
}
|
|
75
|
+
async detach() {
|
|
76
|
+
if (this._detached) {
|
|
77
|
+
throw new Error('entity already detached');
|
|
78
|
+
}
|
|
79
|
+
this._detached = true;
|
|
80
|
+
if (this.parent) {
|
|
81
|
+
await this.parent.remove(this);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (!this.gameEngine) {
|
|
85
|
+
throw new Error('entity isn\'t attached to a parent or the game engine');
|
|
86
|
+
}
|
|
87
|
+
await this.gameEngine.remove(this);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
has(entity) {
|
|
91
|
+
return this.children.has(entity);
|
|
92
|
+
}
|
|
93
|
+
getAllEntities(target = []) {
|
|
94
|
+
target.push(this);
|
|
95
|
+
for (const child of this.children) {
|
|
96
|
+
child.getAllEntities(target);
|
|
97
|
+
}
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.Entity = Entity;
|
|
96
102
|
//# sourceMappingURL=entity.js.map
|
package/lib/entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":";;;AACA,6CAAmC;AAEnC,+CAA+C;
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":";;;AACA,6CAAmC;AAEnC,+CAA+C;AAC/C,yCAA2C;AAE3C,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,MAAa,MAAM;IAgBf;QAbS,aAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QAK7B,kBAAa,GAAG,IAAI,oBAAM,EAAE,CAAC;QAC7B,aAAQ,GAAG,IAAI,oBAAM,EAAE,CAAC;QACzB,gBAAW,GAAG,KAAK,CAAC;QACpB,cAAS,GAAG,KAAK,CAAC;QACT,cAAS,GAAoB,IAAI,GAAG,EAAc,CAAC;QAKhE,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC;IAC1B,CAAC;IAJD,IAAI,QAAQ,KAAc,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAQlD,SAAS,CAAI,EAAM;QACf,OAAO,IAAA,sBAAW,EAAC,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,oBAAM,EAAO,CAAC,CAAC;IACpE,CAAC;IAEO,SAAS,CAAC,MAA0B;QACxC,IAAI,MAAM,KAAK,IAAI,CAAC,OAAO,EAAE;YAEzB,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;SAC9B;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,YAAY,CAAkB,cAAiB;QAC3C,MAAM,YAAY,GAAG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