cache World node reference in spawn_control

main
Artur David 2026-06-06 02:10:54 +02:00
parent f998f37693
commit 6177d2afbb
1 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,7 @@
extends Control
@onready var _world: Node2D = get_node("/root/Game/World")
var up_left: Vector2
var down_right: Vector2
var up_right: Vector2
@ -86,7 +88,7 @@ func _active_stage_idx() -> int:
func _spawn_elite(scene: PackedScene) -> void:
var enemy = scene.instantiate()
enemy.global_position = get_spawn_position()
get_node("/root/Game/World").add_child(enemy)
_world.add_child(enemy)
enemy.scale = Vector2(ELITE_SCALE, ELITE_SCALE)
enemy.max_hp = enemy.max_hp * ELITE_HP_MULT
enemy.hp = enemy.max_hp
@ -140,4 +142,4 @@ func _spawn_one(entry: StageEntry, state: Dictionary) -> void:
state["alive"] += 1
state["spawned_total"] += 1
enemy.tree_exited.connect(func(): state["alive"] -= 1)
get_node("/root/Game/World").add_child(enemy)
_world.add_child(enemy)