@ives_xxz/framework 1.4.15 → 1.5.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/FW.d.ts +61 -44
- package/Framework.ts +95 -3
- package/FrameworkBase.ts +62 -0
- package/FrameworkBase.ts.meta +10 -0
- package/config/FWSystemConfig.ts +18 -0
- package/controller/FWLayerController.ts +3 -2
- package/data/FWData.ts +2 -5
- package/define/FWEventDefine.ts +4 -0
- package/define/FWSystemDefine.ts +5 -0
- package/entry/FWEntry.ts +9 -18
- package/logic/FWLogic.ts +4 -7
- package/manager/FWAssetManager.ts +62 -67
- package/manager/FWAudioManager.ts +230 -185
- package/manager/FWBundleManager.ts +6 -7
- package/manager/FWEngineManager.ts +8 -0
- package/manager/FWEventManager.ts +91 -2
- package/manager/FWLayerManager.ts +2 -2
- package/manager/FWManager.ts +4 -51
- package/manager/FWObjectManager.ts +100 -33
- package/manager/FWPerformanceManager.ts +32 -34
- package/manager/FWPromiseManager.ts +21 -24
- package/manager/FWResManager.ts +5 -5
- package/manager/FWTaskManager.ts +3 -1
- package/manager/FWTimeManager.ts +12 -40
- package/package.json +1 -1
- package/service/FWService.ts +6 -50
- package/service/http/FWHttp.ts +39 -34
- package/service/socket/FWSocket.ts +7 -11
package/FW.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare namespace FW {
|
|
|
47
47
|
getDepend(bundleName: string): string[];
|
|
48
48
|
update(dt: number): void;
|
|
49
49
|
initialize(): void;
|
|
50
|
-
|
|
50
|
+
restart(): void;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
type Manager = {};
|
|
@@ -57,7 +57,8 @@ declare namespace FW {
|
|
|
57
57
|
executor: (
|
|
58
58
|
resolve: (value: T | PromiseLike<T>) => void,
|
|
59
59
|
reject: (reason?: any) => void,
|
|
60
|
-
signal
|
|
60
|
+
signal?: AbortSignal,
|
|
61
|
+
reason?: any,
|
|
61
62
|
) => void = PromiseExcutor,
|
|
62
63
|
options: PromiseExecuteOptions = {},
|
|
63
64
|
): PromiseProxy<T>;
|
|
@@ -180,6 +181,10 @@ declare namespace FW {
|
|
|
180
181
|
|
|
181
182
|
/** 销毁一个对象池 */
|
|
182
183
|
destroyObjectPool(tag: string): void;
|
|
184
|
+
/** 获取对象池状态 */
|
|
185
|
+
getPoolStats(): { total: number; tags: string[] };
|
|
186
|
+
/** 清理所有对象池 */
|
|
187
|
+
clearAllPools(): void;
|
|
183
188
|
};
|
|
184
189
|
|
|
185
190
|
type ObjectPool = {
|
|
@@ -317,6 +322,7 @@ declare namespace FW {
|
|
|
317
322
|
type Observer = {
|
|
318
323
|
priority: number;
|
|
319
324
|
intercept: boolean;
|
|
325
|
+
once: boolean;
|
|
320
326
|
/**
|
|
321
327
|
* 事件通知
|
|
322
328
|
*/
|
|
@@ -452,13 +458,52 @@ declare namespace FW {
|
|
|
452
458
|
*/
|
|
453
459
|
register(
|
|
454
460
|
eventName: string | number,
|
|
455
|
-
cb: (
|
|
461
|
+
cb: (
|
|
462
|
+
args1?: EventManagerArgs,
|
|
463
|
+
args2?: EventManagerArgs,
|
|
464
|
+
args3?: EventManagerArgs,
|
|
465
|
+
args4?: EventManagerArgs,
|
|
466
|
+
args5?: EventManagerArgs,
|
|
467
|
+
args6?: EventManagerArgs,
|
|
468
|
+
args7?: EventManagerArgs,
|
|
469
|
+
args8?: EventManagerArgs,
|
|
470
|
+
args9?: EventManagerArgs,
|
|
471
|
+
args10?: EventManagerArgs,
|
|
472
|
+
) => void,
|
|
456
473
|
target: TargetType,
|
|
457
474
|
options?: {
|
|
458
475
|
priority?: FWSystemDefine.FWPriorityOrder;
|
|
459
476
|
intercept?: boolean;
|
|
460
477
|
},
|
|
461
478
|
);
|
|
479
|
+
|
|
480
|
+
registerOnce(
|
|
481
|
+
eventName: string | number,
|
|
482
|
+
cb: (
|
|
483
|
+
args1?: EventManagerArgs,
|
|
484
|
+
args2?: EventManagerArgs,
|
|
485
|
+
args3?: EventManagerArgs,
|
|
486
|
+
args4?: EventManagerArgs,
|
|
487
|
+
args5?: EventManagerArgs,
|
|
488
|
+
args6?: EventManagerArgs,
|
|
489
|
+
args7?: EventManagerArgs,
|
|
490
|
+
args8?: EventManagerArgs,
|
|
491
|
+
args9?: EventManagerArgs,
|
|
492
|
+
args10?: EventManagerArgs,
|
|
493
|
+
) => void,
|
|
494
|
+
target: TargetType,
|
|
495
|
+
options?: {
|
|
496
|
+
priority?: number;
|
|
497
|
+
intercept?: boolean;
|
|
498
|
+
},
|
|
499
|
+
): void;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* 获取事件监听器数量
|
|
503
|
+
* @param eventName 事件名
|
|
504
|
+
* @returns 监听器数量
|
|
505
|
+
*/
|
|
506
|
+
getListenerCount(eventName: string | number): number;
|
|
462
507
|
/**
|
|
463
508
|
* 派发事件
|
|
464
509
|
* @param eventName
|
|
@@ -972,6 +1017,7 @@ declare namespace FW {
|
|
|
972
1017
|
type EngineManager = {
|
|
973
1018
|
debug: boolean;
|
|
974
1019
|
getMemory(): void;
|
|
1020
|
+
restart(): void;
|
|
975
1021
|
};
|
|
976
1022
|
|
|
977
1023
|
type Layer = {
|
|
@@ -1162,6 +1208,8 @@ declare namespace FW {
|
|
|
1162
1208
|
* 获取所有任务
|
|
1163
1209
|
*/
|
|
1164
1210
|
getAllTasks(): FW.Task[];
|
|
1211
|
+
|
|
1212
|
+
onDestroy();
|
|
1165
1213
|
};
|
|
1166
1214
|
|
|
1167
1215
|
type StateManager = {
|
|
@@ -1575,48 +1623,11 @@ declare namespace FW {
|
|
|
1575
1623
|
* @param mute
|
|
1576
1624
|
*/
|
|
1577
1625
|
setSoundMute(mute: boolean): void;
|
|
1578
|
-
/**
|
|
1579
|
-
* 播放音效
|
|
1580
|
-
* @param path
|
|
1581
|
-
* @param loop
|
|
1582
|
-
*/
|
|
1583
|
-
playEffect(path: string, loop?: boolean): Promise<number>;
|
|
1584
|
-
/**
|
|
1585
|
-
* 播放音效
|
|
1586
|
-
* @param audio
|
|
1587
|
-
* @param loop
|
|
1588
|
-
*/
|
|
1589
|
-
playEffect(audio: cc.AudioClip, loop?: boolean): Promise<number>;
|
|
1590
|
-
/**
|
|
1591
|
-
* 播放音效
|
|
1592
|
-
* @param assetProperty
|
|
1593
|
-
* @param loop
|
|
1594
|
-
*/
|
|
1595
|
-
playEffect(assetProperty: FW.AssetProperty, loop?: boolean): Promise<number>;
|
|
1596
|
-
/**
|
|
1597
|
-
* 停止音效
|
|
1598
|
-
* @param audioID
|
|
1599
|
-
*/
|
|
1600
|
-
stopEffect(audioID: number): void;
|
|
1601
|
-
/**
|
|
1602
|
-
* 设置音效音量
|
|
1603
|
-
* @param volume
|
|
1604
|
-
*/
|
|
1605
|
-
setEffectsVolume(volume: number): void;
|
|
1606
|
-
/**
|
|
1607
|
-
* 停止全部音效
|
|
1608
|
-
*/
|
|
1609
|
-
stopAllEffects(): void;
|
|
1610
|
-
/**
|
|
1611
|
-
* 设置音效是否静音
|
|
1612
|
-
* @param mute
|
|
1613
|
-
*/
|
|
1614
|
-
setEffectsMute(mute: boolean): void;
|
|
1615
1626
|
};
|
|
1616
1627
|
|
|
1617
1628
|
type PerformanceManager = {
|
|
1618
1629
|
recordOperationMetric(manager: string, operation: string, duration: number): void;
|
|
1619
|
-
|
|
1630
|
+
getModuleReport(manager: string): PerformanceReport;
|
|
1620
1631
|
getAllReports(): Map<string, FW.PerformanceReport>;
|
|
1621
1632
|
};
|
|
1622
1633
|
|
|
@@ -1839,6 +1850,10 @@ declare namespace FW {
|
|
|
1839
1850
|
* 重置
|
|
1840
1851
|
*/
|
|
1841
1852
|
reset(): void;
|
|
1853
|
+
/**
|
|
1854
|
+
* 停止任务
|
|
1855
|
+
*/
|
|
1856
|
+
stop(): void;
|
|
1842
1857
|
/**
|
|
1843
1858
|
* 获取任务性能报告
|
|
1844
1859
|
*/
|
|
@@ -1918,9 +1933,11 @@ declare namespace FW {
|
|
|
1918
1933
|
resolve: (value: T | PromiseLike<T>) => void,
|
|
1919
1934
|
reject: (reason?: any) => void,
|
|
1920
1935
|
signal: AbortSignal,
|
|
1936
|
+
reason?: any,
|
|
1921
1937
|
) => void;
|
|
1922
1938
|
|
|
1923
1939
|
type PromiseExecuteOptions = {
|
|
1940
|
+
reason?: any;
|
|
1924
1941
|
timeout?: number;
|
|
1925
1942
|
retryCount?: number;
|
|
1926
1943
|
retryInterval?: number;
|
|
@@ -1940,7 +1957,7 @@ declare namespace FW {
|
|
|
1940
1957
|
/**
|
|
1941
1958
|
* 性能管理器配置
|
|
1942
1959
|
*/
|
|
1943
|
-
type
|
|
1960
|
+
type PerformanceModuleOptions = {
|
|
1944
1961
|
/** 是否自动收集性能数据 */
|
|
1945
1962
|
autoCollect?: boolean;
|
|
1946
1963
|
/** 性能数据保留时间(毫秒) */
|
|
@@ -1955,7 +1972,7 @@ declare namespace FW {
|
|
|
1955
1972
|
* 性能统计报告
|
|
1956
1973
|
*/
|
|
1957
1974
|
type PerformanceReport = {
|
|
1958
|
-
|
|
1975
|
+
module: string;
|
|
1959
1976
|
totalOperations: number;
|
|
1960
1977
|
averageDuration: number;
|
|
1961
1978
|
minDuration: number;
|
|
@@ -1967,7 +1984,7 @@ declare namespace FW {
|
|
|
1967
1984
|
* 性能指标数据
|
|
1968
1985
|
*/
|
|
1969
1986
|
type PerformanceMetric = {
|
|
1970
|
-
|
|
1987
|
+
module: string;
|
|
1971
1988
|
operation: string;
|
|
1972
1989
|
duration: number;
|
|
1973
1990
|
timestamp: number;
|
package/Framework.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Container, interfaces } from 'inversify';
|
|
3
3
|
import { FWSystemDefine } from './define/FWSystemDefine';
|
|
4
|
+
import FWLog from './log/FWLog';
|
|
5
|
+
import { FWEventDefine } from './define/FWEventDefine';
|
|
4
6
|
|
|
5
7
|
class Framework {
|
|
6
8
|
private container: Container;
|
|
7
9
|
private registry: Map<string, new () => FW.Registry>;
|
|
10
|
+
private registeredComponents: Map<string, FW.RegisterFramework[]> = new Map();
|
|
8
11
|
private static instance: Framework;
|
|
9
12
|
private constructor() {}
|
|
10
13
|
|
|
@@ -14,6 +17,7 @@ class Framework {
|
|
|
14
17
|
autoBindInjectable: true,
|
|
15
18
|
});
|
|
16
19
|
this.registry = new Map<string, new () => FW.Registry>();
|
|
20
|
+
this.registeredComponents.clear();
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
public static getInstance() {
|
|
@@ -63,6 +67,7 @@ class Framework {
|
|
|
63
67
|
return this.getComponents(serviceIdentifier)[0];
|
|
64
68
|
}
|
|
65
69
|
}
|
|
70
|
+
|
|
66
71
|
/** 获取所有组件 */
|
|
67
72
|
public getComponents<T>(serviceIdentifier: FW.ServiceIdentifier<T>): T[] {
|
|
68
73
|
const binder = (this.container as any)._bindingDictionary;
|
|
@@ -112,7 +117,10 @@ class Framework {
|
|
|
112
117
|
* @param bundleName
|
|
113
118
|
*/
|
|
114
119
|
getRegistry(bundleName: string): FW.Registry {
|
|
115
|
-
|
|
120
|
+
if (this.registry.has(bundleName)) {
|
|
121
|
+
return this.container.get(this.registry.get(bundleName));
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
/**
|
|
@@ -145,7 +153,10 @@ class Framework {
|
|
|
145
153
|
this.container.bind(this.getKey(data.bundleName, index)).toService(cls);
|
|
146
154
|
}
|
|
147
155
|
});
|
|
156
|
+
|
|
157
|
+
this.recordRegistration(data);
|
|
148
158
|
}
|
|
159
|
+
|
|
149
160
|
/**
|
|
150
161
|
* 注销数据
|
|
151
162
|
* @param data
|
|
@@ -156,14 +167,95 @@ class Framework {
|
|
|
156
167
|
classes.forEach((cls, index) => {
|
|
157
168
|
const key = this.getKey(data.bundleName, index);
|
|
158
169
|
if (cls && this.container.isBound(cls)) {
|
|
159
|
-
this.container.get(key)['onDestroy']?.();
|
|
170
|
+
this.container.get(key)?.['onDestroy']?.();
|
|
160
171
|
this.container.unbind(cls);
|
|
161
172
|
}
|
|
162
173
|
if (this.container.isBound(key)) {
|
|
163
|
-
this.container.get(key)['onDestroy']?.();
|
|
174
|
+
this.container.get(key)?.['onDestroy']?.();
|
|
164
175
|
this.container.unbind(this.getKey(data.bundleName, index));
|
|
165
176
|
}
|
|
166
177
|
});
|
|
178
|
+
|
|
179
|
+
this.removeRegistration(data);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private recordRegistration(data: FW.RegisterFramework) {
|
|
183
|
+
const bundleName = data.bundleName;
|
|
184
|
+
if (!this.registeredComponents.has(bundleName)) {
|
|
185
|
+
this.registeredComponents.set(bundleName, []);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const registrations = this.registeredComponents.get(bundleName)!;
|
|
189
|
+
const exists = registrations.some(
|
|
190
|
+
(reg) => reg.logic === data.logic && reg.data === data.data && reg.config === data.config,
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
if (!exists) {
|
|
194
|
+
registrations.push({ ...data });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private removeRegistration(data: FW.RegisterFramework) {
|
|
199
|
+
const bundleName = data.bundleName;
|
|
200
|
+
if (this.registeredComponents.has(bundleName)) {
|
|
201
|
+
const registrations = this.registeredComponents.get(bundleName)!;
|
|
202
|
+
const index = registrations.findIndex(
|
|
203
|
+
(reg) => reg.logic === data.logic && reg.data === data.data && reg.config === data.config,
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
if (index !== -1) {
|
|
207
|
+
registrations.splice(index, 1);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (registrations.length === 0) {
|
|
211
|
+
this.registeredComponents.delete(bundleName);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public restart(): void {
|
|
217
|
+
this.destroyAllComponents();
|
|
218
|
+
this.container.unbindAll();
|
|
219
|
+
this.container = new Container({
|
|
220
|
+
defaultScope: 'Singleton',
|
|
221
|
+
autoBindInjectable: true,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
this.reregisterAllComponents();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private destroyAllComponents(): void {
|
|
228
|
+
const binder = (this.container as any)._bindingDictionary;
|
|
229
|
+
const map = binder._map;
|
|
230
|
+
|
|
231
|
+
for (const [key, bindings] of map.entries()) {
|
|
232
|
+
for (const binding of bindings) {
|
|
233
|
+
try {
|
|
234
|
+
if (this.container.isBound(binding.serviceIdentifier)) {
|
|
235
|
+
const instance = this.container.get(binding.serviceIdentifier);
|
|
236
|
+
instance?.['onDestroy']?.();
|
|
237
|
+
}
|
|
238
|
+
} catch (e) {
|
|
239
|
+
FWLog.warn(`Error destroying component ${key}:`, e);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private reregisterAllComponents(): void {
|
|
246
|
+
for (const [bundleName, registrations] of this.registeredComponents.entries()) {
|
|
247
|
+
for (const data of registrations) {
|
|
248
|
+
try {
|
|
249
|
+
this.register(data);
|
|
250
|
+
} catch (e) {
|
|
251
|
+
console.error(`Error re-registering component for bundle ${bundleName}:`, e);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public getRegisteredComponents(): Map<string, FW.RegisterFramework[]> {
|
|
258
|
+
return new Map(this.registeredComponents);
|
|
167
259
|
}
|
|
168
260
|
|
|
169
261
|
private getKey(bundleName: string, tag: FWSystemDefine.FWBindTag) {
|
package/FrameworkBase.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FWEventDefine } from './define/FWEventDefine';
|
|
2
|
+
import FWLog from './log/FWLog';
|
|
3
|
+
|
|
4
|
+
export abstract class FrameworkBase {
|
|
5
|
+
public readonly entry: FW.Entry = FW.Entry;
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
this.initialize();
|
|
9
|
+
|
|
10
|
+
this.entry.evtMgr.register(FWEventDefine.SystemEvent.SYSTEM_RESTART, this.onRestart, this);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public abstract initialize?(): void;
|
|
14
|
+
public abstract onDestroy?(): void;
|
|
15
|
+
|
|
16
|
+
protected get moduleName(): string {
|
|
17
|
+
return this.constructor.name;
|
|
18
|
+
}
|
|
19
|
+
protected onRestart?(): void;
|
|
20
|
+
|
|
21
|
+
protected async invoke<T>(operation: Promise<T>, operationName: string = 'unknown'): Promise<T> {
|
|
22
|
+
const startTime = this.getCurrentTime();
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const result = await operation;
|
|
26
|
+
const duration = this.getCurrentTime() - startTime;
|
|
27
|
+
this.recordPerformanceMetric(operationName, duration);
|
|
28
|
+
return result;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
this.handleError(operationName, error);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private recordPerformanceMetric(operationName: string, duration: number): void {
|
|
36
|
+
if (FW.Entry.performanceMgr) {
|
|
37
|
+
FW.Entry.performanceMgr.recordOperationMetric(this.moduleName, operationName, duration);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const shouldWarn = duration > 1000;
|
|
41
|
+
|
|
42
|
+
if (FW.Entry.engineMgr.debug || shouldWarn) {
|
|
43
|
+
const log = shouldWarn ? FWLog.warn : FWLog.debug;
|
|
44
|
+
log(`[${this.moduleName?.toUpperCase()}] Operation ${operationName} took ${duration}ms`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected handleError(operation: string, error: any): void {
|
|
49
|
+
const errorInfo = {
|
|
50
|
+
type: this.moduleName,
|
|
51
|
+
operation,
|
|
52
|
+
error: error?.message || error,
|
|
53
|
+
stack: error?.stack,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
FWLog.error(`Error in ${this.moduleName}.${operation}:`, errorInfo);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected getCurrentTime(): number {
|
|
60
|
+
return Date.now();
|
|
61
|
+
}
|
|
62
|
+
}
|
package/config/FWSystemConfig.ts
CHANGED
|
@@ -8,4 +8,22 @@ export namespace FWSystemConfig {
|
|
|
8
8
|
protocolSymbol: null,
|
|
9
9
|
protocolPollingTime: 10,
|
|
10
10
|
};
|
|
11
|
+
|
|
12
|
+
export const PromiseConfig = {
|
|
13
|
+
loadAsset: {
|
|
14
|
+
retryCount: 3,
|
|
15
|
+
retryInterval: 5,
|
|
16
|
+
timeout: 10,
|
|
17
|
+
},
|
|
18
|
+
loadBundle: {
|
|
19
|
+
retryCount: 3,
|
|
20
|
+
retryInterval: 5,
|
|
21
|
+
timeout: 10,
|
|
22
|
+
},
|
|
23
|
+
http: {
|
|
24
|
+
retryCount: 3,
|
|
25
|
+
retryInterval: 5,
|
|
26
|
+
timeout: 10,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
11
29
|
}
|
|
@@ -2,7 +2,8 @@ import { FWSystemDefine } from '../define/FWSystemDefine';
|
|
|
2
2
|
import FWLayer from '../layer/FWLayer';
|
|
3
3
|
import { FWLayerData } from '../manager/FWLayerManager';
|
|
4
4
|
import FWLog from '../log/FWLog';
|
|
5
|
-
|
|
5
|
+
import { FrameworkBase } from '../FrameworkBase';
|
|
6
|
+
export abstract class FWLayerController extends FrameworkBase implements FW.LayerController {
|
|
6
7
|
readonly entry: FW.Entry = FW.Entry;
|
|
7
8
|
/** layer数据 */
|
|
8
9
|
layerData: FWLayerData;
|
|
@@ -33,8 +34,8 @@ export abstract class FWLayerController implements FW.LayerController {
|
|
|
33
34
|
onEnable?();
|
|
34
35
|
onDisable?();
|
|
35
36
|
onDestroy?();
|
|
36
|
-
async onClose?();
|
|
37
37
|
initialize() {}
|
|
38
|
+
async onClose?();
|
|
38
39
|
|
|
39
40
|
async destroy() {
|
|
40
41
|
FW.Entry.timeMgr?.unSchedule(this);
|
package/data/FWData.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { injectable } from 'inversify';
|
|
2
|
+
import { FrameworkBase } from '../FrameworkBase';
|
|
2
3
|
@injectable()
|
|
3
|
-
export default class FWData implements FW.Data {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.initialize?.();
|
|
6
|
-
}
|
|
7
|
-
public readonly entry: FW.Entry = FW.Entry;
|
|
4
|
+
export default class FWData extends FrameworkBase implements FW.Data {
|
|
8
5
|
public initialize?(): void;
|
|
9
6
|
public onDestroy?(): void;
|
|
10
7
|
}
|
package/define/FWEventDefine.ts
CHANGED
package/define/FWSystemDefine.ts
CHANGED
package/entry/FWEntry.ts
CHANGED
|
@@ -108,9 +108,9 @@ export default class FWEntry implements FW.Entry {
|
|
|
108
108
|
* */
|
|
109
109
|
initialize() {
|
|
110
110
|
this.map = new Map<string, FW.RegisterBundle>();
|
|
111
|
+
this.evtMgr = new FWEventManager();
|
|
111
112
|
this.engineMgr = new FWEngineManager();
|
|
112
113
|
this.taskMgr = new FWTaskManager();
|
|
113
|
-
this.evtMgr = new FWEventManager();
|
|
114
114
|
this.resMgr = new FWResManager();
|
|
115
115
|
this.layerMgr = new FWLayerManager();
|
|
116
116
|
this.timeMgr = new FWTimeManager();
|
|
@@ -140,6 +140,10 @@ export default class FWEntry implements FW.Entry {
|
|
|
140
140
|
@FWSocketAutoProcessPause()
|
|
141
141
|
launchScene(name: string): void {
|
|
142
142
|
FW.Entry.layerMgr.clear();
|
|
143
|
+
if (this.bundleAutoRelease(this.bundleName)) {
|
|
144
|
+
this.releaseBundle(this.bundleName);
|
|
145
|
+
}
|
|
146
|
+
|
|
143
147
|
if (!this.hasSceneName(name)) {
|
|
144
148
|
try {
|
|
145
149
|
cc.director.loadScene(name);
|
|
@@ -148,13 +152,14 @@ export default class FWEntry implements FW.Entry {
|
|
|
148
152
|
FWLog.error('launchScene failed:', name);
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
|
-
if (this.bundleAutoRelease(this.bundleName)) {
|
|
152
|
-
this.releaseBundle(this.bundleName);
|
|
153
|
-
}
|
|
154
155
|
this.bundleName = name;
|
|
155
156
|
cc.director.loadScene(this.getSceneName());
|
|
156
157
|
}
|
|
157
158
|
|
|
159
|
+
restart() {
|
|
160
|
+
this.engineMgr?.restart();
|
|
161
|
+
}
|
|
162
|
+
|
|
158
163
|
releaseBundle(bundleName: string) {
|
|
159
164
|
this.resMgr.releaseBundle(bundleName);
|
|
160
165
|
const depend = this.getDepend(bundleName);
|
|
@@ -207,20 +212,6 @@ export default class FWEntry implements FW.Entry {
|
|
|
207
212
|
getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (serviceIdentifier) =>
|
|
208
213
|
Framework.getComponents(serviceIdentifier);
|
|
209
214
|
|
|
210
|
-
onDestroy() {
|
|
211
|
-
this.resMgr.onDestroy();
|
|
212
|
-
this.layerMgr.onDestroy();
|
|
213
|
-
this.timeMgr.onDestroy();
|
|
214
|
-
this.animationMgr.onDestroy();
|
|
215
|
-
this.stateMgr.onDestroy();
|
|
216
|
-
|
|
217
|
-
this.resMgr = null;
|
|
218
|
-
this.layerMgr = null;
|
|
219
|
-
this.timeMgr = null;
|
|
220
|
-
this.animationMgr = null;
|
|
221
|
-
this.stateMgr = null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
215
|
update(dt: number) {
|
|
225
216
|
this.timeMgr?.onUpdate(dt);
|
|
226
217
|
}
|
package/logic/FWLogic.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { injectable } from 'inversify';
|
|
2
|
+
import { FrameworkBase } from '../FrameworkBase';
|
|
2
3
|
@injectable()
|
|
3
|
-
export default class FWLogic implements FW.Logic {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
public readonly entry: FW.Entry = FW.Entry;
|
|
8
|
-
public initialize?();
|
|
9
|
-
public onDestroy?();
|
|
4
|
+
export default class FWLogic extends FrameworkBase implements FW.Logic {
|
|
5
|
+
initialize?();
|
|
6
|
+
onDestroy?();
|
|
10
7
|
}
|