refactor(技能系统): 重构技能施放系统并优化位置初始化

- 将SkillCastSystem重命名为SCastSystem和SACastSystem以区分不同功能
- 优化SMoveComp中位置属性的初始化,改为null避免不必要的对象创建
- 统一日志前缀使用系统名称提高可读性
- 在SACastSystem中添加目标位置检查逻辑
- 修复代码格式问题,统一缩进和注释风格
This commit is contained in:
2025-10-31 11:05:44 +08:00
parent 2b3b80b308
commit 3b21ee4048
3 changed files with 32 additions and 17 deletions

View File

@@ -24,8 +24,8 @@ import { CSRequestComp } from "../skill/STagComps";
* - 施法检查与执行分离
* - 自动处理资源消耗和CD重置
*/
// @ecs.register('SkillCastSystem')
export class SkillCastSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
// @ecs.register('SCastSystem')
export class SCastSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
/**
* 过滤器:拥有技能数据 + 施法请求的实体
@@ -45,7 +45,7 @@ export class SkillCastSystem extends ecs.ComblockSystem implements ecs.IEntityEn
// 1. 验证数据完整性
if (!skillsComp || !heroAttrs || !request || !heroView) {
console.warn("[SkillCastSystem] 数据不完整,取消施法");
console.warn("[SCastSystem] 数据不完整,取消施法");
e.remove(CSRequestComp);
return;
}
@@ -53,7 +53,7 @@ export class SkillCastSystem extends ecs.ComblockSystem implements ecs.IEntityEn
// 2. 获取技能数据
const skill = skillsComp.getSkill(request.s_uuid);
if (!skill) {
console.warn(`[SkillCastSystem] 技能索引无效: ${request.s_uuid }`);
console.warn(`[SCastSystem] 技能索引无效: ${request.s_uuid }`);
e.remove(CSRequestComp);
return;
}
@@ -103,7 +103,7 @@ export class SkillCastSystem extends ecs.ComblockSystem implements ecs.IEntityEn
private executeCast(casterEntity: ecs.Entity, skill: any, targets: Vec3[], heroView: HeroViewComp) {
const config = SkillSet[skill.uuid];
if (!config) {
console.error("[SkillCastSystem] 技能配置不存在:", skill.uuid);
console.error("[SCastSystem] 技能配置不存在:", skill.uuid);
return;
}
@@ -117,7 +117,7 @@ export class SkillCastSystem extends ecs.ComblockSystem implements ecs.IEntityEn
}, delay);
const heroAttrs = casterEntity.get(HeroAttrsComp);
console.log(`[SkillCastSystem] ${heroAttrs?.hero_name ?? '未知'} 施放技能: ${config.name}`);
console.log(`[SCastSystem] ${heroAttrs?.hero_name ?? '未知'} 施放技能: ${config.name}`);
}
/**
@@ -126,14 +126,14 @@ export class SkillCastSystem extends ecs.ComblockSystem implements ecs.IEntityEn
private createSkill(skillId: number, caster: HeroViewComp, targets: Vec3[]) {
// 检查节点有效性
if (!caster.node || !caster.node.isValid) {
console.warn("[SkillCastSystem] 施法者节点无效");
console.warn("[SCastSystem] 施法者节点无效");
return;
}
// 获取场景节点
const parent = caster.node.parent;
if (!parent) {
console.warn("[SkillCastSystem] 场景节点无效");
console.warn("[SCastSystem] 场景节点无效");
return;
}