@ives_xxz/framework 1.5.9 → 1.5.10
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 +21 -29
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ import FWData from "../data/FWData";
|
|
|
10
10
|
import FWSocketSender from "../service/socket/FWSocketSender";
|
|
11
11
|
import FWSocketHandle from "../service/socket/FWSocketHandle";
|
|
12
12
|
import Framework from "../Framework";
|
|
13
|
+
import { FrameworkBase } from "../FrameworkBase";
|
|
13
14
|
|
|
14
15
|
const ADD_EXTERNAL_REFERENCE: string = "addExternalReference";
|
|
15
16
|
|
|
@@ -259,7 +260,8 @@ export class FWLayerData<T extends FW.LayerController = FW.LayerController>
|
|
|
259
260
|
class FWLayerDataManager {
|
|
260
261
|
private layerMap: Map<new () => FW.LayerController, FWLayerData> = new Map();
|
|
261
262
|
private layerRegistry: Set<new () => FW.LayerController> = new Set();
|
|
262
|
-
|
|
263
|
+
private layerControllerFactory: FWLayerControllerFactory =
|
|
264
|
+
new FWLayerControllerFactory();
|
|
263
265
|
/**
|
|
264
266
|
* 获取已存在的Layer
|
|
265
267
|
*/
|
|
@@ -280,7 +282,7 @@ class FWLayerDataManager {
|
|
|
280
282
|
createLayerData<Ctr extends FW.LayerController = FW.LayerController>(
|
|
281
283
|
type: new () => Ctr
|
|
282
284
|
): FW.LayerData {
|
|
283
|
-
const ctr =
|
|
285
|
+
const ctr = this.layerControllerFactory.createController(type);
|
|
284
286
|
const ctrName = cc.js.getClassName(ctr);
|
|
285
287
|
const layerData = this.generationData(ctr);
|
|
286
288
|
|
|
@@ -297,39 +299,12 @@ class FWLayerDataManager {
|
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
301
|
|
|
300
|
-
private findBundleNameByClassName(name: string): string | undefined {
|
|
301
|
-
const registeredComponents = Framework.getRegisteredComponents();
|
|
302
|
-
|
|
303
|
-
const bundleNames = Array.from(registeredComponents.keys());
|
|
304
|
-
|
|
305
|
-
for (const bundleName of bundleNames) {
|
|
306
|
-
if (this.doesClassNameContainBundleName(name, bundleName)) {
|
|
307
|
-
return bundleName;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return undefined;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
private doesClassNameContainBundleName(
|
|
314
|
-
className: string,
|
|
315
|
-
bundleName: string
|
|
316
|
-
): boolean {
|
|
317
|
-
const bundleNameLower = bundleName.toLowerCase();
|
|
318
|
-
const classNameLower = className.toLowerCase();
|
|
319
|
-
return classNameLower.includes(bundleNameLower);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
302
|
/**
|
|
323
303
|
* 生成数据
|
|
324
304
|
*/
|
|
325
305
|
private generationData(ctr: FW.LayerController): FWLayerData {
|
|
326
306
|
const layerData = new FWLayerData();
|
|
327
307
|
const layerType = ctr.layerType;
|
|
328
|
-
const constructorName = ctr.constructor.name;
|
|
329
|
-
const bundleName = this.findBundleNameByClassName(constructorName);
|
|
330
|
-
const configTag = FWSystemDefine.FWBindTag.CONFIG;
|
|
331
|
-
|
|
332
|
-
ctr.config = FW.Entry.getComponent(`${bundleName}${configTag}`);
|
|
333
308
|
|
|
334
309
|
layerData.layerRenderOrder = ctr.renderOrder;
|
|
335
310
|
layerData.layerAssetProperty = ctr.layerAssetProperty;
|
|
@@ -851,3 +826,20 @@ class FWLayerLifecycleManager {
|
|
|
851
826
|
};
|
|
852
827
|
}
|
|
853
828
|
}
|
|
829
|
+
|
|
830
|
+
class FWLayerControllerFactory {
|
|
831
|
+
/**
|
|
832
|
+
* 创建并初始化 LayerController
|
|
833
|
+
*/
|
|
834
|
+
createController<Ctr extends FW.LayerController = FW.LayerController>(
|
|
835
|
+
type: new () => Ctr
|
|
836
|
+
): Ctr {
|
|
837
|
+
const ctr = new type();
|
|
838
|
+
|
|
839
|
+
if (ctr instanceof FrameworkBase) {
|
|
840
|
+
ctr.initializeDependencies?.();
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return ctr;
|
|
844
|
+
}
|
|
845
|
+
}
|