feat(rbxl): XML-������ ������ .rbxl + Day/Night + Tool/Mouse/Backpack flow #38

Closed
min wants to merge 39 commits from feat/rbxl-xml-parser-import into main
Showing only changes of commit 55f4a3fc38 - Show all commits

View File

@ -3979,21 +3979,21 @@ export class GameRuntime {
return;
}
if (cmd === 'playerSet' && payload) {
// Из Lua-runtime: humanoid.Health = 0 → шлёт {prop:'health', value:N}.
// Применяем к реальному игроку BabylonScene.
// Из Lua-runtime: humanoid.Health = N → {prop:'health', value:N}.
// Используем PlayerController.takeDamage, который запускает полный
// death-flow: distance debris, _onDeath callback (respawn), звук.
// Сбрасываем _lastDamageTime чтобы invulnerability не блокировал.
const player = this.scene3d?.player;
if (!player) return;
if (payload.prop === 'health') {
const v = Math.max(0, Number(payload.value) || 0);
player.hp = v;
if (v === 0) {
try { this.routeGlobalEvent('playerDied', {}); } catch (_) {}
// Перезагружаем игру (как при смерти)
try {
if (this.scene3d?.respawnPlayer) this.scene3d.respawnPlayer();
} catch (_) {}
const target = Math.max(0, Number(payload.value) || 0);
const damage = Math.max(0, (player.hp || 0) - target);
if (damage > 0 && typeof player.takeDamage === 'function') {
player._lastDamageTime = 0;
player.takeDamage(damage, 'lua');
} else {
player.hp = target;
}
try { this.routeGlobalEvent('hpChange', { hp: v }); } catch (_) {}
}
return;
}