From 53e0509fcb20cc824e3fe5b3d3a826f09fc9c166 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 27 Sep 2025 21:06:32 -0400 Subject: Treat worldports as items for tracker --- apworld/client/client.gd | 23 +++++++++++++++++++++++ apworld/client/gamedata.gd | 5 +++++ apworld/client/manager.gd | 8 ++++++++ apworld/client/textclient.gd | 5 +++++ apworld/client/worldport.gd | 10 +++++++++- 5 files changed, 50 insertions(+), 1 deletion(-) (limited to 'apworld/client') diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 3d4096f..a23e85a 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd @@ -18,10 +18,12 @@ var _seed = "" var _team = 0 var _slot = 0 var _checked_locations = [] +var _checked_worldports = [] var _received_indexes = [] var _received_items = {} var _slot_data = {} var _accessible_locations = [] +var _accessible_worldports = [] signal could_not_connect signal connect_status @@ -33,6 +35,7 @@ signal item_sent_notification(message) signal hint_received(message) signal accessible_locations_updated signal checked_locations_updated +signal checked_worldports_updated signal keyboard_update_received @@ -55,7 +58,9 @@ func _reset_state(): _should_process = false _received_items = {} _received_indexes = [] + _checked_worldports = [] _accessible_locations = [] + _accessible_worldports = [] func disconnect_from_ap(): @@ -117,6 +122,14 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo checked_locations_updated.emit() + elif cmd == "UpdateWorldports": + for port_id in message["worldports"]: + var lint = int(port_id) + if not _checked_worldports.has(lint): + _checked_worldports.append(lint) + + checked_worldports_updated.emit() + elif cmd == "ItemReceived": for item in message["items"]: var index = int(item["index"]) @@ -152,10 +165,15 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo elif cmd == "AccessibleLocations": _accessible_locations.clear() + _accessible_worldports.clear() for loc in message["locations"]: _accessible_locations.append(int(loc)) + if "worldports" in message: + for port_id in message["worldports"]: + _accessible_worldports.append(int(port_id)) + accessible_locations_updated.emit() elif cmd == "UpdateKeyboard": @@ -226,6 +244,11 @@ func updateKeyboard(updates): sendMessage([{"cmd": "UpdateKeyboard", "keyboard": updates}]) +func checkWorldport(port_id): + if not _checked_worldports.has(port_id): + sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) + + func sendQuit(): sendMessage([{"cmd": "Quit"}]) diff --git a/apworld/client/gamedata.gd b/apworld/client/gamedata.gd index 13ec568..e44fa17 100644 --- a/apworld/client/gamedata.gd +++ b/apworld/client/gamedata.gd @@ -173,6 +173,11 @@ func get_door_receivers(door_id): return door.get_receivers() +func get_worldport_display_name(port_id): + var port = objects.get_ports()[port_id] + return "%s - %s (Worldport)" % [_get_room_object_map_name(port), port.get_name()] + + func _get_map_object_map_name(obj): return objects.get_maps()[obj.get_map_id()].get_display_name() diff --git a/apworld/client/manager.gd b/apworld/client/manager.gd index afa3ebe..3facfba 100644 --- a/apworld/client/manager.gd +++ b/apworld/client/manager.gd @@ -109,6 +109,7 @@ func _ready(): client.hint_received.connect(_process_hint_received) client.accessible_locations_updated.connect(_on_accessible_locations_updated) client.checked_locations_updated.connect(_on_checked_locations_updated) + client.checked_worldports_updated.connect(_on_checked_worldports_updated) client.could_not_connect.connect(_client_could_not_connect) client.connect_status.connect(_client_connect_status) @@ -195,6 +196,7 @@ func _process_item(item, amount): if gamedata.get_door_map_name(lock[0]) != global.map: continue + # TODO: fix doors opening from door groups var receivers = gamedata.get_door_receivers(lock[0]) var scene = get_tree().get_root().get_node_or_null("scene") if scene != null: @@ -327,6 +329,12 @@ func _on_checked_locations_updated(): textclient_node.update_locations() +func _on_checked_worldports_updated(): + var textclient_node = global.get_node("Textclient") + if textclient_node != null: + textclient_node.update_locations() + + func _client_could_not_connect(message): could_not_connect.emit(message) diff --git a/apworld/client/textclient.gd b/apworld/client/textclient.gd index 1b36c29..af155fb 100644 --- a/apworld/client/textclient.gd +++ b/apworld/client/textclient.gd @@ -150,6 +150,11 @@ func update_locations(): var location_name = gamedata.location_name_by_id.get(location_id, "(Unknown)") location_names.append(location_name) + for port_id in ap.client._accessible_worldports: + if not ap.client._checked_worldports.has(port_id): + var port_name = gamedata.get_worldport_display_name(port_id) + location_names.append(port_name) + location_names.sort() var count = 0 diff --git a/apworld/client/worldport.gd b/apworld/client/worldport.gd index cdca248..ed9891e 100644 --- a/apworld/client/worldport.gd +++ b/apworld/client/worldport.gd @@ -3,6 +3,8 @@ extends "res://scripts/nodes/worldport.gd" var absolute_rotation = false var target_rotation = 0 +var port_id = null + func _ready(): var node_path = String( @@ -13,7 +15,7 @@ func _ready(): if ap.shuffle_worldports: var gamedata = global.get_node("Gamedata") - var port_id = gamedata.get_port_for_map_node_path(global.map, node_path) + port_id = gamedata.get_port_for_map_node_path(global.map, node_path) if port_id != null: if port_id in ap.port_pairings: var target_port = gamedata.objects.get_ports()[ap.port_pairings[port_id]] @@ -29,6 +31,8 @@ func _ready(): sets_entry_point = true invisible = false fades = true + else: + port_id = null if global.map == "icarus" and exit == "daedalus": if not ap.daedalus_roof_access: @@ -39,6 +43,10 @@ func _ready(): func bodyEntered(body): if body.is_in_group("player"): + if port_id != null: + var ap = global.get_node("Archipelago") + ap.client.checkWorldport(port_id) + if absolute_rotation: entry_rotate.y = target_rotation - body.rotation_degrees.y -- cgit 1.4.1