Files
2026-07-13 07:38:54 +02:00

31 lines
1002 B
GDScript

# scripts/game.gd — autoloaded as "Game"
extends Node
const BOAT_SCENE := preload("res://boat.tscn")
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed(&"restart"):
get_tree().reload_current_scene()
if event.is_action_pressed(&"debug_spawn_boat") and _is_in_mission():
_debug_spawn_boat()
if event.is_action_pressed(&"debug_end_mission") and _is_in_mission():
GameState.return_to_hub({"outcome": "aborted"})
func _debug_spawn_boat() -> void:
var focus := get_tree().get_first_node_in_group(&"boats") as Node3D
var boat: Boat = BOAT_SCENE.instantiate()
if focus != null:
boat.position = focus.global_position + focus.global_basis.x * 10.0 + Vector3.UP * 2.0
else:
boat.position = Vector3(0, 3, 0)
var ai := AIController.new()
ai.name = "AIController"
boat.add_child(ai)
get_tree().current_scene.add_child(boat, true)
func _is_in_mission() -> bool:
var scene := get_tree().current_scene
return scene != null and scene.is_in_group(&"mission")