diff --git a/scripts/autoloads/boss_manager.gd b/scripts/autoloads/boss_manager.gd index df7b6f3..7f0d586 100644 --- a/scripts/autoloads/boss_manager.gd +++ b/scripts/autoloads/boss_manager.gd @@ -50,6 +50,8 @@ func _physics_process(delta: float) -> void: if _active.is_empty(): return for boss_id in _active.keys(): + if not _active.has(boss_id): + continue # 防重入:本帧内被 reset()/erase(如玩家死亡致命一击)→ 跳过已失效键 if not EnemyManager.has_entity(boss_id): continue var st: Dictionary = _active[boss_id] diff --git a/scripts/autoloads/enemy_bullet_manager.gd b/scripts/autoloads/enemy_bullet_manager.gd index 7dc90f6..5ba8da5 100644 --- a/scripts/autoloads/enemy_bullet_manager.gd +++ b/scripts/autoloads/enemy_bullet_manager.gd @@ -37,6 +37,8 @@ func _physics_process(delta: float) -> void: i += 1 func _swap_and_pop(idx: int) -> void: + if _active_count <= 0: + return # 防重入:玩家死亡致命一击触发 reset() 已清空池,勿再 -1 var last: int = _active_count - 1 if idx != last: var b_i: int = idx * ENEMY_BULLET_STRIDE