extends PlaceableBehaviour

class_name Seesaw

var left_down = false
var seesaw_empty = true


signal flip_clown

func _ready():
	($Seesaw/Seesaw_Board as MeshInstance3D).set("blend_shapes/GoDown", -1)


func tryToSitLeft():
	#print("try sit left ", left_down, seesaw_empty)
	if left_down and seesaw_empty:
		#print("---yes")
		seesaw_empty = false
		return true
	#print("---no")
	return false

func tryToSitRight():
	#print("try sit right ", left_down, seesaw_empty)
	if !left_down and seesaw_empty:
		#print("---yes")
		seesaw_empty = false
		return true
	#print("---no")
	return false

func tryToFlipLeft():
	#print("try flip left")
	if !left_down and !seesaw_empty:
		#print("---yes")
		seesaw_empty = true
		left_down = true
		$AnimationPlayer.play("right_to_left")
		emit_signal("flip_clown",10.0,true)
		for dict in flip_clown.get_connections():
			flip_clown.disconnect(dict["callable"])
		return true
	return false

func tryToFlipRight():
	#print("try flip right")
	if left_down and !seesaw_empty:
		#print("---yes")
		seesaw_empty = true
		left_down = false
		$AnimationPlayer.play("left_to_right")
		emit_signal("flip_clown",10.0,false)
		for dict in flip_clown.get_connections():
			flip_clown.disconnect(dict["callable"])
		return true
	return false
