extends Control #DeskAssets @onready var patient = $UpperHalf/ControlGlass/Patient @onready var supervisor = $UpperHalf/ControlGlass/Supervisor @onready var green_button = $LowerHalf/GreenButton @onready var red_button = $LowerHalf/RedButton @onready var journal = $LowerHalf/Journal/JournalButton @onready var journal_layer = $JournalLayer @onready var release = $LowerHalf/DecisionScreen/MarginContainer/HBoxContainer/Release @onready var terminate = $LowerHalf/DecisionScreen/MarginContainer/HBoxContainer/Terminate @onready var patient_color: Color @onready var computer = $LowerHalf/Computer @onready var middle_screen = $LowerHalf/MiddleScreen/MarginContainer/MiddleScreen @onready var console = $LowerHalf/Console @onready var room_assets = $RoomAssets #DialogueAssets @onready var patient_dialogue_resource: Resource @onready var balloon: Node @onready var patient_emotions : Dictionary @onready var message_array: Array[String] var main: Node func _ready() -> void: #Referencing main node main = get_parent() #Connecting signals console.next_patient_button.pressed.connect(self._on_call_next_patient_pressed) red_button.decision_made.connect(self._on_decision_made) green_button.decision_made.connect(self._on_decision_made) journal.pressed.connect(journal_layer._on_journal_pressed) Globals.clear_patient.connect(self._on_clear_patient) Globals.decision_made.connect(self._on_decision_made) Globals.color_change.connect(self._on_color_change) Globals.next_event.connect(self.event_manager) Globals.add_objective.connect(journal_layer.add_objective) room_assets.reset() hide() #Hiding ScreeningDesk message_array.resize(3) #Setting up message array #Manages what event should happen next func event_manager(): match Globals.event_index: "interfloor": supervisor.dialogue("interfloor_" + str(-Globals.floor_count-1)) "next_patient": console.next_patient_button.show() "descend": descend_floor() "supervisor": supervisor.dialogue("dialogue_" + str(Globals.supervisor_index)) func _on_call_next_patient_pressed(): #Brings in next patient and sets up the desk controls #Selecting next patient Patient.load_patient(Patient.next_patient()) #Updating patient information computer.patient_file.text = Patient.file_text computer.recording.text = "" patient.texture = Patient.image #Hiding the next_patient button var scenes_to_hide = [console.next_patient_button, supervisor] for scenes in scenes_to_hide: scenes.hide() # Shows transition messages on computer and console var message : String message = Globals.colorize("COMPUTING CELL TRANSLATION...\n\n\n- BRINGING IN NEXT PATIENT -", "dark_orange") console.display(message) #Shutters entry animation room_assets.cell_door.show() room_assets.cell_animation.play("incoming") await room_assets.cell_animation.animation_finished #Showing the Patient and the Backroom var scenes_to_show = [patient, room_assets.cell_wall] for scene in scenes_to_show: scene.show() #Opening Shutters room_assets.cell_animation.play("open") await room_assets.cell_animation.animation_finished room_assets.cell_door.hide() #Activating Buttons green_button.set_disabled(false) red_button.set_disabled(false) #Coloring Release and Terminate release.text = Globals.colorize("RELEASE", "dark_green") terminate.text = Globals.colorize("TERMINATE", "dark_red") #Starting Dialogue and hiding console screen console.screen.hide() main.start_balloon("screening", "patient", Patient.dialogue_resource, Patient.dialogue_start) computer.tab_switch(computer.tab_patient_file, computer.patient_file) #Starts release or termination protocols when the corresponding button is pressed func _on_decision_made(choice: String): #Setting up console and computer displays if choice == "release": release.text = Globals.colorize("RELEASE", "green") #Highlighting the decision message_array = Globals.release_messages elif choice == "terminate": terminate.text = Globals.colorize("TERMINATE", "red") #Highlighting the decision message_array = Globals.terminate_messages console.display(message_array[0]) #Disabling Buttons green_button.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) red_button.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) #Final Patient Dialogue main.start_balloon("screening", "patient", Patient.dialogue_resource, choice) #Clears patient and transitions towards next patient or end of day func _on_clear_patient(choice:String): # Updating middle screen info and accurate_diagnoses value if Patient.spy.order and Patient.spy.spy_check(): Globals.accurate_diagnoses += 1 Patient.spy.count += 1 elif (Patient.abnormal == true and choice == "terminate") or (Patient.abnormal == false and choice == "release"): Globals.accurate_diagnoses += 1 else: Globals.misdiagnoses += 1 Globals.misdiagnoses_allowed -= 1 #Reducing remaining mistakes allowed if the player makes a wrong diagnosis Patient.update_list() #Updating patient list Globals.patient_count += 1 #Updating patient_count #Updating middle screen info middle_screen.update(Globals.floor_count, Globals.patient_count, Globals.patient_quota) #Updating statistics tab computer.update_statistics(Globals.accurate_diagnoses, Globals.misdiagnoses) #Showing second console message console.display(message_array[1]) #Closing Shutters room_assets.cell_door.show() room_assets.cell_animation.play("close") await room_assets.cell_animation.animation_finished #Hiding patient and cell_wall for node in [patient, room_assets.cell_wall]: node.hide() #Playing release or terminate cell animation room_assets.cell_animation.play(choice) await room_assets.cell_animation.animation_finished #Resetting the scene reset() #GameOver if too many misdiagnoses were made if Globals.misdiagnoses_allowed == -1 and Globals.misdiagnoses_game_over: UI.game_over.reveal("YOU MADE TOO MANY MISTAKES") #Descending Floor if patient_quota is reached if Globals.patient_count == Globals.patient_quota: Globals.event_index = "descend" event_manager() func _on_color_change(color: String): #Modulating backroom and patient colors var new_color: Color match color: "red": new_color = Color(1,0.1,0.1,1) "green": new_color = Color(0.5,1,0.5,1) patient.modulate = new_color room_assets.cell_wall.modulate = new_color print("Color changed to: " + str(new_color)) func descend_floor(): #Descends to next floor #Updating Global variables Globals.event_index = "interfloor" Globals.floor_count -= 1 Globals.patient_count = 0 if Globals.floor_count >= -3: #Resetting misdiagnoses allowance for the first few floors Globals.misdiagnoses_allowed = 2 #Displaying information on screens var message : String message = Globals.colorize("PATIENT QUOTA REACHED", "green_yellow") + "\n\n" + "SECURITY CLEARANCE UPDATED" + "\n\n" + Globals.colorize("ACCESS TO NEXT FLOOR AUTHORIZED", "green") message += Globals.colorize("\n\n\n\n- DESCENT PROTOCOL INITIATED -\n\n- TRANSLATING TO NEXT FLOOR -", "dark_orange") console.display(message) #Descending animation room_assets.backwall_animation.play("going_down_1") await room_assets.backwall_animation.animation_finished room_assets.backwall_animation.play("going_down_2") await room_assets.backwall_animation.animation_finished for node in [middle_screen, computer, console, journal_layer]: node.reset() #Resetting the scene main.save_game(0) #Autosaving event_manager() #Selecting next event #Resets to initial state func reset(): for node in [patient, supervisor, journal_layer, computer, console, middle_screen, release, terminate, green_button, red_button, room_assets]: node.reset()