extends Area2D

class_name WarpZone

signal player_entered
export var to_level_coord:Vector2 = Vector2(-1, -1)
export var is_exit:bool = true
const spawn_offset = 30


const NON_SPECIFIED_LEVEL :=Vector2(-1, -1)


  

func _on_body_entered(body:Node):
  if body.name == "Player" and get_parent().is_active_level:
    print("Warp - exit=%s to_level=%s" % [is_exit, to_level_coord])
    emit_signal("player_entered", is_exit, to_level_coord)

func get_checkpoint_position():
  var factor = -1 if is_exit else 1
  return position + Vector2(factor * spawn_offset, 0)