feat(item) 优化移动及添加测试场景

This commit is contained in:
chicrobot committed 2026-01-04 00:55:48 +08:00
1 parent 2f7210f47e
commit b9a5180293
15 files changed
+1428 -62

No files matched your search

+8 -2
View File
@@ -26,7 +26,10 @@ export class CommandSystem {
// 遍历所有目标单位,调用它们的moveRelative方法进行相对移动
targets.forEach(unit => {
unit.moveRelative(dir.x, dir.y);
// 确保unit是有效的Unit实例
if (unit && typeof unit.moveRelative === 'function') {
unit.moveRelative(dir.x, dir.y);
}
});
}
@@ -37,7 +40,10 @@ export class CommandSystem {
// 遍历所有目标单位,调用它们的setTarget方法设置移动目标点
targets.forEach(unit => {
unit.setTarget(x, y); // ← 使用单位的新接口方法
// 确保unit是有效的Unit实例
if (unit && typeof unit.setTarget === 'function') {
unit.setTarget(x, y); // ← 使用单位的新接口方法
}
});
}