extends CharacterBody2D

class_name Debris

@onready var deb := $AnimatedSprite2D
@onready var warn_arrow := $AnimatedSprite2D2

var speed := 40
var direction := Vector2.LEFT

var moving := false


### 	 ACCESSORS 	 ###






### 	 BUILT-IN 	 ###

func _ready() -> void:
	direction = direction.rotated(self.rotation)
	warn_arrow.rotate(Vector2.LEFT.angle_to(direction))


func _physics_process(delta: float) -> void:
	if moving:
		velocity = direction * speed
		move_and_slide()


### 	 VIRTUAL 	 ###





### 	 LOGIC 	 ###

func set_direction(dir : Vector2) -> void:
	direction = dir


### 	 SIGNAL-RESPONSE 	 ###


func _on_warn_timer_timeout() -> void:
	moving = true
	deb.visible = true
	warn_arrow.visible = false


func _on_area_2d_body_entered(body: Node2D) -> void:
	body.terrorize(self.global_position)
