about summary refs log blame commit diff stats
path: root/Archipelago/player.gd
blob: 49d907de7c10a9c84f9f24729d274f162d86918f (plain) (tree)
1
2
3

                                 


























                                                                                          



















                                                                                               
extends "res://scripts/player.gd"


var _oldpos = Vector3(0, -200, 0)


func _ready():
	_oldpos = translation
	_oldpos.y = 0

	var apclient = global.get_node("Archipelago")
	if apclient.track_player:
		var tracking_timer = Timer.new()
		tracking_timer.name = "TrackingTimer"
		tracking_timer.wait_time = 5.0
		add_child(tracking_timer)
		tracking_timer.connect("timeout", self, "_tick_tracking")
		tracking_timer.start()


func _tick_tracking():
	var newpos = translation
	newpos.y = 0
	
	if newpos != _oldpos && newpos.distance_to(_oldpos) > 10:
		_oldpos = newpos

		var apclient = global.get_node("Archipelago")
		apclient.setValue("PlayerPos", {"x": int(_oldpos.x), "z": int(_oldpos.z)})


func _solving():
	._solving()

	var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects")
	effects_node.enter_solve_mode()


func _solvingEnd():
	._solvingEnd()

	var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects")
	effects_node.exit_solve_mode()


func _unhandled_input(event):
	._unhandled_input(event)

	if event is InputEventKey:
		if event.pressed and event.scancode == KEY_P:
			var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects")
			effects_node.skip_puzzle()