fix: board now knows it's board

This commit is contained in:
tiger tiger tiger 2026-01-05 21:52:20 +01:00
parent 9da3692b60
commit 31977a731c
3 changed files with 28 additions and 21 deletions

View File

@ -1,6 +1,7 @@
class_name InteractiveSprite extends Area3D
@export var interaction_ui: PackedScene = null
@export var is_board: bool = false
@onready var pass_to_actor: = $UiWrapper/UiSprite/SubViewport/CollectableUi
@onready var wrapper := $UiWrapper
@ -9,6 +10,7 @@ class_name InteractiveSprite extends Area3D
@onready var distance_tween: Tween
var revealed: bool = false:
set(reveal):
revealed = reveal
@ -37,11 +39,13 @@ func _ready():
ui.canvas_layer = %CanvasLayer
# Find and wire the StoryPlayable if not already set
if ui.story_playable == null:
for child in %CanvasLayer.get_children():
if child is StoryPlayable:
ui.story_playable = child
break
for child in %CanvasLayer.get_children():
if child is StoryPlayable:
ui.story_playable = child
break
if child is CardBoard:
ui.is_board = true
# Connect playback_finished to restore player control
ui.playback_finished.connect(_on_playback_finished)

View File

@ -8,6 +8,8 @@ enum Error {
MISSING
}
const is_board := true
var focus_stickies:bool = true:
set(stickies):
if not is_node_ready(): return

View File

@ -1,7 +1,7 @@
extends CenterContainer
class_name CollectableUi
class_name CollectableUi
@onready var canvas_layer: CanvasLayer = %CanvasLayer
@onready var canvas_layer: CanvasLayer = %CanvasLayer
## The StoryPlayable to play when this memento is collected.
## Auto-discovered from the owner's %CanvasLayer, or can be set manually.
@ -127,6 +127,7 @@ var story_playable: StoryPlayable
else:
scene = scene
collected_box.show()
@export var is_exit:bool = false:
set(exit):
is_exit = exit
@ -151,7 +152,7 @@ func _ready() -> void:
State.settings_changed.connect(_on_context_updated)
%CollectButton.pressed.connect(collect_memento)
##TODO: add functions for remaining buttons
update_state()
@ -217,44 +218,44 @@ func vanish() -> void:
func collect_memento() -> void:
print_debug("CollectableUi.collect_memento() - scene: %s" % Scenes.id.keys()[scene])
# Hide the collectable UI
vanish()
# Check if we have a story_playable to play
if story_playable == null:
push_warning("CollectableUi for scene %s has no story_playable assigned" % Scenes.id.keys()[scene])
if was_skipped:
if was_skipped:
scene_skipped.emit(-1)
is_collected = true
playback_finished.emit()
return
# Signal that a scene is starting (for music, etc.)
Scenes.begin_sequence(scene)
# Hide mouse and collapse other interactables BEFORE showing canvas
get_tree().call_group("interactables", "collapse")
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
# Show the CanvasLayer so the story is visible full-screen
canvas_layer.show()
# Play the story
await story_playable.play()
# Hide the CanvasLayer when done
canvas_layer.hide()
# Restore mouse to captured mode (player controller will be given back control)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
# Signal that the scene is finished
Scenes.end_sequence(scene)
if was_skipped:
if was_skipped:
scene_skipped.emit(-1)
is_collected = true
# Signal that playback is finished so the InteractiveSprite can restore player control
playback_finished.emit()