@cjhd/cj-ecs 1.0.0 → 1.0.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/assets/common/component/MoveComponent.d.ts +141 -0
- package/assets/common/component/NodeComponent.d.ts +98 -0
- package/assets/common/system/MoveSystem.d.ts +17 -0
- package/assets/ecs/EcsComponent.d.ts +89 -0
- package/assets/ecs/{EcsDirty.ts → EcsDirty.d.ts} +340 -459
- package/assets/ecs/EcsEntity.d.ts +148 -0
- package/assets/ecs/EcsSingleton.d.ts +3 -0
- package/assets/ecs/EcsSystem.d.ts +96 -0
- package/assets/ecs.d.ts +126 -0
- package/assets/lib/EcsCache.d.ts +24 -0
- package/assets/lib/EcsFilter.d.ts +57 -0
- package/assets/lib/EcsManager.d.ts +251 -0
- package/assets/lib/{EcsObject.ts → EcsObject.d.ts} +360 -422
- package/assets/lib/EcsTimer.d.ts +119 -0
- package/assets/lib/EcsTween.d.ts +168 -0
- package/assets/lib/EcsUtils.d.ts +82 -0
- package/dist/cocos/assets/common/component/MoveComponent.js +4 -0
- package/dist/cocos/assets/common/component/NodeComponent.js +4 -0
- package/dist/cocos/assets/common/system/MoveSystem.js +2 -0
- package/dist/cocos/assets/ecs/EcsComponent.js +4 -0
- package/dist/cocos/assets/ecs/EcsDirty.js +4 -0
- package/dist/cocos/assets/ecs/EcsEntity.js +4 -0
- package/dist/cocos/assets/ecs/EcsSingleton.js +4 -0
- package/dist/cocos/assets/ecs/EcsSystem.js +2 -0
- package/dist/cocos/assets/ecs.js +2 -0
- package/dist/cocos/assets/lib/EcsCache.js +2 -0
- package/dist/cocos/assets/lib/EcsFilter.js +2 -0
- package/dist/cocos/assets/lib/EcsManager.js +4 -0
- package/dist/cocos/assets/lib/EcsObject.js +4 -0
- package/dist/cocos/assets/lib/EcsTimer.js +4 -0
- package/dist/cocos/assets/lib/EcsTween.js +4 -0
- package/dist/cocos/assets/lib/EcsUtils.js +2 -0
- package/dist/cocos/index.js +4 -0
- package/{index.ts → index.d.ts} +14 -33
- package/package.json +27 -7
- package/assets/common/component/MoveComponent.ts +0 -292
- package/assets/common/component/MoveComponent.ts.meta +0 -9
- package/assets/common/component/NodeComponent.ts +0 -315
- package/assets/common/component/NodeComponent.ts.meta +0 -9
- package/assets/common/component.meta +0 -12
- package/assets/common/system/MoveSystem.ts +0 -108
- package/assets/common/system/MoveSystem.ts.meta +0 -9
- package/assets/common/system.meta +0 -12
- package/assets/common.meta +0 -12
- package/assets/ecs/EcsComponent.ts +0 -244
- package/assets/ecs/EcsComponent.ts.meta +0 -9
- package/assets/ecs/EcsDirty.ts.meta +0 -9
- package/assets/ecs/EcsEntity.ts +0 -430
- package/assets/ecs/EcsEntity.ts.meta +0 -9
- package/assets/ecs/EcsSingleton.ts +0 -6
- package/assets/ecs/EcsSingleton.ts.meta +0 -9
- package/assets/ecs/EcsSystem.ts +0 -191
- package/assets/ecs/EcsSystem.ts.meta +0 -9
- package/assets/ecs.meta +0 -12
- package/assets/ecs.ts +0 -339
- package/assets/ecs.ts.meta +0 -9
- package/assets/lib/EcsCache.ts +0 -43
- package/assets/lib/EcsCache.ts.meta +0 -9
- package/assets/lib/EcsFilter.ts +0 -210
- package/assets/lib/EcsFilter.ts.meta +0 -9
- package/assets/lib/EcsManager.ts +0 -502
- package/assets/lib/EcsManager.ts.meta +0 -9
- package/assets/lib/EcsObject.ts.meta +0 -9
- package/assets/lib/EcsTimer.ts +0 -239
- package/assets/lib/EcsTimer.ts.meta +0 -9
- package/assets/lib/EcsTween.ts +0 -486
- package/assets/lib/EcsTween.ts.meta +0 -9
- package/assets/lib/EcsUtils.ts +0 -352
- package/assets/lib/EcsUtils.ts.meta +0 -9
- package/assets/lib.meta +0 -12
- package/assets.meta +0 -9
- package/index.ts.meta +0 -9
- package/package.json.meta +0 -11
- /package/{.cj-ecs.md → README.md} +0 -0
|
@@ -1,422 +1,360 @@
|
|
|
1
|
-
import { Node } from 'cc';
|
|
2
|
-
import type { EcsDirtyMask, IEcsComponentDirtySink, IEcsObservedQuery } from '../ecs/EcsDirty';
|
|
3
|
-
import { UuidMaker } from './EcsUtils';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
protected abstract
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
static
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
*
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
*
|
|
239
|
-
*/
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
*
|
|
243
|
-
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
*
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
*
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
*
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
*
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
query
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
*
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
findByUuid(uuid: IEntityUUID): IEntity | null;
|
|
362
|
-
/**
|
|
363
|
-
* 根据uuid查询实体是否存在
|
|
364
|
-
*/
|
|
365
|
-
existByUuid(uuid: IEntityUUID): boolean;
|
|
366
|
-
/**
|
|
367
|
-
* 添加系统
|
|
368
|
-
*/
|
|
369
|
-
addSystem<T extends ITypeofSystem>(System: T): void
|
|
370
|
-
/**
|
|
371
|
-
* 移除系统
|
|
372
|
-
*/
|
|
373
|
-
removeSystem<T extends ITypeofSystem>(System: T): void
|
|
374
|
-
/**
|
|
375
|
-
* 添加单例组件
|
|
376
|
-
*/
|
|
377
|
-
addSingleton<T extends ITypeofSingleton>(param: T): InstanceType<T>
|
|
378
|
-
/**
|
|
379
|
-
* 添加单例组件
|
|
380
|
-
*/
|
|
381
|
-
addSingleton<T extends ISingleton>(param: T): T
|
|
382
|
-
/**
|
|
383
|
-
* 获取单例组件
|
|
384
|
-
*/
|
|
385
|
-
getSingleton<T extends ITypeofSingleton>(param: T): InstanceType<T> | null
|
|
386
|
-
/**
|
|
387
|
-
* 移除单例组件
|
|
388
|
-
*/
|
|
389
|
-
removeSingleton<T extends ITypeofSingleton>(param: T): InstanceType<T> | null
|
|
390
|
-
/**
|
|
391
|
-
* 创建一个实体
|
|
392
|
-
*/
|
|
393
|
-
createEntity<T extends ITypeofEntity>(Entity: T, options?: Node | { node?: Node }): InstanceType<T>
|
|
394
|
-
/**
|
|
395
|
-
* 清理系统、实体、组件、单例组件(都不会触发生命周期)
|
|
396
|
-
*/
|
|
397
|
-
clear(): any
|
|
398
|
-
/**
|
|
399
|
-
* 开始批量组件增删,延迟刷新系统 matcher
|
|
400
|
-
*/
|
|
401
|
-
beginMutation(): void
|
|
402
|
-
/**
|
|
403
|
-
* 结束批量组件增删,并刷新受影响实体的系统 matcher
|
|
404
|
-
*/
|
|
405
|
-
endMutation(): void
|
|
406
|
-
setDirtySink(sink: IEcsComponentDirtySink | null): void
|
|
407
|
-
getDirtySink(): IEcsComponentDirtySink | null
|
|
408
|
-
setObservedQuery(query: IEcsObservedQuery | null): void
|
|
409
|
-
getObservedQuery(): IEcsObservedQuery | null
|
|
410
|
-
/**
|
|
411
|
-
* 用于逻辑帧
|
|
412
|
-
* 执行顺序:
|
|
413
|
-
* [系统的beforeExecute] -> [系统的execute] ->[系统的afterExecute]
|
|
414
|
-
*/
|
|
415
|
-
execute(dt: number, ...args: any[]): any
|
|
416
|
-
/**
|
|
417
|
-
* 用于渲染帧
|
|
418
|
-
* 执行顺序:
|
|
419
|
-
* [系统的beforeUpdate] -> [系统的update] -> [系统的afterUpdate]
|
|
420
|
-
*/
|
|
421
|
-
update(dt: number, ...args: any[]): any
|
|
422
|
-
}
|
|
1
|
+
import { Node } from 'cc';
|
|
2
|
+
import type { EcsDirtyMask, IEcsComponentDirtySink, IEcsObservedQuery } from '../ecs/EcsDirty';
|
|
3
|
+
import { UuidMaker } from './EcsUtils';
|
|
4
|
+
/**
|
|
5
|
+
* 过滤器
|
|
6
|
+
*/
|
|
7
|
+
export interface IFilter {
|
|
8
|
+
/**
|
|
9
|
+
* 有这些组件中的任何一个
|
|
10
|
+
*/
|
|
11
|
+
any(...args: ITypeofComponent[]): this;
|
|
12
|
+
/**
|
|
13
|
+
* 必须包含所有这些组件
|
|
14
|
+
* - 让数量最少的组件作为第一个参数,会获得更好的性能
|
|
15
|
+
*/
|
|
16
|
+
all(...args: ITypeofComponent[]): this;
|
|
17
|
+
/**
|
|
18
|
+
* 仅仅只有这些组件
|
|
19
|
+
* - 让数量最少的组件作为第一个参数,会获得更好的性能
|
|
20
|
+
*/
|
|
21
|
+
only(...args: ITypeofComponent[]): this;
|
|
22
|
+
/**
|
|
23
|
+
* 不能包含其中的任何一个组件
|
|
24
|
+
*/
|
|
25
|
+
exclude(...args: ITypeofComponent[]): this;
|
|
26
|
+
}
|
|
27
|
+
/**uuid生成器 */
|
|
28
|
+
export declare const entityUuidMaker: UuidMaker;
|
|
29
|
+
export declare const componentUuidMaker: UuidMaker;
|
|
30
|
+
export declare const systemUuidMaker: UuidMaker;
|
|
31
|
+
export declare const singletonUuidMaker: UuidMaker;
|
|
32
|
+
export declare abstract class EcsBase {
|
|
33
|
+
/**类名 */
|
|
34
|
+
static ecsName: string;
|
|
35
|
+
/**类名 */
|
|
36
|
+
get ecsName(): string;
|
|
37
|
+
}
|
|
38
|
+
/**实体基类 */
|
|
39
|
+
export declare abstract class EcsBaseEntity extends EcsBase {
|
|
40
|
+
static updateUUID(ins: EcsBaseEntity): void;
|
|
41
|
+
static init(entity: EcsBaseEntity, ecs: IECS, node?: Node | null): void;
|
|
42
|
+
static addComponent(entity: EcsBaseEntity, com: IComponent): void;
|
|
43
|
+
static removeComponent(entity: EcsBaseEntity, com: IComponent): void;
|
|
44
|
+
/**唯一ID */
|
|
45
|
+
private _uuid;
|
|
46
|
+
get uuid(): number;
|
|
47
|
+
/**允许回收复用(默认false) */
|
|
48
|
+
static allowRecycling: boolean;
|
|
49
|
+
/**允许回收复用(默认false) */
|
|
50
|
+
get allowRecycling(): boolean;
|
|
51
|
+
/**添加*/
|
|
52
|
+
protected abstract onAdd(): any;
|
|
53
|
+
/**生效*/
|
|
54
|
+
protected abstract onEnable(): any;
|
|
55
|
+
/**失效*/
|
|
56
|
+
protected abstract onDisable(): any;
|
|
57
|
+
/**移除*/
|
|
58
|
+
protected abstract onRemove(): any;
|
|
59
|
+
/**
|
|
60
|
+
* 内部初始化函数
|
|
61
|
+
*/
|
|
62
|
+
protected abstract innerInit(ecs: IECS, node?: Node | null): void;
|
|
63
|
+
/**
|
|
64
|
+
* 添加组件(内部调用)
|
|
65
|
+
*/
|
|
66
|
+
protected abstract innerAddComponent(com: IComponent): void;
|
|
67
|
+
/**
|
|
68
|
+
* 移除组件(内部调用)
|
|
69
|
+
*/
|
|
70
|
+
protected abstract innerRemoveComponent(com: IComponent): void;
|
|
71
|
+
}
|
|
72
|
+
/**组件基类 */
|
|
73
|
+
export declare abstract class EcsBaseComponent extends EcsBase {
|
|
74
|
+
/**内部函数 */
|
|
75
|
+
static updateUUID(ins: EcsBaseComponent): void;
|
|
76
|
+
/**唯一ID */
|
|
77
|
+
private _uuid;
|
|
78
|
+
get uuid(): number;
|
|
79
|
+
/**允许回收复用(默认false) */
|
|
80
|
+
static allowRecycling: boolean;
|
|
81
|
+
/**允许回收复用(默认false) */
|
|
82
|
+
get allowRecycling(): boolean;
|
|
83
|
+
/**允许在同一个实体中重复添加(默认false) */
|
|
84
|
+
static allowMultiple: boolean;
|
|
85
|
+
/**允许在同一个实体中重复添加(默认false) */
|
|
86
|
+
get allowMultiple(): boolean;
|
|
87
|
+
/**添加*/
|
|
88
|
+
protected abstract onAdd(): any;
|
|
89
|
+
/**生效*/
|
|
90
|
+
protected abstract onEnable(): any;
|
|
91
|
+
/**失效*/
|
|
92
|
+
protected abstract onDisable(): any;
|
|
93
|
+
/**移除*/
|
|
94
|
+
protected abstract onRemove(): any;
|
|
95
|
+
}
|
|
96
|
+
/**系统基类 */
|
|
97
|
+
export declare abstract class EcsBaseSystem extends EcsBase {
|
|
98
|
+
/**唯一ID */
|
|
99
|
+
private _uuid;
|
|
100
|
+
get uuid(): number;
|
|
101
|
+
static onAdd(system: EcsBaseSystem): void;
|
|
102
|
+
static onRemove(system: EcsBaseSystem): void;
|
|
103
|
+
static execute(system: EcsBaseSystem, dt: number, args: any[]): void;
|
|
104
|
+
static beforeExecute(system: EcsBaseSystem, dt: number, args: any[]): void;
|
|
105
|
+
static afterExecute(system: EcsBaseSystem, dt: number, args: any[]): void;
|
|
106
|
+
static update(system: EcsBaseSystem, dt: number, args: any[]): void;
|
|
107
|
+
static beforeUpdate(system: EcsBaseSystem, dt: number, args: any[]): void;
|
|
108
|
+
static afterUpdate(system: EcsBaseSystem, dt: number, args: any[]): void;
|
|
109
|
+
/**添加*/
|
|
110
|
+
protected abstract onAdd(): any;
|
|
111
|
+
/**移除*/
|
|
112
|
+
protected abstract onRemove(): any;
|
|
113
|
+
protected abstract execute(dt?: number, ...args: any[]): any;
|
|
114
|
+
protected abstract beforeExecute(dt?: number, ...args: any[]): any;
|
|
115
|
+
protected abstract afterExecute(dt?: number, ...args: any[]): any;
|
|
116
|
+
protected abstract update(dt?: number, ...args: any[]): any;
|
|
117
|
+
protected abstract beforeUpdate(dt?: number, ...args: any[]): any;
|
|
118
|
+
protected abstract afterUpdate(dt?: number, ...args: any[]): any;
|
|
119
|
+
}
|
|
120
|
+
/**单例基类 */
|
|
121
|
+
export declare abstract class EcsBaseSingleton extends EcsBase {
|
|
122
|
+
/**唯一ID */
|
|
123
|
+
private _uuid;
|
|
124
|
+
get uuid(): number;
|
|
125
|
+
}
|
|
126
|
+
export type IEntityUUID = number;
|
|
127
|
+
export type IComponentName = string;
|
|
128
|
+
export type IComponentUUID = number;
|
|
129
|
+
export type IFlag = number[];
|
|
130
|
+
export type ITypeofEntity = {
|
|
131
|
+
new (): IEntity;
|
|
132
|
+
ecsName: string;
|
|
133
|
+
allowRecycling: boolean;
|
|
134
|
+
};
|
|
135
|
+
export type ITypeofComponent = {
|
|
136
|
+
new (): IComponent;
|
|
137
|
+
ecsName: string;
|
|
138
|
+
allowRecycling: boolean;
|
|
139
|
+
allowMultiple: boolean;
|
|
140
|
+
};
|
|
141
|
+
export type ITypeofSystem = {
|
|
142
|
+
new (ecs: IECS): ISystem;
|
|
143
|
+
ecsName: string;
|
|
144
|
+
};
|
|
145
|
+
export type ITypeofSingleton = {
|
|
146
|
+
new (): ISingleton;
|
|
147
|
+
ecsName: string;
|
|
148
|
+
};
|
|
149
|
+
export interface IEntity extends EcsBaseEntity {
|
|
150
|
+
/**
|
|
151
|
+
* 是否有效
|
|
152
|
+
*/
|
|
153
|
+
readonly isValid: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* 绑定的节点
|
|
156
|
+
*/
|
|
157
|
+
node: Node | null;
|
|
158
|
+
/**
|
|
159
|
+
* 标记是否生效(为false后将不会被查询到)
|
|
160
|
+
*/
|
|
161
|
+
enabled: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* 销毁
|
|
164
|
+
* 会在触发onDisable和移除所有组件之后才会isValid设为false
|
|
165
|
+
*/
|
|
166
|
+
destroy(): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* 检查是否仅包含全部
|
|
169
|
+
*/
|
|
170
|
+
checkFlagAll(flag: IFlag): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* 检查是否包含任一
|
|
173
|
+
*/
|
|
174
|
+
checkFlagAny(flag: IFlag): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* 检查是否仅包含全部
|
|
177
|
+
*/
|
|
178
|
+
checkFlagOnly(flag: IFlag): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* 是否存在指定名字的启用组件
|
|
181
|
+
*/
|
|
182
|
+
hasEnabledComponentName(componentName: IComponentName): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* 添加相应类型的组件
|
|
185
|
+
* @see 同add
|
|
186
|
+
* @param param 类型
|
|
187
|
+
*/
|
|
188
|
+
addComponent<T extends ITypeofComponent>(Com: T): InstanceType<T> | null;
|
|
189
|
+
/**
|
|
190
|
+
* 添加相应类型的组件
|
|
191
|
+
* @param param 类型
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
add<T extends ITypeofComponent>(Com: T): InstanceType<T> | null;
|
|
195
|
+
/**
|
|
196
|
+
* 移除相应类型的第一个组件
|
|
197
|
+
* @see 同remove
|
|
198
|
+
* @param param 类型
|
|
199
|
+
*/
|
|
200
|
+
removeComponent(Com: ITypeofComponent | IComponent): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* 移除相应类型的第一个组件
|
|
203
|
+
* @param param 类型
|
|
204
|
+
*/
|
|
205
|
+
remove(Com: ITypeofComponent | IComponent): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* 移除相应组件的所有组件
|
|
208
|
+
* @see 同removeAll
|
|
209
|
+
* @param Com 类型
|
|
210
|
+
*/
|
|
211
|
+
removeComponents(Com: ITypeofComponent): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* 移除相应组件的所有组件
|
|
214
|
+
* @param Com 类型
|
|
215
|
+
* @returns
|
|
216
|
+
*/
|
|
217
|
+
removeAll(Com: ITypeofComponent): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* 有没有相应类型的组件
|
|
220
|
+
* @see 同has
|
|
221
|
+
*/
|
|
222
|
+
hasComponent(Com: ITypeofComponent): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* 有没有相应类型的组件
|
|
225
|
+
*/
|
|
226
|
+
has(Com: ITypeofComponent): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* 获取相应类型的组件
|
|
229
|
+
* @see 同get
|
|
230
|
+
*/
|
|
231
|
+
getComponent<T extends ITypeofComponent>(Com: T): InstanceType<T> | null;
|
|
232
|
+
/**
|
|
233
|
+
* 获取相应类型的组件
|
|
234
|
+
*/
|
|
235
|
+
get<T extends ITypeofComponent>(Com: T): InstanceType<T> | null;
|
|
236
|
+
/**
|
|
237
|
+
* 获取相应类型的组件
|
|
238
|
+
* @see 同getAll
|
|
239
|
+
*/
|
|
240
|
+
getComponents<T extends ITypeofComponent>(Com: T): InstanceType<T>[];
|
|
241
|
+
/**
|
|
242
|
+
* 获取相应类型的组件
|
|
243
|
+
*/
|
|
244
|
+
getAll<T extends ITypeofComponent>(Com: T): InstanceType<T>[];
|
|
245
|
+
}
|
|
246
|
+
export interface IComponent<E extends IEntity = IEntity> extends EcsBaseComponent {
|
|
247
|
+
/**是否有效*/
|
|
248
|
+
readonly isValid: boolean;
|
|
249
|
+
/**是否有效(如果当前正处于销毁流程中,也会返回false)*/
|
|
250
|
+
readonly isStrictValid: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* 标记是否生效(为false代表不会被查询到)
|
|
253
|
+
*/
|
|
254
|
+
enabled: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* 表示该组件是否被启用并且所在的实体也处于启用状态(为false代表不会被查询到)
|
|
257
|
+
*/
|
|
258
|
+
readonly enabledInHierarchy: boolean;
|
|
259
|
+
/**当前组件所在的实体 */
|
|
260
|
+
readonly entity: E | null;
|
|
261
|
+
readonly dirty: boolean;
|
|
262
|
+
readonly dirtyMask: EcsDirtyMask;
|
|
263
|
+
readonly dirtyVersion: number;
|
|
264
|
+
hasDirty(mask: EcsDirtyMask): boolean;
|
|
265
|
+
markDirty(mask?: EcsDirtyMask): void;
|
|
266
|
+
clearDirty(mask?: EcsDirtyMask): void;
|
|
267
|
+
clearDirtySilent(): void;
|
|
268
|
+
/**销毁当前组件 */
|
|
269
|
+
destroy(): boolean;
|
|
270
|
+
}
|
|
271
|
+
export type ISystem = EcsBaseSystem;
|
|
272
|
+
export type ISingleton = EcsBaseSingleton;
|
|
273
|
+
export interface IECS {
|
|
274
|
+
/**
|
|
275
|
+
* 查询实体
|
|
276
|
+
*/
|
|
277
|
+
query<T extends IEntity>(filter: IFilter): T[];
|
|
278
|
+
query<T extends IComponent>(filter: IFilter, Component: {
|
|
279
|
+
new (): T;
|
|
280
|
+
}): T[];
|
|
281
|
+
query<T>(filter: IFilter, Component?: ITypeofComponent): T[];
|
|
282
|
+
/**
|
|
283
|
+
* 查询实体
|
|
284
|
+
*/
|
|
285
|
+
find<T extends IEntity>(filter: IFilter): T;
|
|
286
|
+
find<T extends IComponent>(filter: IFilter, Component: {
|
|
287
|
+
new (): T;
|
|
288
|
+
}): T;
|
|
289
|
+
find<T>(filter: IFilter, Component?: ITypeofComponent): T;
|
|
290
|
+
/**
|
|
291
|
+
* 查询实体是否存在
|
|
292
|
+
*/
|
|
293
|
+
exist(filter: IFilter): boolean;
|
|
294
|
+
/**
|
|
295
|
+
* 根据uuid查询实体
|
|
296
|
+
*/
|
|
297
|
+
findByUuid(uuid: IEntityUUID): IEntity | null;
|
|
298
|
+
/**
|
|
299
|
+
* 根据uuid查询实体是否存在
|
|
300
|
+
*/
|
|
301
|
+
existByUuid(uuid: IEntityUUID): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* 添加系统
|
|
304
|
+
*/
|
|
305
|
+
addSystem<T extends ITypeofSystem>(System: T): void;
|
|
306
|
+
/**
|
|
307
|
+
* 移除系统
|
|
308
|
+
*/
|
|
309
|
+
removeSystem<T extends ITypeofSystem>(System: T): void;
|
|
310
|
+
/**
|
|
311
|
+
* 添加单例组件
|
|
312
|
+
*/
|
|
313
|
+
addSingleton<T extends ITypeofSingleton>(param: T): InstanceType<T>;
|
|
314
|
+
/**
|
|
315
|
+
* 添加单例组件
|
|
316
|
+
*/
|
|
317
|
+
addSingleton<T extends ISingleton>(param: T): T;
|
|
318
|
+
/**
|
|
319
|
+
* 获取单例组件
|
|
320
|
+
*/
|
|
321
|
+
getSingleton<T extends ITypeofSingleton>(param: T): InstanceType<T> | null;
|
|
322
|
+
/**
|
|
323
|
+
* 移除单例组件
|
|
324
|
+
*/
|
|
325
|
+
removeSingleton<T extends ITypeofSingleton>(param: T): InstanceType<T> | null;
|
|
326
|
+
/**
|
|
327
|
+
* 创建一个实体
|
|
328
|
+
*/
|
|
329
|
+
createEntity<T extends ITypeofEntity>(Entity: T, options?: Node | {
|
|
330
|
+
node?: Node;
|
|
331
|
+
}): InstanceType<T>;
|
|
332
|
+
/**
|
|
333
|
+
* 清理系统、实体、组件、单例组件(都不会触发生命周期)
|
|
334
|
+
*/
|
|
335
|
+
clear(): any;
|
|
336
|
+
/**
|
|
337
|
+
* 开始批量组件增删,延迟刷新系统 matcher
|
|
338
|
+
*/
|
|
339
|
+
beginMutation(): void;
|
|
340
|
+
/**
|
|
341
|
+
* 结束批量组件增删,并刷新受影响实体的系统 matcher
|
|
342
|
+
*/
|
|
343
|
+
endMutation(): void;
|
|
344
|
+
setDirtySink(sink: IEcsComponentDirtySink | null): void;
|
|
345
|
+
getDirtySink(): IEcsComponentDirtySink | null;
|
|
346
|
+
setObservedQuery(query: IEcsObservedQuery | null): void;
|
|
347
|
+
getObservedQuery(): IEcsObservedQuery | null;
|
|
348
|
+
/**
|
|
349
|
+
* 用于逻辑帧
|
|
350
|
+
* 执行顺序:
|
|
351
|
+
* [系统的beforeExecute] -> [系统的execute] ->[系统的afterExecute]
|
|
352
|
+
*/
|
|
353
|
+
execute(dt: number, ...args: any[]): any;
|
|
354
|
+
/**
|
|
355
|
+
* 用于渲染帧
|
|
356
|
+
* 执行顺序:
|
|
357
|
+
* [系统的beforeUpdate] -> [系统的update] -> [系统的afterUpdate]
|
|
358
|
+
*/
|
|
359
|
+
update(dt: number, ...args: any[]): any;
|
|
360
|
+
}
|