diff options
Diffstat (limited to 'apworld/client')
| -rw-r--r-- | apworld/client/client.gd | 17 | ||||
| -rw-r--r-- | apworld/client/door.gd | 31 | ||||
| -rw-r--r-- | apworld/client/manager.gd | 15 |
3 files changed, 62 insertions, 1 deletions
| diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 9a4b402..ce5ac7e 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd | |||
| @@ -25,6 +25,7 @@ var _slot_data = {} | |||
| 25 | var _accessible_locations = [] | 25 | var _accessible_locations = [] |
| 26 | var _accessible_worldports = [] | 26 | var _accessible_worldports = [] |
| 27 | var _goal_accessible = false | 27 | var _goal_accessible = false |
| 28 | var _latched_doors = [] | ||
| 28 | 29 | ||
| 29 | signal could_not_connect | 30 | signal could_not_connect |
| 30 | signal connect_status | 31 | signal connect_status |
| @@ -34,6 +35,7 @@ signal location_scout_received(location_id, item_name, player_name, flags, for_s | |||
| 34 | signal text_message_received(message) | 35 | signal text_message_received(message) |
| 35 | signal item_sent_notification(message) | 36 | signal item_sent_notification(message) |
| 36 | signal hint_received(message) | 37 | signal hint_received(message) |
| 38 | signal door_latched(id) | ||
| 37 | signal accessible_locations_updated | 39 | signal accessible_locations_updated |
| 38 | signal checked_locations_updated | 40 | signal checked_locations_updated |
| 39 | signal checked_worldports_updated | 41 | signal checked_worldports_updated |
| @@ -189,6 +191,14 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
| 189 | message["type"], int(message.get("id", null)), message["path"] | 191 | message["type"], int(message.get("id", null)), message["path"] |
| 190 | ) | 192 | ) |
| 191 | 193 | ||
| 194 | elif cmd == "UpdateLatches": | ||
| 195 | for id in message["latches"]: | ||
| 196 | var iid = int(id) | ||
| 197 | if not _latched_doors.has(iid): | ||
| 198 | _latched_doors.append(iid) | ||
| 199 | |||
| 200 | door_latched.emit(iid) | ||
| 201 | |||
| 192 | 202 | ||
| 193 | func connectToServer(server, un, pw): | 203 | func connectToServer(server, un, pw): |
| 194 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) | 204 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) |
| @@ -255,6 +265,13 @@ func checkWorldport(port_id): | |||
| 255 | sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) | 265 | sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) |
| 256 | 266 | ||
| 257 | 267 | ||
| 268 | func latchDoor(id): | ||
| 269 | if not _latched_doors.has(id): | ||
| 270 | _latched_doors.append(id) | ||
| 271 | |||
| 272 | sendMessage([{"cmd": "LatchDoor", "door": id}]) | ||
| 273 | |||
| 274 | |||
| 258 | func getLogicalPath(object_type, object_id): | 275 | func getLogicalPath(object_type, object_id): |
| 259 | var msg = {"cmd": "GetPath", "type": object_type} | 276 | var msg = {"cmd": "GetPath", "type": object_type} |
| 260 | if object_id != null: | 277 | if object_id != null: |
| diff --git a/apworld/client/door.gd b/apworld/client/door.gd index 49f5728..63cfa99 100644 --- a/apworld/client/door.gd +++ b/apworld/client/door.gd | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | extends "res://scripts/nodes/door.gd" | 1 | extends "res://scripts/nodes/door.gd" |
| 2 | 2 | ||
| 3 | var door_id | ||
| 3 | var item_id | 4 | var item_id |
| 4 | var item_amount | 5 | var item_amount |
| 6 | var latched = false | ||
| 5 | 7 | ||
| 6 | 8 | ||
| 7 | func _ready(): | 9 | func _ready(): |
| @@ -10,7 +12,7 @@ func _ready(): | |||
| 10 | ) | 12 | ) |
| 11 | 13 | ||
| 12 | var gamedata = global.get_node("Gamedata") | 14 | var gamedata = global.get_node("Gamedata") |
| 13 | var door_id = gamedata.get_door_for_map_node_path(global.map, node_path) | 15 | door_id = gamedata.get_door_for_map_node_path(global.map, node_path) |
| 14 | if door_id != null: | 16 | if door_id != null: |
| 15 | var ap = global.get_node("Archipelago") | 17 | var ap = global.get_node("Archipelago") |
| 16 | var item_lock = ap.get_item_id_for_door(door_id) | 18 | var item_lock = ap.get_item_id_for_door(door_id) |
| @@ -27,6 +29,12 @@ func _ready(): | |||
| 27 | self.excludeSenders = [] | 29 | self.excludeSenders = [] |
| 28 | 30 | ||
| 29 | call_deferred("_readier") | 31 | call_deferred("_readier") |
| 32 | else: | ||
| 33 | var door_data = gamedata.objects.get_doors()[door_id] | ||
| 34 | if door_data.has_latch() and door_data.get_latch(): | ||
| 35 | _check_latched.call_deferred(door_id) | ||
| 36 | |||
| 37 | latched = true | ||
| 30 | 38 | ||
| 31 | if global.map == "the_sun_temple": | 39 | if global.map == "the_sun_temple": |
| 32 | if name == "spe_EndPlatform" or name == "spe_entry_2": | 40 | if name == "spe_EndPlatform" or name == "spe_entry_2": |
| @@ -44,3 +52,24 @@ func _readier(): | |||
| 44 | 52 | ||
| 45 | if ap.client.getItemAmount(item_id) >= item_amount: | 53 | if ap.client.getItemAmount(item_id) >= item_amount: |
| 46 | handleTriggered() | 54 | handleTriggered() |
| 55 | |||
| 56 | |||
| 57 | func _check_latched(door_id): | ||
| 58 | var ap = global.get_node("Archipelago") | ||
| 59 | |||
| 60 | if ap.client._latched_doors.has(door_id): | ||
| 61 | triggered = total | ||
| 62 | handleTriggered() | ||
| 63 | |||
| 64 | |||
| 65 | func handleTriggered(): | ||
| 66 | super.handleTriggered() | ||
| 67 | |||
| 68 | if latched and ran: | ||
| 69 | var ap = global.get_node("Archipelago") | ||
| 70 | ap.client.latchDoor(door_id) | ||
| 71 | |||
| 72 | |||
| 73 | func handleUntriggered(): | ||
| 74 | if not latched or not ran: | ||
| 75 | super.handleUntriggered() | ||
| diff --git a/apworld/client/manager.gd b/apworld/client/manager.gd index dac09b2..a17bee8 100644 --- a/apworld/client/manager.gd +++ b/apworld/client/manager.gd | |||
| @@ -141,6 +141,7 @@ func _ready(): | |||
| 141 | client.accessible_locations_updated.connect(_on_accessible_locations_updated) | 141 | client.accessible_locations_updated.connect(_on_accessible_locations_updated) |
| 142 | client.checked_locations_updated.connect(_on_checked_locations_updated) | 142 | client.checked_locations_updated.connect(_on_checked_locations_updated) |
| 143 | client.checked_worldports_updated.connect(_on_checked_worldports_updated) | 143 | client.checked_worldports_updated.connect(_on_checked_worldports_updated) |
| 144 | client.door_latched.connect(_on_door_latched) | ||
| 144 | 145 | ||
| 145 | client.could_not_connect.connect(_client_could_not_connect) | 146 | client.could_not_connect.connect(_client_could_not_connect) |
| 146 | client.connect_status.connect(_client_connect_status) | 147 | client.connect_status.connect(_client_connect_status) |
| @@ -376,6 +377,20 @@ func _on_checked_worldports_updated(): | |||
| 376 | textclient_node.update_worldports() | 377 | textclient_node.update_worldports() |
| 377 | 378 | ||
| 378 | 379 | ||
| 380 | func _on_door_latched(door_id): | ||
| 381 | var gamedata = global.get_node("Gamedata") | ||
| 382 | if gamedata.get_door_map_name(door_id) != global.map: | ||
| 383 | return | ||
| 384 | |||
| 385 | var receivers = gamedata.get_door_receivers(door_id) | ||
| 386 | var scene = get_tree().get_root().get_node_or_null("scene") | ||
| 387 | if scene != null: | ||
| 388 | for receiver in receivers: | ||
| 389 | var rnode = scene.get_node_or_null(receiver) | ||
| 390 | if rnode != null: | ||
| 391 | rnode.handleTriggered() | ||
| 392 | |||
| 393 | |||
| 379 | func _client_could_not_connect(message): | 394 | func _client_could_not_connect(message): |
| 380 | could_not_connect.emit(message) | 395 | could_not_connect.emit(message) |
| 381 | 396 | ||
