chore: hook up new direct interactable system
This commit is contained in:
parent
465b00cbd4
commit
8dfbf4ef23
|
|
@ -32,6 +32,17 @@ var has_mouse: bool = false
|
|||
func _ready():
|
||||
mouse_entered.connect(_on_mouse_entered)
|
||||
|
||||
# Wire up the CollectableUi with the CanvasLayer for story playback
|
||||
var canvas = get_node_or_null("%CanvasLayer")
|
||||
if canvas and ui:
|
||||
ui.canvas_layer = canvas
|
||||
# Find and wire the StoryPlayable if not already set
|
||||
if ui.story_playable == null:
|
||||
for child in canvas.get_children():
|
||||
if child is StoryPlayable:
|
||||
ui.story_playable = child
|
||||
break
|
||||
|
||||
func _on_mouse_entered():
|
||||
if not State.focus_locked:
|
||||
input_ray_pickable = false
|
||||
|
|
|
|||
|
|
@ -2,9 +2,13 @@ extends CenterContainer
|
|||
class_name CollectableUi
|
||||
|
||||
## The StoryPlayable to play when this memento is collected.
|
||||
## Should be a child node (typically inside a CanvasLayer for full-screen display).
|
||||
## Auto-discovered from the owner's %CanvasLayer, or can be set manually.
|
||||
@export var story_playable: StoryPlayable
|
||||
|
||||
## Reference to the CanvasLayer containing the story_playable.
|
||||
## Auto-discovered in _ready() if not set.
|
||||
var canvas_layer: CanvasLayer
|
||||
|
||||
@export var has_stage: bool = false:
|
||||
set(focused):
|
||||
if has_stage == focused: return
|
||||
|
|
@ -166,8 +170,21 @@ func _ready() -> void:
|
|||
%CollectButton.pressed.connect(collect_memento)
|
||||
##TODO: add functions for remaining buttons
|
||||
|
||||
# Auto-discover story_playable and canvas_layer from scene hierarchy
|
||||
_discover_story_playable()
|
||||
|
||||
update_state()
|
||||
|
||||
|
||||
## Ensure canvas_layer is set if story_playable was set via export.
|
||||
## InteractiveSprite._ready() handles the main wiring for inherited scenes.
|
||||
func _discover_story_playable() -> void:
|
||||
if story_playable != null and canvas_layer == null:
|
||||
# story_playable set via export, find its parent CanvasLayer
|
||||
var parent = story_playable.get_parent()
|
||||
if parent is CanvasLayer:
|
||||
canvas_layer = parent
|
||||
|
||||
func _on_context_updated() -> void:
|
||||
%SkipButton.visible = State.allow_skipping
|
||||
%SummaryButton.visible = State.provide_summaries
|
||||
|
|
@ -242,22 +259,28 @@ func collect_memento() -> void:
|
|||
is_collected = true
|
||||
return
|
||||
|
||||
# Take stage and mark sequence as starting
|
||||
State.take_stage(self)
|
||||
# Signal that a scene is starting (for music, etc.)
|
||||
Scenes.begin_sequence(scene)
|
||||
|
||||
# Hide mouse and collapse other interactables
|
||||
# Hide mouse and collapse other interactables BEFORE showing canvas
|
||||
get_tree().call_group("interactables", "collapse")
|
||||
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
|
||||
|
||||
# Play the story (StoryPlayable handles its own visibility via animations)
|
||||
# Show the CanvasLayer so the story is visible full-screen
|
||||
if canvas_layer:
|
||||
canvas_layer.show()
|
||||
|
||||
# Play the story
|
||||
await story_playable.play()
|
||||
|
||||
# Hide the CanvasLayer when done
|
||||
if canvas_layer:
|
||||
canvas_layer.hide()
|
||||
|
||||
# Restore mouse
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
# Leave stage and mark sequence as finished
|
||||
State.leave_stage(self)
|
||||
# Signal that the scene is finished
|
||||
Scenes.end_sequence(scene)
|
||||
|
||||
if was_skipped:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ var enabled_sequences: int = 255:
|
|||
set(stuff): pass
|
||||
var current_sequence: int = -1
|
||||
|
||||
## Returns true if a scene is currently playing.
|
||||
var is_playing: bool:
|
||||
get: return current_sequence != -1
|
||||
|
||||
enum id {
|
||||
YOUTH_DRAEVEN,
|
||||
YOUTH_CHILDHOOD,
|
||||
|
|
|
|||
Loading…
Reference in New Issue