extends Control # Internal monologue display (per D-015) # Shows character's internal thoughts as text overlay @onready var text_panel: PanelContainer = $PanelContainer @onready var text_label: RichTextLabel = $PanelContainer/MarginContainer/RichTextLabel var fade_timer: float = 0.0 var fade_duration: float = 5.0 # Display duration before fade var is_visible: bool = false var _active_tween: Tween = null func _ready() -> void: print("MonologueDisplay: Initialized") text_panel.modulate.a = 0.0 is_visible = false func _process(delta: float) -> void: # Auto-fade after display if is_visible: fade_timer += delta if fade_timer >= fade_duration: _fade_out() # Show internal monologue text func show_monologue(text: String, duration: float = 5.0) -> void: text_label.text = text fade_duration = duration fade_timer = 0.0 is_visible = true # Cancel any active tween before starting a new one if _active_tween and _active_tween.is_valid(): _active_tween.kill() _active_tween = create_tween() _active_tween.tween_property(text_panel, "modulate:a", 1.0, 0.3) # Fade out the monologue func _fade_out() -> void: if not is_visible: return is_visible = false if _active_tween and _active_tween.is_valid(): _active_tween.kill() _active_tween = create_tween() _active_tween.tween_property(text_panel, "modulate:a", 0.0, 0.5)