@jael-ecs/core 1.0.3 → 1.1.0
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 +66 -42
- package/dist/ComponentManager.d.ts +10 -9
- package/dist/EntityManager.d.ts +8 -9
- package/dist/EventRegistry.d.ts +9 -6
- package/dist/Query.d.ts +12 -7
- package/dist/World.d.ts +9 -7
- package/dist/jael-build.cjs +1 -1
- package/dist/jael-build.js +194 -147
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,13 +60,19 @@ interface Velocity {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// Create entities
|
|
63
|
-
const
|
|
64
|
-
world.addComponent(
|
|
65
|
-
world.addComponent(
|
|
63
|
+
const playerId = world.create();
|
|
64
|
+
world.addComponent(playerId, "position", { x: 0, y: 0 });
|
|
65
|
+
world.addComponent(playerId, "velocity", { dx: 1, dy: 1 });
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
world.addComponent(
|
|
69
|
-
world.addComponent(
|
|
67
|
+
const enemyId = world.create();
|
|
68
|
+
world.addComponent(enemyId, "position", { x: 10, y: 10 });
|
|
69
|
+
world.addComponent(enemyId, "velocity", { dx: -1, dy: 0 });
|
|
70
|
+
|
|
71
|
+
// Using Entity Proxy
|
|
72
|
+
const playerId = world.create();
|
|
73
|
+
const player = world.getEntity(playerId);
|
|
74
|
+
player.add("position", { x: 0, y: 0 });
|
|
75
|
+
player.add("velocity", { dx: 1, dy: 1 });
|
|
70
76
|
|
|
71
77
|
// Create a system
|
|
72
78
|
const movementSystem: System = {
|
|
@@ -74,10 +80,20 @@ const movementSystem: System = {
|
|
|
74
80
|
update() {
|
|
75
81
|
const query = world.include("position", "velocity");
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
// Get direct proxy access
|
|
84
|
+
query.entities.forEach((entity) => {
|
|
78
85
|
const position = entity.get<Position>("position");
|
|
79
86
|
const velocity = entity.get<Velocity>("velocity");
|
|
80
87
|
|
|
88
|
+
position.x += velocity.dx * (Time.delta || 0.016);
|
|
89
|
+
position.y += velocity.dy * (Time.delta || 0.016);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Get entity ids from query
|
|
93
|
+
for (const entityId of query.ids) {
|
|
94
|
+
const position = this.world.getComponent<Position>(entityId, "position");
|
|
95
|
+
const velocity = this.world.getComponent<Velocity>(entityId, "velocity");
|
|
96
|
+
|
|
81
97
|
position.x += velocity.dx * (Time.delta || 0.016);
|
|
82
98
|
position.y += velocity.dy * (Time.delta || 0.016);
|
|
83
99
|
}
|
|
@@ -111,29 +127,26 @@ The central hub that manages entities, components, and systems.
|
|
|
111
127
|
|
|
112
128
|
```typescript
|
|
113
129
|
// Create a new entity
|
|
114
|
-
const
|
|
130
|
+
const entityId = world.create();
|
|
115
131
|
|
|
116
132
|
// Destroy an entity
|
|
117
|
-
world.destroy(
|
|
133
|
+
world.destroy(entityId);
|
|
118
134
|
|
|
119
135
|
// Check if entity exists
|
|
120
|
-
const exists = world.exist(
|
|
136
|
+
const exists = world.exist(entityId);
|
|
121
137
|
```
|
|
122
138
|
|
|
123
139
|
#### Component Management
|
|
124
140
|
|
|
125
141
|
```typescript
|
|
126
142
|
// Add component
|
|
127
|
-
world.addComponent(
|
|
143
|
+
world.addComponent(entityId, "position", { x: 0, y: 0 });
|
|
128
144
|
|
|
129
145
|
// Remove component
|
|
130
|
-
world.removeComponent(
|
|
146
|
+
world.removeComponent(entityId, "position");
|
|
131
147
|
|
|
132
148
|
// Get component
|
|
133
|
-
const position =
|
|
134
|
-
|
|
135
|
-
// Check if entity has component
|
|
136
|
-
const hasPosition = entity.has("position");
|
|
149
|
+
const position = world.getComponent<Position>(entityId, "position");
|
|
137
150
|
```
|
|
138
151
|
|
|
139
152
|
#### System Management
|
|
@@ -149,7 +162,7 @@ world.removeSystem(yourSystem);
|
|
|
149
162
|
#### Events
|
|
150
163
|
|
|
151
164
|
```typescript
|
|
152
|
-
// Listen to world events
|
|
165
|
+
// Listen to world events ( returns entity proxy for easy reading )
|
|
153
166
|
world.on("entityCreated", ({ entity }) => {
|
|
154
167
|
console.log("Entity created:", entity);
|
|
155
168
|
});
|
|
@@ -173,11 +186,12 @@ world.on("updated", () => {
|
|
|
173
186
|
|
|
174
187
|
### Entity
|
|
175
188
|
|
|
176
|
-
Base entity class for intuitive component management
|
|
189
|
+
Base entity class for intuitive component management as proxy around id
|
|
177
190
|
|
|
178
191
|
```typescript
|
|
179
192
|
// Create entity
|
|
180
|
-
const
|
|
193
|
+
const entityId = world.create();
|
|
194
|
+
const entity = world.getEntity(entityId); // Returns Entity class proxy
|
|
181
195
|
|
|
182
196
|
// Add component
|
|
183
197
|
entity.add("position", { x: 0, y: 0 });
|
|
@@ -190,6 +204,9 @@ const posExist = entity.has("position");
|
|
|
190
204
|
|
|
191
205
|
// Get curren value of the component
|
|
192
206
|
const compSchema = entity.get("position");
|
|
207
|
+
|
|
208
|
+
entity.id // Returns unique entity id from proxy
|
|
209
|
+
|
|
193
210
|
```
|
|
194
211
|
|
|
195
212
|
### System
|
|
@@ -199,7 +216,7 @@ Systems contain the game logic that processes entities with specific components.
|
|
|
199
216
|
```typescript
|
|
200
217
|
interface System {
|
|
201
218
|
priority: number; // Execution order (lower = earlier)
|
|
202
|
-
init?(): void // Runs when added to the world
|
|
219
|
+
init?(): void; // Runs when added to the world
|
|
203
220
|
exit?(): void; // Cleanup when removed
|
|
204
221
|
update(): void; // Main update logic
|
|
205
222
|
}
|
|
@@ -218,13 +235,13 @@ const renderSystem: System = {
|
|
|
218
235
|
update(dt) {
|
|
219
236
|
const renderableQuery = world.include("position", "sprite");
|
|
220
237
|
|
|
221
|
-
|
|
238
|
+
renderableQuery.entities.forEach((entity) => {
|
|
222
239
|
const position = entity.get<Position>("position");
|
|
223
240
|
const sprite = entity.get<Sprite>("sprite");
|
|
224
241
|
|
|
225
242
|
// Render entity
|
|
226
243
|
drawSprite(sprite, position.x, position.y);
|
|
227
|
-
}
|
|
244
|
+
})
|
|
228
245
|
},
|
|
229
246
|
|
|
230
247
|
exit() {
|
|
@@ -266,29 +283,36 @@ const complexQuery2 = world.include("position", "health").exclude("static");
|
|
|
266
283
|
#### Accessing Results
|
|
267
284
|
|
|
268
285
|
```typescript
|
|
269
|
-
// Iterate through entities
|
|
270
|
-
|
|
271
|
-
// Process
|
|
286
|
+
// Iterate through entities as proxy
|
|
287
|
+
query.entities.forEach((entity) => {
|
|
288
|
+
// Process Entity proxy
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
// Iterate through entities ids
|
|
292
|
+
for(const entityId of query.ids){
|
|
293
|
+
// Process Entity id
|
|
272
294
|
}
|
|
273
295
|
|
|
296
|
+
|
|
297
|
+
|
|
274
298
|
// Get the first value of the query
|
|
275
|
-
const first = query.entities
|
|
299
|
+
const first = query.entities[0];
|
|
300
|
+
const firstId = query.ids.first()
|
|
276
301
|
|
|
277
302
|
// Check query size
|
|
278
|
-
const count = query.
|
|
303
|
+
const count = query.size();
|
|
279
304
|
|
|
280
305
|
// Check if query has any entities
|
|
281
|
-
const isEmpty = query.
|
|
306
|
+
const isEmpty = query.size() === 0;
|
|
282
307
|
|
|
283
308
|
// Subscribe to query events
|
|
284
|
-
query.on(
|
|
285
|
-
// Entity added
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
query.on('removed', (entity: Entity) => {
|
|
309
|
+
query.on("added", (entityId: number) => {
|
|
289
310
|
// Entity added
|
|
290
|
-
})
|
|
311
|
+
});
|
|
291
312
|
|
|
313
|
+
query.on("removed", (entityId: number) => {
|
|
314
|
+
// Entity removed
|
|
315
|
+
});
|
|
292
316
|
```
|
|
293
317
|
|
|
294
318
|
### SparseSet
|
|
@@ -353,8 +377,8 @@ interface WorldEvents {
|
|
|
353
377
|
}
|
|
354
378
|
|
|
355
379
|
interface QueryEvents {
|
|
356
|
-
added:
|
|
357
|
-
removed:
|
|
380
|
+
added: number; //EntityId added to query entities
|
|
381
|
+
removed: number; //EntityId removed to query entities
|
|
358
382
|
}
|
|
359
383
|
|
|
360
384
|
// Listen to events
|
|
@@ -369,7 +393,7 @@ world.emit("entityCreated", { entity: someEntity });
|
|
|
369
393
|
world.off("entityCreated", handler);
|
|
370
394
|
|
|
371
395
|
// Romeve all listeners of a type
|
|
372
|
-
world.clearEvent(
|
|
396
|
+
world.clearEvent("type");
|
|
373
397
|
|
|
374
398
|
// Remove all listeners
|
|
375
399
|
world.clearAllEvents();
|
|
@@ -425,8 +449,8 @@ class MovementSystem implements System {
|
|
|
425
449
|
}
|
|
426
450
|
|
|
427
451
|
update() {
|
|
428
|
-
for
|
|
429
|
-
// Process movement
|
|
452
|
+
for(const entityId of this.movementQuery.ids){
|
|
453
|
+
// Process movement using entityId
|
|
430
454
|
}
|
|
431
455
|
}
|
|
432
456
|
}
|
|
@@ -438,13 +462,13 @@ type MovementSystem = { movementQuery: Query | null } & System;
|
|
|
438
462
|
const movementSystem: MovementSystem = {
|
|
439
463
|
movementQuery: null;
|
|
440
464
|
priority: 1;
|
|
441
|
-
|
|
465
|
+
|
|
442
466
|
init(){
|
|
443
467
|
this.movementQuery = world.include('position', 'velocity');
|
|
444
468
|
}
|
|
445
469
|
|
|
446
470
|
update(){
|
|
447
|
-
for (const
|
|
471
|
+
for (const entityId of this.movementQuery.ids) {
|
|
448
472
|
// Process movement
|
|
449
473
|
}
|
|
450
474
|
}
|
|
@@ -461,7 +485,7 @@ update() {
|
|
|
461
485
|
|
|
462
486
|
```typescript
|
|
463
487
|
// Remember to clean up when removing entities
|
|
464
|
-
world.destroy(
|
|
488
|
+
world.destroy(entityId); // Automatically removes all components
|
|
465
489
|
|
|
466
490
|
// Clean up systems if they have resources
|
|
467
491
|
system.exit?.(); // Called automatically when removed from world
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { Entity } from './EntityManager';
|
|
2
1
|
import { default as EventRegistry } from './EventRegistry';
|
|
3
2
|
import { default as World } from './World';
|
|
4
3
|
export type ComponentSchema = Record<string, any>;
|
|
5
4
|
export interface ComponentManagerEvents {
|
|
6
5
|
add: {
|
|
7
|
-
|
|
6
|
+
entityId: number;
|
|
8
7
|
component: keyof ComponentSchema;
|
|
9
8
|
};
|
|
10
9
|
remove: {
|
|
11
|
-
|
|
10
|
+
entityId: number;
|
|
12
11
|
component: keyof ComponentSchema;
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
14
|
export declare class ComponentManager extends EventRegistry<ComponentManagerEvents> {
|
|
16
|
-
componentSet:
|
|
15
|
+
componentSet: {
|
|
16
|
+
[k: number]: ComponentSchema;
|
|
17
|
+
};
|
|
17
18
|
world: World;
|
|
18
19
|
constructor(world: World);
|
|
19
|
-
clearComponentSchema(
|
|
20
|
-
addComponent<K extends keyof ComponentSchema>(
|
|
21
|
-
getComponent<K extends keyof ComponentSchema>(
|
|
22
|
-
hasComponent<K extends keyof ComponentSchema>(
|
|
23
|
-
removeComponent<K extends keyof ComponentSchema>(
|
|
20
|
+
clearComponentSchema(entityId: number): void;
|
|
21
|
+
addComponent<K extends keyof ComponentSchema>(entityId: number, key: K, value: ComponentSchema[K]): void;
|
|
22
|
+
getComponent<K extends keyof ComponentSchema>(entityId: number, key: K): ComponentSchema[K] | undefined;
|
|
23
|
+
hasComponent<K extends keyof ComponentSchema>(entityId: number, key: K): boolean;
|
|
24
|
+
removeComponent<K extends keyof ComponentSchema>(entityId: number, key: K): void;
|
|
24
25
|
}
|
package/dist/EntityManager.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as EventRegistry } from './EventRegistry';
|
|
2
2
|
import { SparseSet } from './SparseSet';
|
|
3
3
|
import { default as World } from './World';
|
|
4
|
-
declare class Entity {
|
|
4
|
+
export declare class Entity {
|
|
5
5
|
readonly id: number;
|
|
6
6
|
private _world;
|
|
7
7
|
constructor(world: World, id: number);
|
|
@@ -30,18 +30,17 @@ declare class Entity {
|
|
|
30
30
|
get<T = any>(compType: string): T;
|
|
31
31
|
}
|
|
32
32
|
export declare class EntityManager extends EventRegistry<EntityManagerEvents> {
|
|
33
|
-
entityMap: SparseSet<
|
|
33
|
+
entityMap: SparseSet<number>;
|
|
34
34
|
nextId: number;
|
|
35
35
|
_world: World;
|
|
36
36
|
constructor(world: World);
|
|
37
|
-
get entities(): SparseSet<
|
|
38
|
-
create():
|
|
39
|
-
exist(
|
|
37
|
+
get entities(): SparseSet<number>;
|
|
38
|
+
create(): number;
|
|
39
|
+
exist(id: number): boolean;
|
|
40
40
|
size(): number;
|
|
41
|
-
destroy(
|
|
41
|
+
destroy(id: number): number;
|
|
42
42
|
}
|
|
43
43
|
export interface EntityManagerEvents {
|
|
44
|
-
create:
|
|
45
|
-
destroy:
|
|
44
|
+
create: number;
|
|
45
|
+
destroy: number;
|
|
46
46
|
}
|
|
47
|
-
export { type Entity };
|
package/dist/EventRegistry.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
export type Event<
|
|
2
|
-
|
|
1
|
+
export type Event<V> = {
|
|
2
|
+
[key: string]: V;
|
|
3
|
+
};
|
|
4
|
+
export type EventCallback<V> = (event: V[keyof V]) => void;
|
|
5
|
+
export default class EventRegistry<E extends Event<any> = {}> {
|
|
3
6
|
private _listeners;
|
|
4
|
-
on(type: keyof E, callback:
|
|
5
|
-
off(type: keyof E, callback:
|
|
6
|
-
once(type: keyof E, callback:
|
|
7
|
+
on(type: keyof E, callback: EventCallback<E>): void;
|
|
8
|
+
off(type: keyof E, callback: EventCallback<E>): void;
|
|
9
|
+
once(type: keyof E, callback: EventCallback<E>): void;
|
|
7
10
|
clearEvent(type: keyof E): void;
|
|
8
11
|
clearAllEvents(): void;
|
|
9
|
-
contains(type: keyof E, callback:
|
|
12
|
+
contains(type: keyof E, callback: EventCallback<E>): boolean;
|
|
10
13
|
emit(type: keyof E, data: E[keyof E]): void;
|
|
11
14
|
}
|
package/dist/Query.d.ts
CHANGED
|
@@ -7,16 +7,21 @@ export interface QueryConfig {
|
|
|
7
7
|
exclude: string[];
|
|
8
8
|
}
|
|
9
9
|
export interface QueryEvents {
|
|
10
|
-
added:
|
|
11
|
-
removed:
|
|
10
|
+
added: number;
|
|
11
|
+
removed: number;
|
|
12
12
|
}
|
|
13
13
|
export declare class Query extends EventRegistry<QueryEvents> {
|
|
14
|
-
config
|
|
15
|
-
entityMap
|
|
16
|
-
|
|
14
|
+
private config;
|
|
15
|
+
private entityMap;
|
|
16
|
+
private entityInstancesCache;
|
|
17
|
+
private world;
|
|
17
18
|
constructor(config: QueryConfig, world: World);
|
|
18
|
-
hasComponents(
|
|
19
|
-
|
|
19
|
+
hasComponents(entityId: number): boolean;
|
|
20
|
+
size(): number;
|
|
21
|
+
get hash(): number;
|
|
22
|
+
get ids(): SparseSet<number>;
|
|
23
|
+
private getCachedEntity;
|
|
24
|
+
get entities(): Entity[];
|
|
20
25
|
include(...comps: string[]): Query;
|
|
21
26
|
exclude(...comps: string[]): Query;
|
|
22
27
|
private _checkExistingEntities;
|
package/dist/World.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentManager, ComponentSchema } from './ComponentManager';
|
|
2
|
-
import {
|
|
2
|
+
import { Entity, EntityManager } from './EntityManager';
|
|
3
3
|
import { default as EventRegistry } from './EventRegistry';
|
|
4
4
|
import { Query, QueryConfig } from './Query';
|
|
5
5
|
import { SparseSet } from './SparseSet';
|
|
@@ -27,17 +27,19 @@ export default class World extends EventRegistry<WorldEvents> {
|
|
|
27
27
|
systemManager: SystemManager;
|
|
28
28
|
queries: Map<number, Query>;
|
|
29
29
|
constructor();
|
|
30
|
-
|
|
30
|
+
getEntity(id: number): Entity | undefined;
|
|
31
|
+
get entityIds(): SparseSet<number>;
|
|
31
32
|
query(config: QueryConfig): Query;
|
|
32
33
|
private _updateQueries;
|
|
33
|
-
exist(
|
|
34
|
+
exist(entityId: number): boolean;
|
|
34
35
|
include(...comps: string[]): Query;
|
|
35
36
|
exclude(...comps: string[]): Query;
|
|
36
|
-
create():
|
|
37
|
-
destroy(
|
|
37
|
+
create(): number;
|
|
38
|
+
destroy(entityId: number): void;
|
|
38
39
|
addSystem(sys: System): void;
|
|
39
40
|
removeSystem(sys: System): void;
|
|
40
|
-
addComponent(
|
|
41
|
-
|
|
41
|
+
addComponent(entityId: number, compKey: string, compValue: any): void;
|
|
42
|
+
getComponent<T>(entityId: number, compKey: string): T;
|
|
43
|
+
removeComponent(entityId: number, compKey: string): void;
|
|
42
44
|
update(): void;
|
|
43
45
|
}
|
package/dist/jael-build.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{_listeners=new Map;on(e,t){if(this.contains(e,t))return;const s=this._listeners.get(e);s?s.add(t):this._listeners.set(e,new Set([t]))}off(e,t){if(!this.contains(e,t))return;const s=this._listeners.get(e);s&&s.delete(t)}once(e,t){const s=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{_listeners=new Map;on(e,t){if(this.contains(e,t))return;const s=this._listeners.get(e);s?s.add(t):this._listeners.set(e,new Set([t]))}off(e,t){if(!this.contains(e,t))return;const s=this._listeners.get(e);s&&s.delete(t)}once(e,t){const s=(n=>{t(n),this.off(e,s)});this.on(e,s)}clearEvent(e){this._listeners.get(e)&&this._listeners.get(e)?.clear()}clearAllEvents(){this._listeners.forEach(e=>e.clear()),this._listeners.clear()}contains(e,t){return this._listeners.get(e)?this._listeners.get(e).has(t):!1}emit(e,t){this._listeners.get(e)&&this._listeners.get(e)?.forEach(s=>{s(t)})}}class d{systemList=[];addSystem(e){this.systemList.push(e),e.init?.(),this.reorder()}reorder(){this.systemList.sort((e,t)=>e.priority-t.priority)}has(e){return this.systemList.indexOf(e)>0}removeSystem(e){if(!this.has(e))return;const t=this.systemList.indexOf(e);t>=0&&(this.systemList.splice(t,1),e.exit?.(),this.reorder())}}class c{denseValues=[];sparse=new Map;[Symbol.iterator](){let e=this.values.length;const t={value:void 0,done:!1};return{next:()=>(t.value=this.values[--e],t.done=e<0,t)}}get values(){return this.denseValues}first(){return this.denseValues[0]}add(e){this.has(e)||(this.denseValues.push(e),this.sparse.set(e,this.denseValues.length-1))}indexOf(e){const t=this.sparse.get(e);return t!==void 0?t:-1}remove(e){if(!this.has(e))return;const t=this.sparse.get(e);this.sparse.delete(e);const s=this.denseValues[this.denseValues.length-1];s!==e&&(this.denseValues[t]=s,this.sparse.set(s,t)),this.denseValues.pop()}forEach(e){for(let t of this)e(t)}size(){return this.denseValues.length}clear(){for(let e of this)this.remove(e)}has(e){return this.sparse.has(e)}}class m{id;_world;constructor(e,t){this.id=t,this._world=e}add(e,t){this._world.addComponent(this.id,e,t)}remove(e){this._world.removeComponent(this.id,e)}has(e){return this._world.componentManager.hasComponent(this.id,e)}get(e){return this._world.componentManager.getComponent(this.id,e)}}class u extends o{entityMap=new c;nextId=0;_world;constructor(e){super(),this._world=e}get entities(){return this.entityMap}create(){const e=this.nextId++;return this.entities.add(e),this.emit("create",e),e}exist(e){return this.entities.has(e)}size(){return this.entities.size()}destroy(e){return this.entities.remove(e),this.emit("destroy",e),e}}class l extends o{componentSet={};world;constructor(e){super(),this.world=e}clearComponentSchema(e){this.componentSet[e]&&delete this.componentSet[e]}addComponent(e,t,s){const n=this.componentSet[e];n?n[t]=s:this.componentSet[e]={[t]:s},this.emit("add",{entityId:e,component:t})}getComponent(e,t){if(this.hasComponent(e,t))return this.componentSet[e][t]}hasComponent(e,t){const s=this.componentSet[e];return s?t in s:!1}removeComponent(e,t){if(!this.componentSet[e])return;const s=this.componentSet[e];s&&s[t]!==void 0&&(delete s[t],Object.keys(s).length===0&&delete this.componentSet[e],this.emit("remove",{entityId:e,component:t}))}}class a extends o{config;entityMap;entityInstancesCache;world;constructor(e,t){super(),this.config=e,this.world=t,this.entityInstancesCache=new Map,this.entityMap=new c,this.on("removed",s=>{this.entityInstancesCache.delete(s)})}hasComponents(e){const t=this.world.componentManager;return this.config.include?.every(s=>t.getComponent(e,s))&&this.config.exclude?.every(s=>!t.getComponent(e,s))}size(){return this.ids.size()}get hash(){return a.getHash(this.config)}get ids(){return this.entityMap}getCachedEntity(e){const t=this.entityInstancesCache.get(e);if(t)return t;{const s=this.world.getEntity(e);return s?(this.entityInstancesCache.set(e,s),s):void 0}}get entities(){const e=[],t=this.entityMap.size()>100;return this.entityMap.forEach(s=>{if(t){const n=this.getCachedEntity(s);n&&e.push(n)}else{const n=this.world.getEntity(s);n&&e.push(n)}}),e}include(...e){return this.world.include(...e)}exclude(...e){return this.world.exclude(...e)}_checkExistingEntities(){for(let e of this.ids)this.world.exist(e)||(this.emit("removed",e),this.entityMap.remove(e))}checkEntities(){this.entityInstancesCache.clear();for(let e of this.world.entityIds)this.hasComponents(e)&&(this.entityMap.add(e),this.emit("added",e));this._checkExistingEntities()}static getHash(e){const t=e.include?.map(i=>i.trim()).filter(i=>i).join("_"),s=e.exclude?.map(i=>i.trim()).filter(i=>i).join("_"),n="in_"+t+"_out_"+s;let h=0;for(const i of n)h=(h<<5)-h+i.charCodeAt(0),h|=0;return h}}class p extends o{_startTime=0;_oldTime=0;_requestId=0;running=!1;delta=0;elapsed=0;constructor(){super()}_loop(){let e=0;if(this.running){const t=performance.now();e=(t-this._oldTime)/1e3,this._oldTime=t,this.elapsed+=e}this.delta=e,this.emit("update"),this._requestId=requestAnimationFrame(this._loop.bind(this))}start(){this._startTime=performance.now(),this._oldTime=this._startTime,this.elapsed=0,this.delta=0,this.running=!0,this._loop()}stop(){this.running=!1,cancelAnimationFrame(this._requestId),this._requestId=0}}let g=new p;class f extends o{entityManager;componentManager;systemManager;queries;constructor(){super(),this.entityManager=new u(this),this.componentManager=new l(this),this.systemManager=new d,this.entityManager.on("create",e=>{const t=this.getEntity(e);t&&(this.emit("entityCreated",{entity:t}),this._updateQueries())}),this.entityManager.on("destroy",e=>{const t=this.getEntity(e);t&&(this.emit("entityCreated",{entity:t}),this._updateQueries(),this.componentManager.clearComponentSchema(e))}),this.componentManager.on("add",e=>{const t=this.getEntity(e.entityId);t&&(this.emit("componentAdded",{entity:t,component:e.component}),this._updateQueries())}),this.componentManager.on("remove",e=>{const t=this.getEntity(e.entityId);t&&(this.emit("componentRemoved",{entity:t,component:e.component}),this._updateQueries())}),this.queries=new Map}getEntity(e){if(this.entityManager.exist(e))return new m(this,e)}get entityIds(){return this.entityManager.entities}query(e){const t=a.getHash(e);let n=this.queries.get(t);return n||(n=new a(e,this),this.queries.set(t,n),this._updateQueries()),n}_updateQueries(){this.queries.forEach(e=>e.checkEntities())}exist(e){return this.entityManager.exist(e)}include(...e){return this.query({include:e,exclude:[]})}exclude(...e){return this.query({include:[],exclude:e})}create(){return this.entityManager.create()}destroy(e){this.entityManager.destroy(e)}addSystem(e){this.systemManager.addSystem(e)}removeSystem(e){this.systemManager.removeSystem(e)}addComponent(e,t,s){this.componentManager.addComponent(e,t,s)}getComponent(e,t){return this.componentManager.getComponent(e,t)}removeComponent(e,t){this.componentManager.removeComponent(e,t)}update(){this.systemManager.systemList.forEach(e=>{e.update()}),this.emit("updated")}}exports.ComponentManager=l;exports.EntityManager=u;exports.EventRegistry=o;exports.Query=a;exports.SparseSet=c;exports.SystemManager=d;exports.Time=g;exports.World=f;
|
package/dist/jael-build.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
class h {
|
|
2
2
|
_listeners = /* @__PURE__ */ new Map();
|
|
3
|
-
on(
|
|
4
|
-
if (this.contains(
|
|
3
|
+
on(t, e) {
|
|
4
|
+
if (this.contains(t, e))
|
|
5
5
|
return;
|
|
6
|
-
const s = this._listeners.get(
|
|
7
|
-
s ? s.add(
|
|
6
|
+
const s = this._listeners.get(t);
|
|
7
|
+
s ? s.add(e) : this._listeners.set(t, /* @__PURE__ */ new Set([e]));
|
|
8
8
|
}
|
|
9
|
-
off(
|
|
10
|
-
if (!this.contains(
|
|
9
|
+
off(t, e) {
|
|
10
|
+
if (!this.contains(t, e))
|
|
11
11
|
return;
|
|
12
|
-
const s = this._listeners.get(
|
|
13
|
-
s && s.delete(
|
|
12
|
+
const s = this._listeners.get(t);
|
|
13
|
+
s && s.delete(e);
|
|
14
14
|
}
|
|
15
|
-
once(
|
|
16
|
-
const s = ((
|
|
17
|
-
|
|
15
|
+
once(t, e) {
|
|
16
|
+
const s = ((n) => {
|
|
17
|
+
e(n), this.off(t, s);
|
|
18
18
|
});
|
|
19
|
-
this.on(
|
|
19
|
+
this.on(t, s);
|
|
20
20
|
}
|
|
21
|
-
clearEvent(
|
|
22
|
-
this._listeners.get(
|
|
21
|
+
clearEvent(t) {
|
|
22
|
+
this._listeners.get(t) && this._listeners.get(t)?.clear();
|
|
23
23
|
}
|
|
24
24
|
clearAllEvents() {
|
|
25
|
-
this._listeners.forEach((
|
|
25
|
+
this._listeners.forEach((t) => t.clear()), this._listeners.clear();
|
|
26
26
|
}
|
|
27
|
-
contains(
|
|
28
|
-
return this._listeners.get(
|
|
27
|
+
contains(t, e) {
|
|
28
|
+
return this._listeners.get(t) ? this._listeners.get(t).has(e) : !1;
|
|
29
29
|
}
|
|
30
|
-
emit(
|
|
31
|
-
this._listeners.get(
|
|
32
|
-
s(
|
|
30
|
+
emit(t, e) {
|
|
31
|
+
this._listeners.get(t) && this._listeners.get(t)?.forEach((s) => {
|
|
32
|
+
s(e);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
class
|
|
36
|
+
class d {
|
|
37
37
|
systemList = [];
|
|
38
|
-
addSystem(
|
|
39
|
-
this.systemList.push(
|
|
38
|
+
addSystem(t) {
|
|
39
|
+
this.systemList.push(t), t.init?.(), this.reorder();
|
|
40
40
|
}
|
|
41
41
|
reorder() {
|
|
42
|
-
this.systemList.sort((
|
|
42
|
+
this.systemList.sort((t, e) => t.priority - e.priority);
|
|
43
43
|
}
|
|
44
|
-
has(
|
|
45
|
-
return this.systemList.indexOf(
|
|
44
|
+
has(t) {
|
|
45
|
+
return this.systemList.indexOf(t) > 0;
|
|
46
46
|
}
|
|
47
|
-
removeSystem(
|
|
48
|
-
if (!this.has(
|
|
49
|
-
const
|
|
50
|
-
|
|
47
|
+
removeSystem(t) {
|
|
48
|
+
if (!this.has(t)) return;
|
|
49
|
+
const e = this.systemList.indexOf(t);
|
|
50
|
+
e >= 0 && (this.systemList.splice(e, 1), t.exit?.(), this.reorder());
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class c {
|
|
54
54
|
denseValues = [];
|
|
55
55
|
sparse = /* @__PURE__ */ new Map();
|
|
56
56
|
[Symbol.iterator]() {
|
|
57
|
-
let
|
|
58
|
-
const
|
|
57
|
+
let t = this.values.length;
|
|
58
|
+
const e = {
|
|
59
59
|
value: void 0,
|
|
60
60
|
done: !1
|
|
61
61
|
};
|
|
62
62
|
return {
|
|
63
|
-
next: () => (
|
|
63
|
+
next: () => (e.value = this.values[--t], e.done = t < 0, e)
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
get values() {
|
|
@@ -69,157 +69,193 @@ class d {
|
|
|
69
69
|
first() {
|
|
70
70
|
return this.denseValues[0];
|
|
71
71
|
}
|
|
72
|
-
add(
|
|
73
|
-
this.has(
|
|
72
|
+
add(t) {
|
|
73
|
+
this.has(t) || (this.denseValues.push(t), this.sparse.set(t, this.denseValues.length - 1));
|
|
74
74
|
}
|
|
75
|
-
indexOf(
|
|
76
|
-
|
|
75
|
+
indexOf(t) {
|
|
76
|
+
const e = this.sparse.get(t);
|
|
77
|
+
return e !== void 0 ? e : -1;
|
|
77
78
|
}
|
|
78
|
-
remove(
|
|
79
|
-
if (!this.has(
|
|
80
|
-
const
|
|
81
|
-
this.sparse.delete(
|
|
79
|
+
remove(t) {
|
|
80
|
+
if (!this.has(t)) return;
|
|
81
|
+
const e = this.sparse.get(t);
|
|
82
|
+
this.sparse.delete(t);
|
|
82
83
|
const s = this.denseValues[this.denseValues.length - 1];
|
|
83
|
-
s !==
|
|
84
|
+
s !== t && (this.denseValues[e] = s, this.sparse.set(s, e)), this.denseValues.pop();
|
|
84
85
|
}
|
|
85
|
-
forEach(
|
|
86
|
-
for (let
|
|
87
|
-
e
|
|
86
|
+
forEach(t) {
|
|
87
|
+
for (let e of this)
|
|
88
|
+
t(e);
|
|
88
89
|
}
|
|
89
90
|
size() {
|
|
90
91
|
return this.denseValues.length;
|
|
91
92
|
}
|
|
92
93
|
clear() {
|
|
93
|
-
for (let
|
|
94
|
-
this.remove(
|
|
94
|
+
for (let t of this)
|
|
95
|
+
this.remove(t);
|
|
95
96
|
}
|
|
96
|
-
has(
|
|
97
|
-
return this.sparse.has(
|
|
97
|
+
has(t) {
|
|
98
|
+
return this.sparse.has(t);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
class u {
|
|
101
102
|
id;
|
|
102
103
|
_world;
|
|
103
|
-
constructor(
|
|
104
|
-
this.id =
|
|
104
|
+
constructor(t, e) {
|
|
105
|
+
this.id = e, this._world = t;
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* Add component to current entity.
|
|
108
109
|
* @param compType Component name
|
|
109
110
|
* @param compValue Component value
|
|
110
111
|
*/
|
|
111
|
-
add(
|
|
112
|
-
this._world.addComponent(this,
|
|
112
|
+
add(t, e) {
|
|
113
|
+
this._world.addComponent(this.id, t, e);
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
116
|
* Remove component of current entity.
|
|
116
117
|
* @param compType Component name
|
|
117
118
|
*/
|
|
118
|
-
remove(
|
|
119
|
-
this._world.removeComponent(this,
|
|
119
|
+
remove(t) {
|
|
120
|
+
this._world.removeComponent(this.id, t);
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* Check if current entity has a component.
|
|
123
124
|
* @param compType Component name
|
|
124
125
|
* @returns boolean
|
|
125
126
|
*/
|
|
126
|
-
has(
|
|
127
|
-
return this._world.componentManager.hasComponent(this,
|
|
127
|
+
has(t) {
|
|
128
|
+
return this._world.componentManager.hasComponent(this.id, t);
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
130
131
|
* Get passed component schema of current entity.
|
|
131
132
|
* @param compType Component name
|
|
132
133
|
* @returns Return component schema with T(any as default) as type
|
|
133
134
|
*/
|
|
134
|
-
get(
|
|
135
|
-
return this._world.componentManager.getComponent(this,
|
|
135
|
+
get(t) {
|
|
136
|
+
return this._world.componentManager.getComponent(this.id, t);
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
class l extends h {
|
|
139
|
-
entityMap = new
|
|
140
|
+
entityMap = new c();
|
|
140
141
|
nextId = 0;
|
|
141
142
|
_world;
|
|
142
|
-
constructor(
|
|
143
|
-
super(), this._world =
|
|
143
|
+
constructor(t) {
|
|
144
|
+
super(), this._world = t;
|
|
144
145
|
}
|
|
145
146
|
get entities() {
|
|
146
147
|
return this.entityMap;
|
|
147
148
|
}
|
|
148
149
|
create() {
|
|
149
|
-
const
|
|
150
|
+
const t = this.nextId++;
|
|
150
151
|
return this.entities.add(t), this.emit("create", t), t;
|
|
151
152
|
}
|
|
152
|
-
exist(
|
|
153
|
-
return this.entities.has(
|
|
153
|
+
exist(t) {
|
|
154
|
+
return this.entities.has(t);
|
|
154
155
|
}
|
|
155
156
|
size() {
|
|
156
157
|
return this.entities.size();
|
|
157
158
|
}
|
|
158
|
-
destroy(
|
|
159
|
-
return this.entities.remove(
|
|
159
|
+
destroy(t) {
|
|
160
|
+
return this.entities.remove(t), this.emit("destroy", t), t;
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
class m extends h {
|
|
163
|
-
componentSet =
|
|
164
|
+
componentSet = {};
|
|
164
165
|
world;
|
|
165
|
-
constructor(
|
|
166
|
-
super(), this.world =
|
|
166
|
+
constructor(t) {
|
|
167
|
+
super(), this.world = t;
|
|
167
168
|
}
|
|
168
|
-
clearComponentSchema(
|
|
169
|
-
this.componentSet
|
|
169
|
+
clearComponentSchema(t) {
|
|
170
|
+
this.componentSet[t] && delete this.componentSet[t];
|
|
170
171
|
}
|
|
171
|
-
addComponent(
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
);
|
|
175
|
-
i ? i[t] = s : this.componentSet.set(e.id, { [t]: s }), this.emit("add", { entity: e, component: t });
|
|
172
|
+
addComponent(t, e, s) {
|
|
173
|
+
const n = this.componentSet[t];
|
|
174
|
+
n ? n[e] = s : this.componentSet[t] = { [e]: s }, this.emit("add", { entityId: t, component: e });
|
|
176
175
|
}
|
|
177
|
-
getComponent(
|
|
178
|
-
|
|
176
|
+
getComponent(t, e) {
|
|
177
|
+
if (this.hasComponent(t, e))
|
|
178
|
+
return this.componentSet[t][e];
|
|
179
179
|
}
|
|
180
|
-
hasComponent(
|
|
181
|
-
const s = this.componentSet
|
|
182
|
-
return s ?
|
|
180
|
+
hasComponent(t, e) {
|
|
181
|
+
const s = this.componentSet[t];
|
|
182
|
+
return s ? e in s : !1;
|
|
183
183
|
}
|
|
184
|
-
removeComponent(
|
|
185
|
-
if (!this.componentSet
|
|
186
|
-
const s = this.componentSet
|
|
187
|
-
s && s[
|
|
184
|
+
removeComponent(t, e) {
|
|
185
|
+
if (!this.componentSet[t]) return;
|
|
186
|
+
const s = this.componentSet[t];
|
|
187
|
+
s && s[e] !== void 0 && (delete s[e], Object.keys(s).length === 0 && delete this.componentSet[t], this.emit("remove", { entityId: t, component: e }));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
class a extends h {
|
|
191
191
|
config;
|
|
192
192
|
entityMap;
|
|
193
|
+
entityInstancesCache;
|
|
193
194
|
world;
|
|
194
|
-
constructor(
|
|
195
|
-
super(), this.config =
|
|
195
|
+
constructor(t, e) {
|
|
196
|
+
super(), this.config = t, this.world = e, this.entityInstancesCache = /* @__PURE__ */ new Map(), this.entityMap = new c(), this.on("removed", (s) => {
|
|
197
|
+
this.entityInstancesCache.delete(s);
|
|
198
|
+
});
|
|
196
199
|
}
|
|
197
|
-
hasComponents(
|
|
198
|
-
|
|
200
|
+
hasComponents(t) {
|
|
201
|
+
const e = this.world.componentManager;
|
|
202
|
+
return this.config.include?.every(
|
|
203
|
+
(s) => e.getComponent(t, s)
|
|
204
|
+
) && this.config.exclude?.every(
|
|
205
|
+
(s) => !e.getComponent(t, s)
|
|
206
|
+
);
|
|
199
207
|
}
|
|
200
|
-
|
|
208
|
+
size() {
|
|
209
|
+
return this.ids.size();
|
|
210
|
+
}
|
|
211
|
+
get hash() {
|
|
212
|
+
return a.getHash(this.config);
|
|
213
|
+
}
|
|
214
|
+
get ids() {
|
|
201
215
|
return this.entityMap;
|
|
202
216
|
}
|
|
203
|
-
|
|
204
|
-
|
|
217
|
+
getCachedEntity(t) {
|
|
218
|
+
const e = this.entityInstancesCache.get(t);
|
|
219
|
+
if (e)
|
|
220
|
+
return e;
|
|
221
|
+
{
|
|
222
|
+
const s = this.world.getEntity(t);
|
|
223
|
+
return s ? (this.entityInstancesCache.set(t, s), s) : void 0;
|
|
224
|
+
}
|
|
205
225
|
}
|
|
206
|
-
|
|
207
|
-
|
|
226
|
+
get entities() {
|
|
227
|
+
const t = [], e = this.entityMap.size() > 100;
|
|
228
|
+
return this.entityMap.forEach((s) => {
|
|
229
|
+
if (e) {
|
|
230
|
+
const n = this.getCachedEntity(s);
|
|
231
|
+
n && t.push(n);
|
|
232
|
+
} else {
|
|
233
|
+
const n = this.world.getEntity(s);
|
|
234
|
+
n && t.push(n);
|
|
235
|
+
}
|
|
236
|
+
}), t;
|
|
237
|
+
}
|
|
238
|
+
include(...t) {
|
|
239
|
+
return this.world.include(...t);
|
|
240
|
+
}
|
|
241
|
+
exclude(...t) {
|
|
242
|
+
return this.world.exclude(...t);
|
|
208
243
|
}
|
|
209
244
|
_checkExistingEntities() {
|
|
210
|
-
for (let
|
|
211
|
-
this.world.exist(
|
|
245
|
+
for (let t of this.ids)
|
|
246
|
+
this.world.exist(t) || (this.emit("removed", t), this.entityMap.remove(t));
|
|
212
247
|
}
|
|
213
248
|
checkEntities() {
|
|
214
|
-
|
|
215
|
-
|
|
249
|
+
this.entityInstancesCache.clear();
|
|
250
|
+
for (let t of this.world.entityIds)
|
|
251
|
+
this.hasComponents(t) && (this.entityMap.add(t), this.emit("added", t));
|
|
216
252
|
this._checkExistingEntities();
|
|
217
253
|
}
|
|
218
|
-
static getHash(
|
|
219
|
-
const
|
|
254
|
+
static getHash(t) {
|
|
255
|
+
const e = t.include?.map((i) => i.trim()).filter((i) => i).join("_"), s = t.exclude?.map((i) => i.trim()).filter((i) => i).join("_"), n = "in_" + e + "_out_" + s;
|
|
220
256
|
let o = 0;
|
|
221
|
-
for (const
|
|
222
|
-
o = (o << 5) - o +
|
|
257
|
+
for (const i of n)
|
|
258
|
+
o = (o << 5) - o + i.charCodeAt(0), o |= 0;
|
|
223
259
|
return o;
|
|
224
260
|
}
|
|
225
261
|
}
|
|
@@ -234,12 +270,12 @@ class p extends h {
|
|
|
234
270
|
super();
|
|
235
271
|
}
|
|
236
272
|
_loop() {
|
|
237
|
-
let
|
|
273
|
+
let t = 0;
|
|
238
274
|
if (this.running) {
|
|
239
|
-
const
|
|
240
|
-
|
|
275
|
+
const e = performance.now();
|
|
276
|
+
t = (e - this._oldTime) / 1e3, this._oldTime = e, this.elapsed += t;
|
|
241
277
|
}
|
|
242
|
-
this.delta =
|
|
278
|
+
this.delta = t, this.emit("update"), this._requestId = requestAnimationFrame(this._loop.bind(this));
|
|
243
279
|
}
|
|
244
280
|
start() {
|
|
245
281
|
this._startTime = performance.now(), this._oldTime = this._startTime, this.elapsed = 0, this.delta = 0, this.running = !0, this._loop();
|
|
@@ -255,69 +291,80 @@ class f extends h {
|
|
|
255
291
|
systemManager;
|
|
256
292
|
queries;
|
|
257
293
|
constructor() {
|
|
258
|
-
super(), this.entityManager = new l(this), this.componentManager = new m(this), this.systemManager = new
|
|
294
|
+
super(), this.entityManager = new l(this), this.componentManager = new m(this), this.systemManager = new d(), this.entityManager.on("create", (t) => {
|
|
295
|
+
const e = this.getEntity(t);
|
|
259
296
|
e && (this.emit("entityCreated", { entity: e }), this._updateQueries());
|
|
260
|
-
}), this.entityManager.on("destroy", (
|
|
261
|
-
|
|
297
|
+
}), this.entityManager.on("destroy", (t) => {
|
|
298
|
+
const e = this.getEntity(t);
|
|
299
|
+
e && (this.emit("entityCreated", { entity: e }), this._updateQueries(), this.componentManager.clearComponentSchema(t));
|
|
262
300
|
}), this.componentManager.on(
|
|
263
301
|
"add",
|
|
264
|
-
(
|
|
265
|
-
this.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
302
|
+
(t) => {
|
|
303
|
+
const e = this.getEntity(t.entityId);
|
|
304
|
+
e && (this.emit("componentAdded", {
|
|
305
|
+
entity: e,
|
|
306
|
+
component: t.component
|
|
307
|
+
}), this._updateQueries());
|
|
269
308
|
}
|
|
270
309
|
), this.componentManager.on(
|
|
271
310
|
"remove",
|
|
272
|
-
(
|
|
273
|
-
this.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
311
|
+
(t) => {
|
|
312
|
+
const e = this.getEntity(t.entityId);
|
|
313
|
+
e && (this.emit("componentRemoved", {
|
|
314
|
+
entity: e,
|
|
315
|
+
component: t.component
|
|
316
|
+
}), this._updateQueries());
|
|
277
317
|
}
|
|
278
318
|
), this.queries = /* @__PURE__ */ new Map();
|
|
279
319
|
}
|
|
280
|
-
|
|
320
|
+
getEntity(t) {
|
|
321
|
+
if (this.entityManager.exist(t))
|
|
322
|
+
return new u(this, t);
|
|
323
|
+
}
|
|
324
|
+
get entityIds() {
|
|
281
325
|
return this.entityManager.entities;
|
|
282
326
|
}
|
|
283
|
-
query(
|
|
284
|
-
const
|
|
285
|
-
let
|
|
286
|
-
return
|
|
327
|
+
query(t) {
|
|
328
|
+
const e = a.getHash(t);
|
|
329
|
+
let n = this.queries.get(e);
|
|
330
|
+
return n || (n = new a(t, this), this.queries.set(e, n), this._updateQueries()), n;
|
|
287
331
|
}
|
|
288
332
|
_updateQueries() {
|
|
289
|
-
this.queries.forEach((
|
|
333
|
+
this.queries.forEach((t) => t.checkEntities());
|
|
290
334
|
}
|
|
291
|
-
exist(
|
|
292
|
-
return this.entityManager.exist(
|
|
335
|
+
exist(t) {
|
|
336
|
+
return this.entityManager.exist(t);
|
|
293
337
|
}
|
|
294
|
-
include(...
|
|
295
|
-
return this.query({ include:
|
|
338
|
+
include(...t) {
|
|
339
|
+
return this.query({ include: t, exclude: [] });
|
|
296
340
|
}
|
|
297
|
-
exclude(...
|
|
298
|
-
return this.query({ include: [], exclude:
|
|
341
|
+
exclude(...t) {
|
|
342
|
+
return this.query({ include: [], exclude: t });
|
|
299
343
|
}
|
|
300
344
|
create() {
|
|
301
345
|
return this.entityManager.create();
|
|
302
346
|
}
|
|
303
|
-
destroy(
|
|
304
|
-
this.entityManager.destroy(
|
|
347
|
+
destroy(t) {
|
|
348
|
+
this.entityManager.destroy(t);
|
|
349
|
+
}
|
|
350
|
+
addSystem(t) {
|
|
351
|
+
this.systemManager.addSystem(t);
|
|
305
352
|
}
|
|
306
|
-
|
|
307
|
-
this.systemManager.
|
|
353
|
+
removeSystem(t) {
|
|
354
|
+
this.systemManager.removeSystem(t);
|
|
308
355
|
}
|
|
309
|
-
|
|
310
|
-
this.
|
|
356
|
+
addComponent(t, e, s) {
|
|
357
|
+
this.componentManager.addComponent(t, e, s);
|
|
311
358
|
}
|
|
312
|
-
|
|
313
|
-
this.componentManager.
|
|
359
|
+
getComponent(t, e) {
|
|
360
|
+
return this.componentManager.getComponent(t, e);
|
|
314
361
|
}
|
|
315
|
-
removeComponent(
|
|
316
|
-
this.componentManager.removeComponent(
|
|
362
|
+
removeComponent(t, e) {
|
|
363
|
+
this.componentManager.removeComponent(t, e);
|
|
317
364
|
}
|
|
318
365
|
update() {
|
|
319
|
-
this.systemManager.systemList.forEach((
|
|
320
|
-
|
|
366
|
+
this.systemManager.systemList.forEach((t) => {
|
|
367
|
+
t.update();
|
|
321
368
|
}), this.emit("updated");
|
|
322
369
|
}
|
|
323
370
|
}
|
|
@@ -326,8 +373,8 @@ export {
|
|
|
326
373
|
l as EntityManager,
|
|
327
374
|
h as EventRegistry,
|
|
328
375
|
a as Query,
|
|
329
|
-
|
|
330
|
-
|
|
376
|
+
c as SparseSet,
|
|
377
|
+
d as SystemManager,
|
|
331
378
|
g as Time,
|
|
332
379
|
f as World
|
|
333
380
|
};
|