class_name StateBuild extends State static var current_builder_element: BuilderElement func _state_enter(): %BuildGrid.visible = true func _state_exit(): %BuildGrid.visible = false func _state_input(event: InputEvent): if event.is_action_pressed("builder_tower_select"): if current_builder_element and current_builder_element.can_build(): var placed_tower = current_builder_element.element.duplicate() as Tower Client.place_tower(placed_tower, current_builder_element.global_position) placed_tower.selected.connect(func(): Client.stage.hud.tower.text = "Range: %s - Power: %s - Speed: %s" % [ placed_tower.attack_range, placed_tower.attack_power, placed_tower.attack_speed ] ) if not Input.is_action_pressed("builder_tower_place_keep"): current_builder_element.queue_free() current_builder_element = null if event.is_action_pressed("build_mode_start"): get_viewport().set_input_as_handled() if current_builder_element: current_builder_element.queue_free() current_builder_element = null set_state("StateDefault")