fix(player): порт — NPC pickable+npcId для попаданий оружия (авто-floater)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
08143b837c
commit
909af7a5d8
@ -161,6 +161,19 @@ export class NpcManager {
|
||||
r15Animator,
|
||||
};
|
||||
this.npcs.set(id, npc);
|
||||
// Пометить меши NPC для попаданий оружия (бластер/меч): pickable + npcId
|
||||
// в metadata. Без pickable raycast оружия проходит сквозь NPC (задача 40).
|
||||
try {
|
||||
const root = npc.data && npc.data.rootMesh;
|
||||
if (root) {
|
||||
root.isPickable = true;
|
||||
root.metadata = Object.assign({}, root.metadata, { npcId: id });
|
||||
for (const m of root.getChildMeshes(false)) {
|
||||
m.isPickable = true;
|
||||
m.metadata = Object.assign({}, m.metadata, { npcId: id });
|
||||
}
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -309,16 +322,21 @@ export class NpcManager {
|
||||
* содержат hit-меш (или предка). Вызывает damage() → авто-floater. */
|
||||
damageByMesh(mesh, amount) {
|
||||
if (!mesh) return false;
|
||||
let m = mesh;
|
||||
for (let i = 0; i < 8 && m; i++) {
|
||||
const nid = m.metadata && m.metadata.npcId;
|
||||
if (nid != null && this.npcs.has(nid)) { this.damage(nid, amount); return true; }
|
||||
m = m.parent;
|
||||
}
|
||||
for (const npc of this.npcs.values()) {
|
||||
if (npc.dead) continue;
|
||||
const root = npc.data && npc.data.rootMesh;
|
||||
if (!root) continue;
|
||||
let m = mesh, hit = false;
|
||||
for (let i = 0; i < 8 && m; i++) { // вверх по иерархии до rootMesh
|
||||
if (m === root) { hit = true; break; }
|
||||
m = m.parent;
|
||||
let mm = mesh;
|
||||
for (let i = 0; i < 8 && mm; i++) {
|
||||
if (mm === root) { this.damage(npc.id, amount); return true; }
|
||||
mm = mm.parent;
|
||||
}
|
||||
if (hit) { this.damage(npc.id, amount); return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user