fix: 修复技能节点池逻辑并调整UI显示

- 修复技能节点池获取和回收时的有效性检查,避免无效节点
- 修复技能父节点查找逻辑,增加空值检查
- 调整卡牌UI的文本样式和宽度
- 启用SkillView调试日志以便问题排查
- 修复英雄后撤动画逻辑,取消注释
- 更新加载页面资源引用
This commit is contained in:
panw
2026-03-12 15:58:25 +08:00
parent 01bff64561
commit 9d86be80c7
6 changed files with 2092 additions and 1911 deletions

View File

@@ -22,14 +22,18 @@ export class Skill extends ecs.Entity {
static getFromPool(path: string): Node | null {
if (this.pools.has(path)) {
const pool = this.pools.get(path)!;
if (pool.size() > 0) {
return pool.get();
while (pool.size() > 0) {
const node = pool.get();
if (node && node.isValid) {
return node;
}
}
}
return null;
}
static putToPool(path: string, node: Node) {
if (!node || !node.isValid) return;
if (!this.pools.has(path)) {
this.pools.set(path, new NodePool());
}
@@ -72,10 +76,29 @@ export class Skill extends ecs.Entity {
return;
}
const node: Node = Skill.getFromPool(path) || instantiate(prefab);
if (!node || !node.isValid) {
mLogger.error(this.debugMode, 'Skill', "[Skill] 节点无效:", path);
return;
}
this.prefabPath = path;
this.skillNode = node;
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!.getChildByName("SKILL") || parent;
let skillParent: Node | null = null;
if (smc.map && smc.map.MapView && smc.map.MapView.scene && smc.map.MapView.scene.entityLayer && smc.map.MapView.scene.entityLayer.node) {
skillParent = smc.map.MapView.scene.entityLayer.node.getChildByName("SKILL");
}
if (!skillParent || !skillParent.isValid) {
skillParent = parent;
}
if (!skillParent || !skillParent.isValid) {
mLogger.error(this.debugMode, 'Skill', "[Skill] 父节点无效");
if(node.isValid) node.destroy();
return;
}
node.parent = skillParent;
// 设置节点属性
let face=caster.node.scale.x < 0 ? -1 : 1
node.setScale(v3(node.scale.x*face,node.scale.y,1))