about summary refs log tree commit diff stats
path: root/Archipelago
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-04-03 14:31:51 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-04-03 14:31:51 -0400
commit38175bd12c1a0a2c80be5f4011f69e4659f61ccd (patch)
tree6e110740dfeaf024c7bf4c46b0eb3cd18bdf4876 /Archipelago
parent0b1ea0dbc89b231d2b4847d0fb7dc5b23e060b0c (diff)
downloadlingo-archipelago-38175bd12c1a0a2c80be5f4011f69e4659f61ccd.tar.gz
lingo-archipelago-38175bd12c1a0a2c80be5f4011f69e4659f61ccd.tar.bz2
lingo-archipelago-38175bd12c1a0a2c80be5f4011f69e4659f61ccd.zip
Added player position tracking
Diffstat (limited to 'Archipelago')
-rw-r--r--Archipelago/client.gd18
-rw-r--r--Archipelago/player.gd28
-rw-r--r--Archipelago/settings_buttons.gd1
-rw-r--r--Archipelago/settings_screen.gd1
4 files changed, 47 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 = ""
14var ap_pass = "" 14var ap_pass = ""
15var confusify_world = false 15var confusify_world = false
16var enable_multiplayer = false 16var enable_multiplayer = false
17var track_player = false
17 18
18const my_version = "2.0.0" 19const my_version = "2.0.0"
19const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} 20const 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 @@
1extends "res://scripts/player.gd" 1extends "res://scripts/player.gd"
2 2
3 3
4var _oldpos = Vector3(0, -200, 0)
5
6
7func _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
21func _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
4func _solving(): 32func _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