diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 36c7c8b0..b8eb0e0b 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -302,15 +302,13 @@ export class HeroAttrsComp extends ecs.Comp { // 更新临时型buff for (const attrIndex in this.BUFFS_TEMP) { const buffs = this.BUFFS_TEMP[attrIndex]; - buffs.forEach(buff => { + for (let i = buffs.length - 1; i >= 0; i--) { + const buff = buffs[i]; buff.remainTime -= dt; if (buff.remainTime <= 0) { - const index = buffs.indexOf(buff); - if (index > -1) { - buffs.splice(index, 1); - } + buffs.splice(i, 1); } - }); + } if (buffs.length === 0) { delete this.BUFFS_TEMP[attrIndex]; affectedAttrs.add(parseInt(attrIndex));