extends Position2D

class_name Stairs

# 楼梯类型
enum StairsType { Up,Down }

export(StairsType) var stairs_type = StairsType.Up

export var disabled : bool = false

onready var sprite : Sprite = $Sprite

onready var collision_shape : CollisionShape2D = $Area2D/CollisionShape2D

func _on_Area2D_body_entered(body):
	if disabled:
		return
	print("entered")
	disabled = true
	body.position = position
	var levels_manager = $"/root/Main/Level" as LevelsManager
	if stairs_type == StairsType.Up:
		levels_manager.set_deferred("level",levels_manager.level + 1)
	else:
		levels_manager.set_deferred("level",levels_manager.level - 1)

func _on_Area2D_body_exited(body):
	disabled = false
