This commit is contained in:
donggang
2024-02-26 18:09:02 +08:00
parent c2cdfc42ab
commit c09363f8c8
3 changed files with 45 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
import { Node, __private } from "cc";
import { oops } from "../../core/Oops";
import { UICallbacks } from "../../core/gui/layer/Defines";
import { ecs } from "../../libs/ecs/ECS";
import { CCComp } from "./CCComp";
import { CCVMParentComp } from "./CCVMParentComp";
import { CompType } from "../../libs/ecs/ECSModel";
export class ModuleUtil {
public static addView<T extends CCVMParentComp | CCComp>(
ent: ecs.Entity,
ctor: __private._types_globals__Constructor<T> | __private._types_globals__AbstractedConstructor<T>,
uiId: number,
uiArgs: any = null) {
var uic: UICallbacks = {
onAdded: (node: Node, params: any) => {
var comp = node.getComponent(ctor) as ecs.Comp;
ent.add(comp);
}
};
oops.gui.open(uiId, uiArgs, uic);
}
public static removeView(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy: boolean = true) {
ent.remove(ctor);
oops.gui.remove(uiId, isDestroy);
}
}