refactor(hero): 重构英雄属性与状态管理
- 将增益效果属性组移到武器进化属性后以优化结构 - 新增 in_stun 和 in_frost 状态标志替代 isStun/isFrost 方法 - 更新状态检查逻辑以使用新的状态标志 - 移除 HeroSkillsComp 依赖以简化移动系统 - 修改伤害计算直接使用 HeroAttrsComp 属性而非 Attrs 映射 - 简化暴击、击退等判定逻辑,移除闪避和抗性计算 - 优化 reset 方法,设置合理的默认值并重置新增状态标志 - 添加状态变化时的调试日志输出
This commit is contained in:
@@ -49,17 +49,19 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
back_chance: number = 0; // 击退概率
|
||||
slow_chance: number = 0; // 减速概率
|
||||
|
||||
// ==================== 增益效果属性 ====================
|
||||
revive_count: number = 0; // 复活次数
|
||||
revive_time: number = 0; // 复活时间
|
||||
invincible_time: number = 0;// 无敌时间
|
||||
|
||||
// ==================== 武器进化相关 ====================
|
||||
puncture: number = 0; // 穿刺次数
|
||||
puncture_dmg: number = 0; // 穿刺伤害
|
||||
wfuny: number = 0; // 风怒
|
||||
|
||||
// ==================== 增益效果属性 ====================
|
||||
revive_count: number = 0; // 复活次数
|
||||
revive_time: number = 0; // 复活时间
|
||||
invincible_time: number = 0;// 无敌时间
|
||||
|
||||
|
||||
in_stun=false
|
||||
in_frost=false
|
||||
|
||||
boom: boolean = false; // 自爆怪
|
||||
|
||||
@@ -303,9 +305,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
private updateStatusFlags() {
|
||||
// 检查特定状态的 Debuff 列表是否为空,来更新 boolean 标志
|
||||
// 例如:冰冻
|
||||
this.checkStatus(Attrs.IN_FROST, 'is_stop'); // 假设冰冻会停止行动
|
||||
// this.checkStatus(Attrs.IN_STUN, 'is_stunned'); // 需要在类里定义 is_stunned
|
||||
this.checkStatus(Attrs.IN_FROST, 'in_frost');
|
||||
this.checkStatus(Attrs.IN_STUN, 'in_stun');
|
||||
}
|
||||
|
||||
private checkStatus(attr: Attrs, flagName: string) {
|
||||
@@ -314,9 +315,11 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
// 只有当状态改变时才赋值,避免每帧赋值
|
||||
if (this[flagName] !== hasBuff) {
|
||||
// 特殊处理:有些状态可能由其他逻辑控制,这里强行覆盖可能会冲突
|
||||
// 但作为 Buff 系统,它应该拥有最高解释权之一
|
||||
this[flagName] = hasBuff;
|
||||
// 状态变化日志
|
||||
if (this.debugMode) {
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', `状态变更: ${this.hero_name}, ${flagName} = ${hasBuff}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,11 +366,12 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.lv = 1;
|
||||
this.type = 0;
|
||||
this.fac = 0;
|
||||
this.rangeType = SkillRange.Melee;
|
||||
this.ap = 0;
|
||||
this.hp = 100;
|
||||
this.hp_max = 100;
|
||||
this.speed = 100;
|
||||
this.dis = 0;
|
||||
this.hp = 100;
|
||||
this.dis = 100;
|
||||
this.shield = 0;
|
||||
this.shield_max = 0;
|
||||
|
||||
@@ -389,12 +393,16 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.puncture_dmg = 0;
|
||||
this.wfuny = 0;
|
||||
this.boom = false;
|
||||
|
||||
this.in_frost = false;
|
||||
this.in_stun = false;
|
||||
|
||||
this.BUFFS = {};
|
||||
this.DEBUFFS = {};
|
||||
// 重置技能距离缓存
|
||||
this.maxSkillDistance = 0;
|
||||
this.minSkillDistance = 0;
|
||||
|
||||
this.is_dead = false;
|
||||
this.is_count_dead = false;
|
||||
this.is_atking = false;
|
||||
@@ -405,9 +413,13 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.is_friend = false;
|
||||
this.is_kalami = false;
|
||||
this.is_reviving = false;
|
||||
|
||||
this.atk_count = 0;
|
||||
this.atked_count = 0;
|
||||
this.killed_count =0;
|
||||
this.atk_id = 0;
|
||||
this.skill_id = 0;
|
||||
|
||||
// 重置脏标签
|
||||
this.dirty_hp = false;
|
||||
this.dirty_shield = false;
|
||||
|
||||
Reference in New Issue
Block a user