mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-07 19:07:30 +08:00
补ECS注释
This commit is contained in:
@@ -4,6 +4,11 @@ import { ECSMatcher } from "./ECSMatcher";
|
||||
import { CompCtor, CompType, ECSModel, EntityCtor } from "./ECSModel";
|
||||
import { ECSComblockSystem, ECSRootSystem, ECSSystem } from "./ECSSystem";
|
||||
|
||||
/**
|
||||
* ECSEntity对象在destroy后,会回收到ECSModel.entityPool实体对象池中
|
||||
* ECSComp对象从ECSEntity.remove后,数据组件会回收到ECSModel.compPools组件对象池中
|
||||
*/
|
||||
|
||||
/** Entity-Component-System(实体-组件-系统)框架 */
|
||||
export module ecs {
|
||||
/** 实体 - 一个概念上的定义,指的是游戏世界中的一个独特物体,是一系列组件的集合 */
|
||||
@@ -138,7 +143,7 @@ export module ecs {
|
||||
ctor.tid = ECSModel.compTid++;
|
||||
ctor.compName = name;
|
||||
if (canNew) {
|
||||
ECSModel.compCtors.push(ctor);
|
||||
ECSModel.compCtors.push(ctor); // 注册不同类型的组件
|
||||
ECSModel.compPools.set(ctor.tid, []);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -241,15 +241,19 @@ export class ECSEntity {
|
||||
comp.ent = null;
|
||||
if (isRecycle) {
|
||||
comp.reset();
|
||||
|
||||
// 回收组件到指定缓存池中
|
||||
if (comp.canRecycle) {
|
||||
ECSModel.compPools.get(componentTypeId)!.push(comp);
|
||||
const compPoolsType = ECSModel.compPools.get(componentTypeId)!;
|
||||
compPoolsType.push(comp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.compTid2Obj.set(componentTypeId, comp);
|
||||
this.compTid2Obj.set(componentTypeId, comp); // 用于缓存显示对象组件
|
||||
}
|
||||
}
|
||||
|
||||
// 删除实体上的组件逻辑
|
||||
if (hasComp) {
|
||||
//@ts-ignore
|
||||
this[compName] = null;
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ECSModel {
|
||||
static compTid = 0;
|
||||
/** 组件缓存池 */
|
||||
static compPools: Map<number, ecs.IComp[]> = new Map();
|
||||
/** 组件构造函数 */
|
||||
/** 组件构造函数,用于ecs.register注册时,记录不同类型的组件 */
|
||||
static compCtors: (CompCtor<any> | number)[] = [];
|
||||
/**
|
||||
* 每个组件的添加和删除的动作都要派送到“关心”它们的group上。goup对当前拥有或者之前(删除前)拥有该组件的实体进行组件规则判断。判断该实体是否满足group
|
||||
|
||||
@@ -62,10 +62,10 @@ export class ModuleUtil {
|
||||
* @param ent 模块实体
|
||||
* @param ctor 界面逻辑组件
|
||||
* @param uiId 界面资源编号
|
||||
* @param isDestroy 是否释放界面缓存
|
||||
* @param isDestroy 是否释放界面缓存(默认为释放界面缓存)
|
||||
*/
|
||||
public static removeViewUi(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy?: boolean) {
|
||||
ent.remove(ctor);
|
||||
public static removeViewUi(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy: boolean = true) {
|
||||
ent.remove(ctor, isDestroy);
|
||||
oops.gui.remove(uiId, isDestroy);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user