refactor(skill): 统一技能效果处理逻辑至 SkillView

移除 SCastSystem 中的 applySupportSkill 方法,将治疗、护盾、Buff/Debuff 效果统一在 SkillView 的碰撞逻辑中处理。同时删除 SkillConfig 中的 SType 枚举,改为通过 buffs 和 debuffs 列表配置效果。
This commit is contained in:
panw
2026-03-12 16:51:14 +08:00
parent 3ba33c5240
commit fac8d571c3
3 changed files with 65 additions and 71 deletions

View File

@@ -2,11 +2,12 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { Vec3 } from "cc";
import { HeroAttrsComp } from "./HeroAttrsComp";
import { HeroViewComp } from "./HeroViewComp";
import { BuffsList, SkillConfig, SkillSet, SType, TGroup, TType } from "../common/config/SkillSet";
import { BuffsList, SkillConfig, SkillSet, TGroup, TType } from "../common/config/SkillSet";
import { Skill } from "../skill/Skill";
import { smc } from "../common/SingletonModuleComp";
import { GameConst } from "../common/config/GameConst";
import { mLogger } from "../common/Logger";
import { Attrs } from "../common/config/HeroAttrs";
/**
* ==================== 自动施法系统 ====================
@@ -71,11 +72,8 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
const delay = GameConst.Battle.SKILL_CAST_DELAY;
heroView.scheduleOnce(() => {
if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return;
if (config.SType === SType.damage) {
this.createSkillEntity(s_uuid, heroView, targets[0].node.position);
} else {
this.applySupportSkill(entity, config, targets);
}
// 始终创建技能实体所有效果伤害、Buff、Debuff均在 SkillView 中处理
this.createSkillEntity(s_uuid, heroView, targets[0].node.position);
}, delay);
if (isMainSkill) {
heroAttrs.triggerSkillCD();
@@ -92,38 +90,6 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
skill.load(caster.node.position.clone(), parent, s_uuid, targetPos.clone(), caster, 0);
}
private applySupportSkill(casterEntity: ecs.Entity, config: SkillConfig, targets: HeroViewComp[]) {
const casterAttrs = casterEntity.get(HeroAttrsComp);
if (!casterAttrs) return;
const ratio = Number(config.ap ?? 0) / 100;
for (const target of targets) {
if (!target.ent) continue;
const model = target.ent.get(HeroAttrsComp);
if (!model || model.is_dead) continue;
if (config.SType === SType.heal) {
const amount = model.hp_max * ratio;
model.add_hp(amount, true);
target.health(amount);
continue;
}
if (config.SType === SType.shield) {
const amount = model.hp_max * ratio;
model.shield_max = Math.max(model.shield_max, amount);
model.add_shield(amount, true);
continue;
}
if (config.SType === SType.buff) {
for (const buffId of config.buffs) {
const buffConf = BuffsList[buffId];
if (buffConf) {
model.addBuff(buffConf);
}
}
}
}
mLogger.log(this.debugMode, "SCastSystem", `[SCastSystem] ${casterAttrs.hero_name} 施放 ${config.name}`);
}
private findTargets(caster: HeroViewComp, casterAttrs: HeroAttrsComp, config: SkillConfig): HeroViewComp[] {
const range = casterAttrs.getCachedMaxSkillDistance() || GameConst.Battle.DEFAULT_SEARCH_RANGE;
const isEnemy = config.TGroup === TGroup.Enemy;