@ives_xxz/framework 1.4.11 → 1.4.12
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/manager/FWLayerManager.ts +20 -21
- package/package-lock.json.meta +6 -0
- package/package.json +1 -1
|
@@ -85,9 +85,9 @@ class FWLayerDataManager {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* 状态表注册
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
addRegistry(type: new () => FW.LayerController): boolean {
|
|
91
91
|
if (this.layerRegistry.has(type)) {
|
|
92
92
|
return true;
|
|
93
93
|
}
|
|
@@ -144,7 +144,7 @@ class FWLayerDataManager {
|
|
|
144
144
|
/**
|
|
145
145
|
* 清理失败的Layer
|
|
146
146
|
*/
|
|
147
|
-
|
|
147
|
+
clearFailedLayer(layerData: FWLayerData): void {
|
|
148
148
|
this.layerMap.delete(layerData.controllerConstructor);
|
|
149
149
|
this.layerRegistry.delete(layerData.controllerConstructor);
|
|
150
150
|
}
|
|
@@ -259,7 +259,7 @@ class FWLayerOpenManager {
|
|
|
259
259
|
return this.getUndefinedResult(isAsync);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
if (this.dataManager.
|
|
262
|
+
if (this.dataManager.addRegistry(data.type)) {
|
|
263
263
|
const proxy = this.dataManager.getExistingProxy(data.type);
|
|
264
264
|
return this.wrapResult(proxy, isAsync) as Ctr;
|
|
265
265
|
}
|
|
@@ -271,9 +271,9 @@ class FWLayerOpenManager {
|
|
|
271
271
|
this.dataManager.addLayerData(data.type, layerData);
|
|
272
272
|
|
|
273
273
|
if (isAsync) {
|
|
274
|
-
return this.
|
|
274
|
+
return this.asyncGenerationLayer(layerData, data);
|
|
275
275
|
} else {
|
|
276
|
-
return this.
|
|
276
|
+
return this.syncGenerationLayer(layerData, data) as Ctr;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
|
|
@@ -303,43 +303,43 @@ class FWLayerOpenManager {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
|
-
*
|
|
306
|
+
* 异步生成Layer
|
|
307
307
|
*/
|
|
308
|
-
private async
|
|
308
|
+
private async asyncGenerationLayer<Ctr extends FW.LayerController = FW.LayerController>(
|
|
309
309
|
layerData: FWLayerData,
|
|
310
310
|
data: FW.LayerOpenArgs,
|
|
311
311
|
): Promise<Ctr> {
|
|
312
312
|
try {
|
|
313
313
|
const res = await this.resourceManager.loadLayerAsync(layerData);
|
|
314
|
-
return this.
|
|
314
|
+
return this.createLayer(layerData, res, data) as Ctr;
|
|
315
315
|
} catch (e) {
|
|
316
|
-
FWLog.error(`
|
|
317
|
-
this.dataManager.
|
|
316
|
+
FWLog.error(`asyncGenerationLayer failed:`, e);
|
|
317
|
+
this.dataManager.clearFailedLayer(layerData);
|
|
318
318
|
throw e;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
/**
|
|
323
|
-
*
|
|
323
|
+
* 同步创建Layer
|
|
324
324
|
*/
|
|
325
|
-
private
|
|
325
|
+
private syncGenerationLayer<Ctr extends FW.LayerController = FW.LayerController>(
|
|
326
326
|
layerData: FWLayerData,
|
|
327
327
|
data: FW.LayerOpenArgs,
|
|
328
328
|
): Ctr {
|
|
329
329
|
try {
|
|
330
330
|
const res = this.resourceManager.loadLayerSync(layerData);
|
|
331
|
-
return this.
|
|
331
|
+
return this.createLayer(layerData, res, data);
|
|
332
332
|
} catch (e) {
|
|
333
|
-
FWLog.error(`
|
|
334
|
-
this.dataManager.
|
|
333
|
+
FWLog.error(`syncGenerationLayer failed:`, e);
|
|
334
|
+
this.dataManager.clearFailedLayer(layerData);
|
|
335
335
|
return undefined;
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
/**
|
|
340
|
-
* 创建Layer
|
|
340
|
+
* 创建Layer
|
|
341
341
|
*/
|
|
342
|
-
private
|
|
342
|
+
private createLayer<Ctr extends FW.LayerController = FW.LayerController>(
|
|
343
343
|
layerData: FWLayerData,
|
|
344
344
|
res: { asset: cc.Prefab; uuid: string },
|
|
345
345
|
data: FW.LayerOpenArgs,
|
|
@@ -365,10 +365,9 @@ class FWLayerOpenManager {
|
|
|
365
365
|
|
|
366
366
|
this.dataManager.removeFromRegistry(layerData.controllerConstructor);
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
layerData.controllerProxy = proxy;
|
|
368
|
+
layerData.controllerProxy = this.dataManager.createControllerProxy(layerData);
|
|
370
369
|
|
|
371
|
-
return
|
|
370
|
+
return layerData.controllerProxy as Ctr;
|
|
372
371
|
}
|
|
373
372
|
}
|
|
374
373
|
|