diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-04-03 14:31:51 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-04-03 14:31:51 -0400 |
commit | 38175bd12c1a0a2c80be5f4011f69e4659f61ccd (patch) | |
tree | 6e110740dfeaf024c7bf4c46b0eb3cd18bdf4876 | |
parent | 0b1ea0dbc89b231d2b4847d0fb7dc5b23e060b0c (diff) | |
download | lingo-archipelago-38175bd12c1a0a2c80be5f4011f69e4659f61ccd.tar.gz lingo-archipelago-38175bd12c1a0a2c80be5f4011f69e4659f61ccd.tar.bz2 lingo-archipelago-38175bd12c1a0a2c80be5f4011f69e4659f61ccd.zip |
Added player position tracking
-rw-r--r-- | Archipelago/client.gd | 18 | ||||
-rw-r--r-- | Archipelago/player.gd | 28 | ||||
-rw-r--r-- | Archipelago/settings_buttons.gd | 1 | ||||
-rw-r--r-- | Archipelago/settings_screen.gd | 1 | ||||
-rw-r--r-- | archipelago.tscn | 10 |
5 files changed, 57 insertions, 1 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 47357ee..b825aaa 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -14,6 +14,7 @@ var ap_user = "" | |||
14 | var ap_pass = "" | 14 | var ap_pass = "" |
15 | var confusify_world = false | 15 | var confusify_world = false |
16 | var enable_multiplayer = false | 16 | var enable_multiplayer = false |
17 | var track_player = false | ||
17 | 18 | ||
18 | const my_version = "2.0.0" | 19 | const my_version = "2.0.0" |
19 | const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} | 20 | const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} |
@@ -158,6 +159,8 @@ func _init(): | |||
158 | confusify_world = data[4] | 159 | confusify_world = data[4] |
159 | if data.size() > 5: | 160 | if data.size() > 5: |
160 | enable_multiplayer = data[5] | 161 | enable_multiplayer = data[5] |
162 | if data.size() > 6: | ||
163 | track_player = data[6] | ||
161 | 164 | ||
162 | processDatapackages() | 165 | processDatapackages() |
163 | 166 | ||
@@ -298,6 +301,11 @@ func _on_data(): | |||
298 | if _slot_data.has("early_color_hallways"): | 301 | if _slot_data.has("early_color_hallways"): |
299 | _early_color_hallways = _slot_data["early_color_hallways"] | 302 | _early_color_hallways = _slot_data["early_color_hallways"] |
300 | 303 | ||
304 | if track_player: | ||
305 | setValue("PlayerPos", {"x": 0, "z": 0}) | ||
306 | else: | ||
307 | setValue("PlayerPos", null) | ||
308 | |||
301 | _puzzle_skips = 0 | 309 | _puzzle_skips = 0 |
302 | 310 | ||
303 | _localdata_file = "user://archipelago_data/%s_%d" % [_seed, _slot] | 311 | _localdata_file = "user://archipelago_data/%s_%d" % [_seed, _slot] |
@@ -470,7 +478,15 @@ func saveSettings(): | |||
470 | var file = File.new() | 478 | var file = File.new() |
471 | file.open("user://settings/archipelago", File.WRITE) | 479 | file.open("user://settings/archipelago", File.WRITE) |
472 | 480 | ||
473 | var data = [ap_server, ap_user, ap_pass, _datapackages, confusify_world, enable_multiplayer] | 481 | var data = [ |
482 | ap_server, | ||
483 | ap_user, | ||
484 | ap_pass, | ||
485 | _datapackages, | ||
486 | confusify_world, | ||
487 | enable_multiplayer, | ||
488 | track_player | ||
489 | ] | ||
474 | file.store_var(data, true) | 490 | file.store_var(data, true) |
475 | file.close() | 491 | file.close() |
476 | 492 | ||
diff --git a/Archipelago/player.gd b/Archipelago/player.gd index 87d9d0c..49d907d 100644 --- a/Archipelago/player.gd +++ b/Archipelago/player.gd | |||
@@ -1,6 +1,34 @@ | |||
1 | extends "res://scripts/player.gd" | 1 | extends "res://scripts/player.gd" |
2 | 2 | ||
3 | 3 | ||
4 | var _oldpos = Vector3(0, -200, 0) | ||
5 | |||
6 | |||
7 | func _ready(): | ||
8 | _oldpos = translation | ||
9 | _oldpos.y = 0 | ||
10 | |||
11 | var apclient = global.get_node("Archipelago") | ||
12 | if apclient.track_player: | ||
13 | var tracking_timer = Timer.new() | ||
14 | tracking_timer.name = "TrackingTimer" | ||
15 | tracking_timer.wait_time = 5.0 | ||
16 | add_child(tracking_timer) | ||
17 | tracking_timer.connect("timeout", self, "_tick_tracking") | ||
18 | tracking_timer.start() | ||
19 | |||
20 | |||
21 | func _tick_tracking(): | ||
22 | var newpos = translation | ||
23 | newpos.y = 0 | ||
24 | |||
25 | if newpos != _oldpos && newpos.distance_to(_oldpos) > 10: | ||
26 | _oldpos = newpos | ||
27 | |||
28 | var apclient = global.get_node("Archipelago") | ||
29 | apclient.setValue("PlayerPos", {"x": int(_oldpos.x), "z": int(_oldpos.z)}) | ||
30 | |||
31 | |||
4 | func _solving(): | 32 | func _solving(): |
5 | ._solving() | 33 | ._solving() |
6 | 34 | ||
diff --git a/Archipelago/settings_buttons.gd b/Archipelago/settings_buttons.gd index e9cff9d..9193b61 100644 --- a/Archipelago/settings_buttons.gd +++ b/Archipelago/settings_buttons.gd | |||
@@ -14,6 +14,7 @@ func _connect_pressed(): | |||
14 | apclient.ap_pass = self.get_parent().get_node("password_box").text | 14 | apclient.ap_pass = self.get_parent().get_node("password_box").text |
15 | apclient.confusify_world = self.get_parent().get_node("confusing_box").pressed | 15 | apclient.confusify_world = self.get_parent().get_node("confusing_box").pressed |
16 | apclient.enable_multiplayer = self.get_parent().get_node("multiplayer_box").pressed | 16 | apclient.enable_multiplayer = self.get_parent().get_node("multiplayer_box").pressed |
17 | apclient.track_player = self.get_parent().get_node("position_box").pressed | ||
17 | apclient.saveSettings() | 18 | apclient.saveSettings() |
18 | 19 | ||
19 | apclient.connectToServer() | 20 | apclient.connectToServer() |
diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 7f50f51..deb0003 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd | |||
@@ -59,6 +59,7 @@ func _ready(): | |||
59 | self.get_node("Panel/password_box").text = apclient.ap_pass | 59 | self.get_node("Panel/password_box").text = apclient.ap_pass |
60 | self.get_node("Panel/confusing_box").pressed = apclient.confusify_world | 60 | self.get_node("Panel/confusing_box").pressed = apclient.confusify_world |
61 | self.get_node("Panel/multiplayer_box").pressed = apclient.enable_multiplayer | 61 | self.get_node("Panel/multiplayer_box").pressed = apclient.enable_multiplayer |
62 | self.get_node("Panel/position_box").pressed = apclient.track_player | ||
62 | 63 | ||
63 | # Show client version. | 64 | # Show client version. |
64 | self.get_node("Panel/title").text = "ARCHIPELAGO (%s)" % apclient.my_version | 65 | self.get_node("Panel/title").text = "ARCHIPELAGO (%s)" % apclient.my_version |
diff --git a/archipelago.tscn b/archipelago.tscn index 917db4e..f0b8ab9 100644 --- a/archipelago.tscn +++ b/archipelago.tscn | |||
@@ -173,5 +173,15 @@ custom_icons/checked = ExtResource( 8 ) | |||
173 | custom_icons/unchecked = ExtResource( 7 ) | 173 | custom_icons/unchecked = ExtResource( 7 ) |
174 | text = "Show other players" | 174 | text = "Show other players" |
175 | 175 | ||
176 | [node name="position_box" type="CheckBox" parent="Panel"] | ||
177 | margin_left = 1227.0 | ||
178 | margin_top = 571.0 | ||
179 | margin_right = 1832.0 | ||
180 | margin_bottom = 654.0 | ||
181 | custom_fonts/font = ExtResource( 6 ) | ||
182 | custom_icons/checked = ExtResource( 8 ) | ||
183 | custom_icons/unchecked = ExtResource( 7 ) | ||
184 | text = "Send position to tracker" | ||
185 | |||
176 | [connection signal="pressed" from="Panel/connect_button" to="Panel/connect_button" method="_connect_pressed"] | 186 | [connection signal="pressed" from="Panel/connect_button" to="Panel/connect_button" method="_connect_pressed"] |
177 | [connection signal="pressed" from="Panel/quit_button" to="Panel/quit_button" method="_back_pressed"] | 187 | [connection signal="pressed" from="Panel/quit_button" to="Panel/quit_button" method="_back_pressed"] |