class_name TimeshiftCheck
extends Area2D

var is_position_valid := true
var last_valid_global_position := Vector2(0, 0)

var colliding_bodies : Array[Node2D] = []

func _process(_delta: float) -> void:
	if is_position_valid:
		last_valid_global_position = global_position


func _on_body_entered(body: Node2D) -> void:
	if body is Area2D:
		return
	if not colliding_bodies.has(body):
		colliding_bodies.append(body)
	is_position_valid = false

func _on_body_exited(body: Node2D) -> void:
	if body is Area2D:
		return
	if colliding_bodies.has(body):
		colliding_bodies.remove_at(colliding_bodies.find(body))
	if colliding_bodies.is_empty():
		is_position_valid = true
