Files
imnotsick/Scenes/screening_desk/screening_desk.gd
T
2026-03-03 12:04:45 +01:00

240 lines
7.5 KiB
GDScript

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_screen = $LowerHalf/Console/Margin/ConsoleScreen
@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
var accurate_diagnoses = 0
func _ready() -> void:
#Referencing main node
main = get_parent()
#Connecting signals
computer.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.color_change.connect(self._on_color_change)
room_assets.reset()
hide() #Hiding ScreeningDesk
message_array.resize(3) #Setting up message array
#Selecting next patient
func new_patient():
var new_id = Patient.next_patient()
#Patient.new_patient("49") #Line for testing purposes
Patient.new_patient(new_id) #Line for generating new patient
computer.patient_file.text = Patient.file_text
computer.recording.text = ""
patient.texture = Patient.image
func _on_call_next_patient_pressed(): #Brings in next patient and sets up the desk controls
#Selecting next_patient
new_patient()
#Hiding the next_patient button
var scenes_to_hide = [computer.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...", "orange_red")
computer.display(message)
message = Globals.colorize("- BRINGING IN NEXT PATIENT -", "dark_orange")
console_screen.display(message)
#Shutters entry animation
room_assets.cell_animation.play("incoming")
room_assets.cell_top.show()
room_assets.cell_bot.show()
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_top.hide()
room_assets.cell_bot.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
computer.screen.hide()
console_screen.hide()
main.start_balloon("screening", "patient", Patient.dialogue_resource, "start")
#Showing Computer Tabs and showing Patient File Screen by default
for tab in computer.tab_list:
tab.show()
tab.set_mouse_filter(Control.MOUSE_FILTER_STOP)
computer.patient_file.show()
#Updating patient_count
Globals.patient_count += 1
#Starts release or termination protocols when the corresponding button is pressed
func _on_decision_made(choice: String):
#Hiding computer tabs screen
for node in computer.tab_list + computer.screen_list:
node.hide()
#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_screen.display(message_array[0])
computer.display(message_array[2])
#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.abnormal == true and choice == "terminate") or (Patient.abnormal == false and choice == "release"):
accurate_diagnoses += 1
else:
accurate_diagnoses = 0 # Resetting to 0 if the player makes a wrong diagnosis
middle_screen.update(Globals.day_count, Globals.floor_count, accurate_diagnoses, Globals.diagnoses_quota)
#Showing second console message
console_screen.display(message_array[1])
#Closing Shutters
room_assets.cell_top.show()
room_assets.cell_bot.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()
#Descending Floor if diagnoses_quota reached
if accurate_diagnoses == Globals.diagnoses_quota:
descend_floor()
else:
#Setting up UI
computer.next_patient_button.show()
console_screen.display(Globals.directives)
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
#Displaying information on screens
var message : String
message = Globals.colorize("DIAGNOSES QUOTA REACHED", "green_yellow") + "\n\n" + "SECURITY CLEARANCE UPDATED" + "\n\n" + Globals.colorize("ACCESS TO NEXT FLOOR AUTHORIZED", "green")
computer.display(message)
message = Globals.colorize("- DESCENT PROTOCOL INITIATED -\n\n- TRANSLATING TO NEXT FLOOR -", "dark_orange")
console_screen.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
#Updating middle screen info
Globals.floor_count -= 1
accurate_diagnoses = 0
Globals.diagnoses_quota += 1
middle_screen.update(Globals.day_count, Globals.floor_count, accurate_diagnoses, Globals.diagnoses_quota)
#Resetting patient_count
Globals.patient_count = 0
#Updating journal symptoms
journal_layer.update_journal(Globals.floor_count)
#Hiding screen messages
computer.screen.hide()
console_screen.hide()
#Interfloor dialogue
supervisor.dialogue("interfloor_" + str(-Globals.floor_count-1))
await supervisor.dialogue_finished
#Setting up UI
computer.next_patient_button.show()
console_screen.display(Globals.directives)
#Resets to initial state
func reset():
for node in [patient, supervisor, journal_layer, computer, console_screen, release, terminate,
green_button, red_button, room_assets]:
node.reset()