mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-08 03:16:49 +08:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
/*
|
||
* @Author: dgflash
|
||
* @Date: 2021-11-11 19:05:32
|
||
* @LastEditors: dgflash
|
||
* @LastEditTime: 2022-09-06 17:20:51
|
||
*/
|
||
|
||
import { UIRemove } from '../../core/gui/layer/LayerUIElement';
|
||
import { ecs } from '../../libs/ecs/ECS';
|
||
import { ECSModel } from '../../libs/ecs/ECSModel';
|
||
import { GameComponent } from './GameComponent';
|
||
import { ModuleUtil } from './ModuleUtil';
|
||
|
||
/**
|
||
* 游戏显示对象组件
|
||
*
|
||
* 功能介绍:
|
||
* 1. 对象拥有 cc.Component 组件功能与 ecs.Comp 组件功能
|
||
* 2. 对象自带全局事件监听、释放、发送全局消息功能
|
||
* 3. 对象管理的所有节点摊平,直接通过节点名获取cc.Node对象
|
||
*
|
||
* 应用场景
|
||
* 1. 网络游戏,优先有数据对象,然后创建视图对象,当释放视图组件时,部分场景不希望释放数据对象
|
||
*
|
||
* @example
|
||
@ccclass('RoleViewComp')
|
||
@ecs.register('RoleView', false)
|
||
export class RoleViewComp extends CCComp {
|
||
@property({ type: sp.Skeleton, tooltip: '角色动画' })
|
||
spine: sp.Skeleton = null!;
|
||
|
||
onLoad(){
|
||
|
||
}
|
||
}
|
||
*/
|
||
export abstract class CCComp extends GameComponent implements ecs.IComp {
|
||
static tid: number = -1;
|
||
static compName: string;
|
||
|
||
canRecycle!: boolean;
|
||
ent!: ecs.Entity;
|
||
tid: number = -1;
|
||
|
||
/** 从父节点移除自己 */
|
||
remove(params?: UIRemove) {
|
||
const cct = ECSModel.compCtors[this.tid];
|
||
ModuleUtil.remove(this.ent, cct, params);
|
||
}
|
||
|
||
abstract reset(): void;
|
||
} |