From 56b1b65232539860d68a5ff03eb43bd99c11f52b Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 11 Feb 2024 12:32:44 -0500 Subject: Added filters --- racing/load.gd | 12 +-- racing/lobby.gd | 52 ++++++---- racing/manager.gd | 2 +- racing/multiplayer.gd | 5 +- racing/router.gd | 268 ++++++++++++++++++++++++++++---------------------- 5 files changed, 191 insertions(+), 148 deletions(-) (limited to 'racing') diff --git a/racing/load.gd b/racing/load.gd index 3fed3c9..0ec76b6 100644 --- a/racing/load.gd +++ b/racing/load.gd @@ -52,16 +52,16 @@ func _load(): victory_panel.name = "Victory" victory_panel.text = "i win" victory_panel.answer = "i win" - victory_panel.translation.x = race_manager.end_pos[1] + 0.5 - victory_panel.translation.y = race_manager.end_pos[2] + 1.5 - victory_panel.translation.z = race_manager.end_pos[3] + 0.01 + victory_panel.translation.x = race_manager.end_pos["pos"][0] + 0.5 + victory_panel.translation.y = race_manager.end_pos["pos"][1] + 1.5 + victory_panel.translation.z = race_manager.end_pos["pos"][2] + 0.01 add_child(victory_panel) victory_panel.get_node("Viewport/GUI/Panel/TextEdit").connect("answer_correct", self, "victory") set_gridmap_tile( - race_manager.end_pos[1], - race_manager.end_pos[2] + 1.5, - race_manager.end_pos[3] - 0.5, + race_manager.end_pos["pos"][0], + race_manager.end_pos["pos"][1] + 1.5, + race_manager.end_pos["pos"][2] - 0.5, "MeshInstance5" ) diff --git a/racing/lobby.gd b/racing/lobby.gd index 36a90b6..d326098 100644 --- a/racing/lobby.gd +++ b/racing/lobby.gd @@ -154,7 +154,7 @@ func _on_lobby_created(result: int, lobby_id: int) -> void: _ignore = Steam.setLobbyData(lobby_id, "save_file", global.save_file.to_lower()) _ignore = Steam.setLobbyData(lobby_id, "racing_vip", str(player_steam_id)) _ignore = Steam.setLobbyData(lobby_id, "closed", "false") - is_vip = true + _become_vip() _request_lobby_list() @@ -166,7 +166,7 @@ func _on_lobby_joined(lobby_id: int, _permissions: int, _locked: bool, result: i Steam.leaveLobby(active_lobby_id) active_lobby_id = lobby_id if Steam.getLobbyData(lobby_id, "racing_vip") == str(player_steam_id): - is_vip = true + _become_vip() _update_lobby_members() @@ -249,15 +249,14 @@ func _read_p2p_packet() -> void: ) if "start_x" in data: race_manager.level = data["level"] - race_manager.start_pos = [ - data["start_name"], - int(data["start_x"]), - int(data["start_y"]), - int(data["start_z"]) - ] - race_manager.end_pos = [ - data["end_name"], int(data["end_x"]), int(data["end_y"]), int(data["end_z"]) - ] + race_manager.start_pos = { + "title": data["start_name"], + "pos": [int(data["start_x"]), int(data["start_y"]), int(data["start_z"])] + } + race_manager.end_pos = { + "title": data["end_name"], + "pos": [int(data["end_x"]), int(data["end_y"]), int(data["end_z"])] + } is_starting = true _start_game() @@ -302,13 +301,22 @@ func _send_p2p_packet(data: Dictionary, recipient_id: int, mode: int, needs_ack: var _ignore = Steam.sendP2PPacket(recipient_id, serialized, mode) +func _become_vip(): + is_vip = true + get_node("Panel/ItemList").margin_left = 226 + get_node("Panel/Settings").visible = true + + func _main_button_pressed(): if everyone_ready and is_vip: get_node("Panel/main_button").disabled = true var _ignore = Steam.setLobbyData(active_lobby_id, "closed", "true") - var route = router.choose_route() + var route = router.choose_route( + get_node("Panel/Settings/LevelOption").get_selected_id(), + get_node("Panel/Settings/LengthOption").get_selected_id() + ) var start_pos = route[1] var end_pos = route[2] @@ -327,14 +335,14 @@ func _main_button_pressed(): _send_p2p_packet( { "level": route[0], - "start_name": start_pos[0], - "start_x": str(start_pos[1]), - "start_y": str(start_pos[2]), - "start_z": str(start_pos[3]), - "end_name": end_pos[0], - "end_x": str(end_pos[1]), - "end_y": str(end_pos[2]), - "end_z": str(end_pos[3]), + "start_name": start_pos["title"], + "start_x": str(start_pos["pos"][0]), + "start_y": str(start_pos["pos"][1]), + "start_z": str(start_pos["pos"][2]), + "end_name": end_pos["title"], + "end_x": str(end_pos["pos"][0]), + "end_y": str(end_pos["pos"][1]), + "end_z": str(end_pos["pos"][2]), }, RECIPIENT_BROADCAST_ALL, Steam.P2P_SEND_RELIABLE, @@ -361,7 +369,9 @@ func _start_game(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) global.map = race_manager.level global.entry_point = Vector3( - race_manager.start_pos[1], race_manager.start_pos[2] + 1, race_manager.start_pos[3] + race_manager.start_pos["pos"][0], + race_manager.start_pos["pos"][1] + 1, + race_manager.start_pos["pos"][2] ) global.entry_rotate = Vector3(0, 0, 0) global.sets_entry_point = true diff --git a/racing/manager.gd b/racing/manager.gd index 48ef466..573e50a 100644 --- a/racing/manager.gd +++ b/racing/manager.gd @@ -17,7 +17,7 @@ func everyone_ready(): get_node("/root/Spatial").remove_child(get_node("/root/Spatial/blindfold")) var indicator = player.get_node("pivot/camera/achievement_label") indicator.visible = true - indicator.text = "Destination:\n%s" % end_pos[0] + indicator.text = "Destination:\n%s" % end_pos["title"] yield(get_tree().create_timer(10), "timeout") diff --git a/racing/multiplayer.gd b/racing/multiplayer.gd index ae2ed48..2aafbb9 100644 --- a/racing/multiplayer.gd +++ b/racing/multiplayer.gd @@ -297,7 +297,10 @@ func time_to_start(): player.playable = true get_node("/root/Spatial/label").text = ( "Start: %s\nDestination: %s" - % [global.get_node("RaceManager").start_pos[0], global.get_node("RaceManager").end_pos[0]] + % [ + global.get_node("RaceManager").start_pos["title"], + global.get_node("RaceManager").end_pos["title"] + ] ) global.get_node("RaceManager").start_timer() get_node("/root/Spatial").ingame_achieve("Go!") diff --git a/racing/router.gd b/racing/router.gd index debfafb..ea3693f 100644 --- a/racing/router.gd +++ b/racing/router.gd @@ -1,135 +1,151 @@ extends Node const LL1_AREAS = [ - ["Starting Room", 0, 0, 0], - ["Second Room", 0, 0, -15], - ["The Traveled", 34, 0, -18], - ["The Agreeable", 30, 0, -45], - ["The Colorful", 10, 0, -83], - ["Suits Area", 0, 0, -78, true], - ["Arrow Garden", -93, 1, -93], - ["The Wondrous (Table)", -108, 1, -78], - ["Courtyard", -64, 0, -71], - ["Yellow Backside Nine", -38, 0, -58], - ["Hot Crusts Area", -20, 0, -81], - ["Crossroads Corner", -28, 0, -54], - ["The Discerning", -54, 0, -34, true], - ["Green Backside", 22, 0, -94], - ["Observant Upstairs", 40, 9, -92, true], - ["Eight Room", 95, 15, -28], - ["The Perceptive", 60, 9, -57], - ["The Tenacious", 0, 0, -43], - ["Rainbow", -96, 0, -41], - ["The Undeterred", -87, 0, 25, true], - ["Directional Gallery", -57, 0, 0], - ["The Eyes They See", -54, 0, -23], - ["Tower First Floor", -27, 0, -23], - ["The Optimistic", 76, 0, -17], - ["The Initiated", 63, 0, -0, true], - ["Art Gallery", 92, 0, 15], - ["Art Gallery Top", 80, 30, 15], - ["Lookout", 75, 18, 51], - ["Knight Night Room", 37, 0, 7], - ["The Seeker", 9, 0, 16, true], - ["Hidden Room", 13, 0, 4], - ["Owl Hallway", 44, 0, -26], - ["Challenge Room", -9, 6, 13], - ["Pilgrim Room", -22, 0, 24, true], - ["Cellar Replica", -44, 0, 30], - ["Elements Area", -61, 0, 40], - ["The Artistic", -25, 0, 54, true], - ["Outside The Wise", -44, 0, 71], - ["The Wise", -72, 0, 72, true], - ["The Scientific", -18, 0, 89], - ["The Wanderer", 0, 0, 80], - ["The Fearless", 18, 10, 90], - ["Champion's Rest", 23, 0, 62, true], - ["The Steady", 31, 0, 77, true], - ["The Bold", 67, 0, 77, true], - ["Color Hunt", 45, 0, 69], - ["Room Room", 95, 6, 84], - ["The Bearer", 61, 0, 51], - ["Tower Third Floor", 18, 0, 33], - ["Rhyme Room (Cross)", 0, 9, 42], - ["Tower Seventh Floor", 0, 37, 64], + {"title": "Starting Room", "pos": [0, 0, 0]}, + {"title": "Second Room", "pos": [0, 0, -15]}, + {"title": "The Traveled", "pos": [34, 0, -18]}, + {"title": "The Agreeable", "pos": [30, 0, -45]}, + {"title": "The Colorful", "pos": [10, 0, -83]}, + {"title": "Suits Area", "pos": [0, 0, -78], "no_start": true}, + {"title": "Arrow Garden", "pos": [-93, 1, -93]}, + {"title": "The Wondrous (Table)", "pos": [-108, 1, -78]}, + {"title": "Courtyard", "pos": [-64, 0, -71]}, + {"title": "Yellow Backside Nine", "pos": [-38, 0, -58]}, + {"title": "Hot Crusts Area", "pos": [-20, 0, -81]}, + {"title": "Crossroads Corner", "pos": [-28, 0, -54]}, + {"title": "The Discerning", "pos": [-54, 0, -34], "no_start": true}, + {"title": "Green Backside", "pos": [22, 0, -94]}, + {"title": "Observant Upstairs", "pos": [40, 9, -92], "no_start": true}, + {"title": "Eight Room", "pos": [95, 15, -28]}, + {"title": "The Perceptive", "pos": [60, 9, -57]}, + {"title": "The Tenacious", "pos": [0, 0, -43]}, + {"title": "Rainbow", "pos": [-96, 0, -41]}, + {"title": "The Undeterred", "pos": [-87, 0, 25], "no_start": true}, + {"title": "Directional Gallery", "pos": [-57, 0, 0]}, + {"title": "The Eyes They See", "pos": [-54, 0, -23]}, + {"title": "Tower First Floor", "pos": [-27, 0, -23], "long": true}, + {"title": "The Optimistic", "pos": [76, 0, -17]}, + {"title": "The Initiated", "pos": [63, 0, -0], "no_start": true}, + {"title": "Art Gallery", "pos": [92, 0, 15]}, + {"title": "Art Gallery Top", "pos": [80, 30, 15]}, + {"title": "Lookout", "pos": [75, 18, 51]}, + {"title": "Knight Night Room", "pos": [37, 0, 7]}, + {"title": "The Seeker", "pos": [9, 0, 16], "no_start": true}, + {"title": "Hidden Room", "pos": [13, 0, 4]}, + {"title": "Owl Hallway", "pos": [44, 0, -26]}, + {"title": "Challenge Room", "pos": [-9, 6, 13], "long": true}, + {"title": "Pilgrim Room", "pos": [-22, 0, 24], "no_start": true, "long": true}, + {"title": "Cellar Replica", "pos": [-44, 0, 30]}, + {"title": "Elements Area", "pos": [-61, 0, 40]}, + {"title": "The Artistic", "pos": [-25, 0, 54], "no_start": true}, + {"title": "Outside The Wise", "pos": [-44, 0, 71]}, + {"title": "The Wise", "pos": [-72, 0, 72], "no_start": true}, + {"title": "The Scientific", "pos": [-18, 0, 89], "long": true}, + {"title": "The Wanderer", "pos": [0, 0, 80], "long": true}, + {"title": "The Fearless", "pos": [18, 10, 90]}, + {"title": "Champion's Rest", "pos": [23, 0, 62], "no_start": true, "long": true}, + {"title": "The Steady", "pos": [31, 0, 77], "no_start": true}, + {"title": "The Bold", "pos": [67, 0, 77], "no_start": true}, + {"title": "Color Hunt", "pos": [45, 0, 69]}, + {"title": "Room Room", "pos": [95, 6, 84]}, + {"title": "The Bearer", "pos": [61, 0, 51]}, + {"title": "Tower Third Floor", "pos": [18, 0, 33]}, + {"title": "Rhyme Room (Cross)", "pos": [0, 9, 42]}, + {"title": "Tower Seventh Floor", "pos": [0, 37, 64], "long": true}, ] const LL2_AREAS = [ - ["Orange Pyramid", 86, 10, -84, true], - ["The Stellar", 43, 6, -86], - ["The Fuzzy", 12, 1, -86, true], - ["The Devious", 0, 0, -88], - ["The Sharp", -26, 0, -88, true], - ["The Structured", -50, 0, -88], - ["Brown Pyramid", -86, 10, -85, true], - ["The Tasty", -86, 7, -62], - ["Black White Room", -88, 0, -32], - ["Lime Magenta Room", -96, 0, -24], - ["Red Blue Room", -87, 0, -23], - ["The Archaeologist", -74, 0, -32], - ["The Earnest", -87, 0, -56], - ["The Hidden", -50, 6, -71, true], - ["The Sapient", -36, 36, -36], - ["The Ethereal", -42, 0, -22], - ["The Learned", 34, 1, -64, true], - ["Whispers Behind Quiet Walls", 44, 0, -51, true], - ["The Lunar", 45, 0, -22], - ["The Arcadian", 86, 0, -53], - ["The Frozen", 84, 0, -27], - ["The Unscrambled", -50, 0, -10], - ["Nightmare", 73, 0, -27, true], - ["The Amazing", -13, 0, -42], - ["Challenge Room", -94, 0, 2], - ["The Fresh", -82, 0, -10], - ["The Exemplary", -82, 0, 11], - ["The Roaming", -66, 0, -11], - ["The Veteran", -66, 0, 12], - ["The Royal", -50, 0, 10], - ["The Exact", -33, 0, -12], - ["The Appreciated", -33, 0, 11], - ["The Unsullied", -17, 0, -11], - ["The Unopposed", -18, 0, 10], - ["The Multitalented", -10, 0, 0], - ["Starting Room", 0, 0, 0], - ["Control Room", 0, 0, 14], - ["Countdown Room", 0, 0, 33, true], - ["The Lucky", 13, 1, 32, true], - ["Greenhouse", 14, 0, 6], - ["The Sweet", 24, 0, 18, true], - ["The Fall", 87, 0, -4, true], - ["White Pyramid", 46, 0, -1], - ["Z", 95, 0, 25, true], - ["The Worldly", 92, 0, 58], - ["The Perennial", 39, 0, 32], - ["The Analytical", -28, 0, 35], - ["Car Room", -59, 0, 50, true], - ["The Mythical", -35, 4, 73], - ["LL1 Starting Room", -70, 0, 41], - ["LL1 Second Room", -86, 0, 41], - ["The Seen", -83, 0, 57, true], - ["Purple Pyramid", -87, 10, 85, true], - ["Four Pips", -66, 0, 76], - ["Twinkle Twinkle Little Star", 6, 0, 55, true], - ["The Unforgettable", 9, 40, 88], - ["HI Room", 27, 0, 59], - ["The Handy", 39, 10, 83], - ["Mint Pyramid", 86, 10, 83, true], + {"title": "Orange Pyramid", "pos": [86, 10, -84], "no_start": true, "long": true}, + {"title": "The Stellar", "pos": [43, 6, -86]}, + {"title": "The Fuzzy", "pos": [12, 1, -86], "no_start": true}, + {"title": "The Devious", "pos": [0, 0, -88]}, + {"title": "The Sharp", "pos": [-26, 0, -88], "no_start": true}, + {"title": "The Structured", "pos": [-50, 0, -88]}, + {"title": "Brown Pyramid", "pos": [-86, 10, -85], "no_start": true, "long": true}, + {"title": "The Tasty", "pos": [-86, 7, -62]}, + {"title": "Black White Room", "pos": [-88, 0, -32]}, + {"title": "Lime Magenta Room", "pos": [-96, 0, -24]}, + {"title": "Red Blue Room", "pos": [-87, 0, -23]}, + {"title": "The Archaeologist", "pos": [-74, 0, -32], "long": true}, + {"title": "The Earnest", "pos": [-87, 0, -56]}, + {"title": "The Hidden", "pos": [-50, 6, -71], "no_start": true}, + {"title": "The Sapient", "pos": [-36, 36, -36]}, + {"title": "The Ethereal", "pos": [-42, 0, -22]}, + {"title": "The Learned", "pos": [34, 1, -64], "no_start": true}, + {"title": "Whispers Behind Quiet Walls", "pos": [44, 0, -51], "no_start": true, "long": true}, + {"title": "The Lunar", "pos": [45, 0, -22]}, + {"title": "The Arcadian", "pos": [86, 0, -53]}, + {"title": "The Frozen", "pos": [84, 0, -27]}, + {"title": "The Unscrambled", "pos": [-50, 0, -10]}, + {"title": "Nightmare", "pos": [73, 0, -27], "no_start": true}, + {"title": "The Amazing", "pos": [-13, 0, -42]}, + {"title": "Challenge Room", "pos": [-94, 0, 2]}, + {"title": "The Fresh", "pos": [-82, 0, -10]}, + {"title": "The Exemplary", "pos": [-82, 0, 11]}, + {"title": "The Roaming", "pos": [-66, 0, -11]}, + {"title": "The Veteran", "pos": [-66, 0, 12]}, + {"title": "The Royal", "pos": [-50, 0, 10]}, + {"title": "The Exact", "pos": [-33, 0, -12]}, + {"title": "The Appreciated", "pos": [-33, 0, 11]}, + {"title": "The Unsullied", "pos": [-17, 0, -11]}, + {"title": "The Unopposed", "pos": [-18, 0, 10]}, + {"title": "The Multitalented", "pos": [-10, 0, 0]}, + {"title": "Starting Room", "pos": [0, 0, 0]}, + {"title": "Control Room", "pos": [0, 0, 14]}, + {"title": "Countdown Room", "pos": [0, 0, 33], "no_start": true}, + {"title": "The Lucky", "pos": [13, 1, 32], "no_start": true, "long": true}, + {"title": "Greenhouse", "pos": [14, 0, 6]}, + {"title": "The Sweet", "pos": [24, 0, 18], "no_start": true}, + {"title": "The Fall", "pos": [87, 0, -4], "no_start": true, "long": true}, + {"title": "White Pyramid", "pos": [46, 0, -1], "long": true}, + {"title": "Z", "pos": [95, 0, 25], "no_start": true}, + {"title": "The Worldly", "pos": [92, 0, 58]}, + {"title": "The Perennial", "pos": [39, 0, 32]}, + {"title": "The Analytical", "pos": [-28, 0, 35]}, + {"title": "Car Room", "pos": [-59, 0, 50], "no_start": true}, + {"title": "The Mythical", "pos": [-35, 4, 73]}, + {"title": "LL1 Starting Room", "pos": [-70, 0, 41]}, + {"title": "LL1 Second Room", "pos": [-86, 0, 41]}, + {"title": "The Seen", "pos": [-83, 0, 57], "no_start": true}, + {"title": "Purple Pyramid", "pos": [-87, 10, 85], "no_start": true, "long": true}, + {"title": "Four Pips", "pos": [-66, 0, 76]}, + {"title": "Twinkle Twinkle Little Star", "pos": [6, 0, 55], "no_start": true}, + {"title": "The Unforgettable", "pos": [9, 40, 88]}, + {"title": "HI Room", "pos": [27, 0, 59]}, + {"title": "The Handy", "pos": [39, 10, 83]}, + {"title": "Mint Pyramid", "pos": [86, 10, 83], "no_start": true, "long": true}, ] +const kLEVEL_CHOICE_ANY = 0 +const kLEVEL_CHOICE_LL1 = 1 +const kLEVEL_CHOICE_LL2 = 2 -func choose_route(): +const kLENGTH_CHOICE_ANY = 0 +const kLENGTH_CHOICE_SHORT = 1 +const kLENGTH_CHOICE_LONG = 2 + + +func choose_route(levelchoice: int, lengthchoice: int): var rng = RandomNumberGenerator.new() rng.randomize() var areas_slot var level_name - if rng.randi_range(0, 2) == 0: - areas_slot = LL1_AREAS + if levelchoice == kLEVEL_CHOICE_ANY: + if rng.randi_range(0, 2) == 0: + level_name = "level1" + else: + level_name = "level2" + elif levelchoice == kLEVEL_CHOICE_LL1: level_name = "level1" - else: - areas_slot = LL2_AREAS + elif levelchoice == kLEVEL_CHOICE_LL2: level_name = "level2" + if level_name == "level1": + areas_slot = LL1_AREAS + elif level_name == "level2": + areas_slot = LL2_AREAS + var start_pos var end_pos var found = false @@ -141,9 +157,23 @@ func choose_route(): i = rng.randi_range(0, areas_dupe.size() - 1) end_pos = areas_dupe[i] - var start_vec = Vector3(start_pos[1], start_pos[2], start_pos[3]) - var end_vec = Vector3(end_pos[1], end_pos[2], end_pos[3]) - if start_vec.distance_to(end_vec) > 50 and not (start_pos.size() >= 5 and start_pos[4]): - found = true + var start_vec = Vector3(start_pos["pos"][0], start_pos["pos"][1], start_pos["pos"][2]) + var end_vec = Vector3(end_pos["pos"][0], end_pos["pos"][1], end_pos["pos"][2]) + if start_vec.distance_to(end_vec) < 50: + continue + + if start_pos.has("no_start") and start_pos["no_start"]: + continue + + if end_pos.has("long") and end_pos["long"] and lengthchoice == kLENGTH_CHOICE_SHORT: + continue + + if ( + ((end_pos.has("long") and !end_pos["long"]) or !end_pos.has("long")) + and lengthchoice == kLENGTH_CHOICE_LONG + ): + continue + + found = true return [level_name, start_pos, end_pos] -- cgit 1.4.1