extends CharacterBody3D

var robot_delay = randf_range(3.5,7)
var robot_ready: bool = false
var robot_win: bool = false
var speed: int = 3.5

@onready var safety_zone = get_node("/root/Game/World/ElevatorSafeZone")


func _ready() -> void:
	await get_tree().create_timer(robot_delay).timeout
	robot_ready = true

func _physics_process(delta):
	
	if robot_win == true: return
	if robot_ready == false: return
	
	if robot_ready == true:
		velocity.z -= speed * delta
		move_and_slide()
		
	if robot_win == true: return
		


func _on_area_3d_area_entered(area: Area3D) -> void:
	var safety = safety_zone
	if area == safety: #TODO: if entered safety AND door is open, then GAME OVER!
		robot_win = true
		print("got you!")
		
