diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-17 16:01:19 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-17 16:01:19 -0500 |
commit | 1bdfb112b659a6e4447ae8ed02c452bf12d8700a (patch) | |
tree | 0285f67a9600b83616edb69d209e3ebaf47cbae8 /Archipelago/player.gd | |
parent | 45fa76505dd00bdd6665bae476277371fb1252a2 (diff) | |
download | lingo-archipelago-1bdfb112b659a6e4447ae8ed02c452bf12d8700a.tar.gz lingo-archipelago-1bdfb112b659a6e4447ae8ed02c452bf12d8700a.tar.bz2 lingo-archipelago-1bdfb112b659a6e4447ae8ed02c452bf12d8700a.zip |
Add position tracking via IPC
Diffstat (limited to 'Archipelago/player.gd')
-rw-r--r-- | Archipelago/player.gd | 29 |
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 | ||
4 | var _oldpos = Vector3(0, -200, 0) | 4 | var _oldpos = Vector3(0, -200, 0) |
5 | var _oldpos_fine = Vector3(0, -200, 0) | ||
5 | 6 | ||
6 | 7 | ||
7 | func _ready(): | 8 | func _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 | ||
21 | func _tick_tracking(): | 32 | func _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 | ||
47 | func _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 | |||
32 | func _solving(): | 61 | func _solving(): |
33 | ._solving() | 62 | ._solving() |
34 | 63 | ||