fix: 收敛战斗内存增长并强化战斗结束清理
This commit is contained in:
@@ -11,11 +11,34 @@ import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,Sp
|
||||
export class Tooltip extends ecs.Entity {
|
||||
/** 对象池 */
|
||||
static pool: NodePool = new NodePool();
|
||||
static readonly MAX_POOL_SIZE: number = 80;
|
||||
|
||||
/** 回收节点 */
|
||||
static put(node: Node) {
|
||||
if (!node || !node.isValid) return;
|
||||
if (this.pool.size() >= this.MAX_POOL_SIZE) {
|
||||
node.destroy();
|
||||
return;
|
||||
}
|
||||
node.active = false;
|
||||
node.parent = null;
|
||||
this.pool.put(node);
|
||||
}
|
||||
static clearPool() {
|
||||
while (this.pool.size() > 0) {
|
||||
const node = this.pool.get();
|
||||
if (node && node.isValid) {
|
||||
node.destroy();
|
||||
}
|
||||
}
|
||||
this.pool.clear();
|
||||
}
|
||||
static getPoolStats() {
|
||||
return {
|
||||
total: this.pool.size(),
|
||||
max: this.MAX_POOL_SIZE
|
||||
};
|
||||
}
|
||||
|
||||
/** ---------- 数据层 ---------- */
|
||||
// SkillModel!: SkillModelComp;
|
||||
|
||||
Reference in New Issue
Block a user