Files
imnotsick/supervisor.gd
T
2026-01-27 17:05:44 +01:00

100 lines
2.2 KiB
GDScript

extends TextureRect
@onready var mat := material as ShaderMaterial
signal reveal_done
signal hide_done
signal dialogue_finished
func _ready():
randomize()
#Noise setup
var noise := FastNoiseLite.new()
noise.noise_type = FastNoiseLite.TYPE_SIMPLEX
noise.frequency = 20.0
noise.seed = randi()
var noise_tex := NoiseTexture2D.new()
noise_tex.noise = noise
noise_tex.width = 512
noise_tex.height = 512
noise_tex.seamless = true
mat.set_shader_parameter("noise_tex", noise_tex)
#Revealing supervisor in a noise spray
func reveal_spray():
mat.set_shader_parameter("progress", 0.0)
var tween = create_tween()
tween.tween_method(set_progress, 0.0, 1.0, 3.0) \
.set_trans(Tween.TRANS_SINE) \
.set_ease(Tween.EASE_OUT)
await tween.finished
reveal_done.emit()
#hiding supervisor in a hiding spray
func hide_spray():
mat.set_shader_parameter("progress", 1.0)
var tween = create_tween()
tween.tween_method(set_progress, 1.0, 0.0, 3.0) \
.set_trans(Tween.TRANS_SINE) \
.set_ease(Tween.EASE_OUT)
await tween.finished
hide_done.emit()
#Progressing the reveal/hide
func set_progress(value: float):
mat.set_shader_parameter("progress", value)
#Supervisor dialogue, mainly between floors
func dialogue(dialogue_resource, dialogue_start):
#Loading supervisor data
var config := ConfigFile.new()
var file_path = "res://Dialogues/Patients/prime_supervisor_" + Patient.supervisor_name + "_file.cfg"
config.load(file_path)
file_path = "res://Art/Patients/prime_supervisor_" + Patient.supervisor_name + "/prime_supervisor_"
Patient.load_emotions(config, file_path)
#Showing the supervisor
texture = Patient.image
show()
reveal_spray()
await reveal_done
#Dialogue
Globals.start_balloon.emit("screening", "supervisor", dialogue_resource, dialogue_start)
await DialogueManager.dialogue_ended
#Hiding the supervisor
hide_spray()
await hide_done
hide()
dialogue_finished.emit()
#Change emotions following dialogue tags
func _change_emotion(dialogue_line) -> void:
var line_tag = dialogue_line.tags
print("Supervisor marker value: " + str(Patient.marker[0]))
if line_tag.is_empty() == false:
var new_emotion = line_tag[0]
texture = Patient.emotions[String(new_emotion)]
print("Supervisor emotion changed to ", new_emotion)