refactor(hero): 重构英雄属性与状态管理
- 将增益效果属性组移到武器进化属性后以优化结构 - 新增 in_stun 和 in_frost 状态标志替代 isStun/isFrost 方法 - 更新状态检查逻辑以使用新的状态标志 - 移除 HeroSkillsComp 依赖以简化移动系统 - 修改伤害计算直接使用 HeroAttrsComp 属性而非 Attrs 映射 - 简化暴击、击退等判定逻辑,移除闪避和抗性计算 - 优化 reset 方法,设置合理的默认值并重置新增状态标志 - 添加状态变化时的调试日志输出
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { HeroSkillsComp } from "./HeroSkills";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { FacSet, IndexSet } from "../common/config/GameSet";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
@@ -38,7 +37,7 @@ export class MonMoveComp extends ecs.Comp {
|
||||
@ecs.register('MonMoveSystem')
|
||||
export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||
filter(): ecs.IMatcher {
|
||||
return ecs.allOf(MonMoveComp, HeroViewComp, HeroAttrsComp, HeroSkillsComp);
|
||||
return ecs.allOf(MonMoveComp, HeroViewComp, HeroAttrsComp);
|
||||
}
|
||||
|
||||
update(e: ecs.Entity) {
|
||||
@@ -61,7 +60,7 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
if (!move.moving) return;
|
||||
|
||||
// 2. 异常状态检查 (死亡/复活/眩晕/冰冻)
|
||||
if (model.is_stop || model.is_dead || model.isStun() || model.isFrost()) {
|
||||
if (model.is_stop || model.is_dead || model.in_stun|| model.in_frost) {
|
||||
view.status_change("idle");
|
||||
return;
|
||||
}
|
||||
@@ -136,7 +135,7 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
view.status_change("idle");
|
||||
model.is_atking = true;
|
||||
} else {
|
||||
const speed = model.Attrs[Attrs.SPEED] / 3;
|
||||
const speed = model.speed / 3;
|
||||
this.moveEntity(view, move.direction, speed);
|
||||
model.is_atking = false;
|
||||
}
|
||||
@@ -162,7 +161,7 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
this.performRetreat(view, move, model, currentX);
|
||||
} else if (dist > maxRange) {
|
||||
// 太远了,追击
|
||||
const speed = model.Attrs[Attrs.SPEED] / 3;
|
||||
const speed = model.speed / 3;
|
||||
this.moveEntity(view, move.direction, speed);
|
||||
model.is_atking = false;
|
||||
} else {
|
||||
@@ -192,7 +191,7 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
this.performRetreat(view, move, model, currentX);
|
||||
} else if (dist > maxRange) {
|
||||
// 太远了,追击
|
||||
const speed = model.Attrs[Attrs.SPEED] / 3;
|
||||
const speed = model.speed / 3;
|
||||
this.moveEntity(view, move.direction, speed);
|
||||
model.is_atking = false;
|
||||
} else {
|
||||
@@ -207,7 +206,7 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
const safeRetreatX = currentX - move.direction * 50;
|
||||
// 怪物活动范围通常宽一些
|
||||
if (safeRetreatX >= -450 && safeRetreatX <= 450) {
|
||||
const retreatSpeed = (model.Attrs[Attrs.SPEED] / 3) * 0.8;
|
||||
const retreatSpeed = (model.speed / 3) * 0.8;
|
||||
this.moveEntity(view, -move.direction, retreatSpeed);
|
||||
model.is_atking = false;
|
||||
} else {
|
||||
@@ -227,7 +226,7 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
|
||||
if (Math.abs(currentX - targetX) > 5) {
|
||||
const dir = targetX > currentX ? 1 : -1;
|
||||
const speed = model.Attrs[Attrs.SPEED] / 3;
|
||||
const speed = model.speed / 3;
|
||||
|
||||
// 修正朝向
|
||||
move.direction = dir;
|
||||
|
||||
Reference in New Issue
Block a user