fix: 收敛战斗内存增长并强化战斗结束清理

This commit is contained in:
panw
2026-03-18 16:46:52 +08:00
parent 56227d8f3f
commit 035066752c
7 changed files with 155 additions and 58 deletions

View File

@@ -25,9 +25,16 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
debugMode: boolean = false; // 是否启用调试模式
private readonly emptyCastPlan = { skillId: 0, isFriendly: false, targetPos: null as Vec3 | null, targetEids: [] as number[] };
private readonly meleeCastRange = 64;
private heroMatcher: ecs.IMatcher | null = null;
private getHeroMatcher(): ecs.IMatcher {
if (!this.heroMatcher) {
this.heroMatcher = ecs.allOf(HeroAttrsComp, HeroViewComp);
}
return this.heroMatcher;
}
filter(): ecs.IMatcher {
return ecs.allOf(HeroAttrsComp, HeroViewComp);
return this.getHeroMatcher();
}
update(e: ecs.Entity): void {
@@ -181,7 +188,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
const currentX = heroView.node.position.x;
let nearest: HeroViewComp | null = null;
let minDist = Infinity;
ecs.query(this.filter()).forEach(entity => {
ecs.query(this.getHeroMatcher()).forEach(entity => {
const attrs = entity.get(HeroAttrsComp);
const view = entity.get(HeroViewComp);
if (!attrs || !view?.node) return;