refactor(hero): 移除旧版控制buff计时系统,统一用buff管理
完成全量buff系统迁移,删除HeroBuffSystem和旧的计时字段, 所有冰冻/眩晕控制效果改为通过BuffManager管理, 简化了控制状态判定逻辑,移除了新旧系统兼容代码
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { HeroDisVal, HeroInfo, HSkillInfo, HType, SkillTriggerType } from "../common/config/heroSet";
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { FieldSkillSet, FieldSkillType, SkillOverrides } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
@@ -9,6 +8,11 @@ import { Attrs } from "../common/config/HeroAttrs";
|
||||
import { FieldSkillHelper } from "./FieldSkillHelper";
|
||||
import { BuffComp } from "./BuffComp";
|
||||
import { BuffList, ModOp } from "../common/config/BuffSet";
|
||||
import { buffManager } from "./BuffManager";
|
||||
|
||||
/** 控制类 buff 配置 id(对应 BuffList) */
|
||||
const BUFF_ID_FROST = 7003;
|
||||
const BUFF_ID_STUN = 7004;
|
||||
@ecs.register('HeroAttrs')
|
||||
export class HeroAttrsComp extends ecs.Comp {
|
||||
public debugMode: boolean = false;
|
||||
@@ -64,9 +68,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
invincible_time: number = 0;// 无敌时间
|
||||
|
||||
|
||||
frost_end_time: number = 0;
|
||||
stun_end_time: number = 0;
|
||||
|
||||
boom: boolean = false; // 自爆怪
|
||||
|
||||
// ==================== 脏标签标记 ====================
|
||||
@@ -106,8 +107,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
* 从 HeroInfo 读取初始配置,建立属性系统
|
||||
*/
|
||||
initAttrs() {
|
||||
this.frost_end_time = 0;
|
||||
this.stun_end_time = 0;
|
||||
}
|
||||
/*******************基础属性管理********************/
|
||||
|
||||
@@ -167,14 +166,16 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
|
||||
|
||||
/** 施加冰冻:委托 buffManager 写入 BuffComp,duration = FROST_TIME * time */
|
||||
toFrost(time: number = 1) {
|
||||
const frostTime = FightSet.FROST_TIME * time;
|
||||
this.frost_end_time = Math.max(this.frost_end_time, frostTime);
|
||||
if (!this.ent) return;
|
||||
buffManager.applyBuff(this.ent, BUFF_ID_FROST, 0, 0, { duration: FightSet.FROST_TIME * time });
|
||||
}
|
||||
|
||||
/** 施加击晕:委托 buffManager 写入 BuffComp,并清零技能 CD */
|
||||
toStun(time: number = 1) {
|
||||
const stunTime = FightSet.STUN_TIME * time;
|
||||
this.stun_end_time = Math.max(this.stun_end_time, stunTime);
|
||||
if (!this.ent) return;
|
||||
buffManager.applyBuff(this.ent, BUFF_ID_STUN, 0, 0, { duration: FightSet.STUN_TIME * time });
|
||||
|
||||
// 击晕时 CD 清零
|
||||
for (const key in this.skills) {
|
||||
@@ -215,11 +216,13 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
skill.ccd = Math.min(actualCd, skill.ccd + dt);
|
||||
}
|
||||
}
|
||||
/** 是否处于冰冻状态(统一走 BuffComp 判定) */
|
||||
isFrost(): boolean {
|
||||
return this.frost_end_time > 0
|
||||
return !!this.ent && buffManager.hasControl(this.ent, 'frost');
|
||||
}
|
||||
/** 是否处于击晕状态(统一走 BuffComp 判定) */
|
||||
isStun(): boolean {
|
||||
return this.stun_end_time > 0
|
||||
return !!this.ent && buffManager.hasControl(this.ent, 'stun');
|
||||
}
|
||||
getSkillLevel(skillId: number): number {
|
||||
if (!skillId) return 0;
|
||||
@@ -547,9 +550,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.wfuny = 0;
|
||||
this.boom = false;
|
||||
|
||||
this.frost_end_time = 0;
|
||||
this.stun_end_time = 0;
|
||||
|
||||
// 重置技能距离缓存
|
||||
this.maxSkillDistance = 0;
|
||||
this.minSkillDistance = 0;
|
||||
@@ -578,32 +578,5 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
}
|
||||
|
||||
@ecs.register('HeroBuffSystem')
|
||||
export class HeroBuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||
private timer = new Timer(0.1)
|
||||
filter(): ecs.IMatcher {
|
||||
return ecs.allOf(HeroAttrsComp);
|
||||
}
|
||||
|
||||
update(e: ecs.Entity): void {
|
||||
if (this.timer.update(this.dt)) {
|
||||
const attrsComp = e.get(HeroAttrsComp);
|
||||
if (attrsComp.frost_end_time > 0) {
|
||||
attrsComp.frost_end_time -= 0.1;
|
||||
if (attrsComp.frost_end_time <= 0) {
|
||||
attrsComp.frost_end_time = 0;
|
||||
}
|
||||
}
|
||||
if (attrsComp.stun_end_time > 0) {
|
||||
attrsComp.stun_end_time -= 0.1;
|
||||
if (attrsComp.stun_end_time <= 0) {
|
||||
attrsComp.stun_end_time = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user