about summary refs log tree commit diff stats
path: root/Archipelago/player.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Archipelago/player.gd')
-rw-r--r--Archipelago/player.gd29
1 files changed, 29 insertions, 0 deletions
diff --git a/Archipelago/player.gd b/Archipelago/player.gd index 52d743a..6638329 100644 --- a/Archipelago/player.gd +++ b/Archipelago/player.gd
@@ -2,12 +2,16 @@ extends "res://scripts/player.gd"
2 2
3 3
4var _oldpos = Vector3(0, -200, 0) 4var _oldpos = Vector3(0, -200, 0)
5var _oldpos_fine = Vector3(0, -200, 0)
5 6
6 7
7func _ready(): 8func _ready():
8 _oldpos = translation 9 _oldpos = translation
9 _oldpos.y = 0 10 _oldpos.y = 0
10 11
12 _oldpos_fine = translation
13 _oldpos_fine.y = 0
14
11 var apclient = global.get_node("Archipelago") 15 var apclient = global.get_node("Archipelago")
12 if apclient.track_player: 16 if apclient.track_player:
13 var tracking_timer = Timer.new() 17 var tracking_timer = Timer.new()
@@ -17,8 +21,19 @@ func _ready():
17 tracking_timer.connect("timeout", self, "_tick_tracking") 21 tracking_timer.connect("timeout", self, "_tick_tracking")
18 tracking_timer.start() 22 tracking_timer.start()
19 23
24 var tracking_timer_fine = Timer.new()
25 tracking_timer_fine.name = "TrackingTimerFine"
26 tracking_timer_fine.wait_time = 0.5
27 add_child(tracking_timer_fine)
28 tracking_timer_fine.connect("timeout", self, "_tick_tracking_fine")
29 tracking_timer_fine.start()
30
20 31
21func _tick_tracking(): 32func _tick_tracking():
33 var tracker = get_tree().get_root().get_node("Spatial/AP_Tracker")
34 if tracker.has_connection():
35 return
36
22 var newpos = translation 37 var newpos = translation
23 newpos.y = 0 38 newpos.y = 0
24 39
@@ -29,6 +44,20 @@ func _tick_tracking():
29 apclient.setValue("PlayerPos", {"x": int(_oldpos.x), "z": int(_oldpos.z)}) 44 apclient.setValue("PlayerPos", {"x": int(_oldpos.x), "z": int(_oldpos.z)})
30 45
31 46
47func _tick_tracking_fine():
48 var tracker = get_tree().get_root().get_node("Spatial/AP_Tracker")
49 if !tracker.has_connection():
50 return
51
52 var newpos = translation
53 newpos.y = 0
54
55 if newpos != _oldpos_fine && newpos.distance_to(_oldpos_fine) > 0.5:
56 _oldpos_fine = newpos
57
58 tracker.update_position(int(_oldpos_fine.x), int(_oldpos_fine.z))
59
60
32func _solving(): 61func _solving():
33 ._solving() 62 ._solving()
34 63