fix: card loading
This commit is contained in:
parent
cdcf6609d7
commit
cc73e1e4b6
|
|
@ -10,17 +10,16 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
func get_ready() -> void:
|
func get_ready() -> void:
|
||||||
super.get_ready()
|
await super.get_ready()
|
||||||
|
|
||||||
save_game = State.save_game
|
# Interactions can this way load their correct prompts
|
||||||
|
get_tree().call_group("interactables", "pull_save_state")
|
||||||
|
|
||||||
%TherapyVoluntaryInteractable.visible = not save_game.subway_burnout
|
%TherapyVoluntaryInteractable.visible = not save_game.subway_burnout
|
||||||
%TherapyUniInteractable.visible = save_game.subway_burnout
|
%TherapyUniInteractable.visible = save_game.subway_burnout
|
||||||
|
|
||||||
pull_save_state(State.save_game)
|
pull_save_state(State.save_game)
|
||||||
|
|
||||||
|
|
||||||
card_board.initialise_from_save(save_game)
|
|
||||||
card_board.board_completed.connect(func():
|
card_board.board_completed.connect(func():
|
||||||
#TODO: hook in ending
|
#TODO: hook in ending
|
||||||
#%DoorInteractable.show()
|
#%DoorInteractable.show()
|
||||||
|
|
|
||||||
|
|
@ -40,20 +40,20 @@ func _play_intro_scene() -> void:
|
||||||
await intro.interact()
|
await intro.interact()
|
||||||
|
|
||||||
|
|
||||||
func get_ready():
|
func get_ready() -> void:
|
||||||
super.get_ready()
|
await super.get_ready()
|
||||||
prints("indeed")
|
|
||||||
Scenes.scene_finished.connect(_on_scene_finished)
|
|
||||||
|
|
||||||
|
pull_save_state(State.save_game)
|
||||||
|
|
||||||
|
card_board.initialise_from_save(State.save_game)
|
||||||
|
|
||||||
|
card_board.closed.connect(save_room)
|
||||||
card_board.board_completed.connect(func():
|
card_board.board_completed.connect(func():
|
||||||
%DoorInteractable.show()
|
%DoorInteractable.show()
|
||||||
save_game.childhood_board_complete = true
|
save_game.childhood_board_complete = true
|
||||||
)
|
)
|
||||||
|
|
||||||
pull_save_state(State.save_game)
|
Scenes.scene_finished.connect(_on_scene_finished)
|
||||||
|
|
||||||
card_board.closed.connect(save_room)
|
|
||||||
|
|
||||||
card_picker.cards_picked.connect(card_board.populate_board)
|
card_picker.cards_picked.connect(card_board.populate_board)
|
||||||
|
|
||||||
ui.hide()
|
ui.hide()
|
||||||
|
|
@ -65,15 +65,18 @@ func pull_save_state(save: SaveGame) -> void:
|
||||||
save_game = save
|
save_game = save
|
||||||
save_game.current_room = id
|
save_game.current_room = id
|
||||||
|
|
||||||
# Load board state from save first, before overwriting it
|
|
||||||
card_board.initialise_from_save(save_game)
|
|
||||||
|
|
||||||
Scenes.started_sequences = save_game.mementos_complete
|
|
||||||
Scenes.completed_sequences = save_game.mementos_complete
|
|
||||||
|
|
||||||
# Interactions can this way load their correct prompts
|
# Interactions can this way load their correct prompts
|
||||||
get_tree().call_group("interactables", "pull_save_state")
|
get_tree().call_group("interactables", "pull_save_state")
|
||||||
|
|
||||||
|
card_board.initialise_from_save(save_game)
|
||||||
|
|
||||||
|
# Load board state from save first, before overwriting it
|
||||||
|
card_board.initialise_from_save(save_game)
|
||||||
|
|
||||||
|
# TODO: These should be deprecated, SaveGame is our source of truth
|
||||||
|
Scenes.started_sequences = save_game.mementos_complete
|
||||||
|
Scenes.completed_sequences = save_game.mementos_complete
|
||||||
|
|
||||||
# Call parent to restore player position
|
# Call parent to restore player position
|
||||||
super.pull_save_state(save)
|
super.pull_save_state(save)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ var id: State.rooms = State.rooms.NULL
|
||||||
@onready var scene_player : AnimationPlayer = %SceneAnimationPlayer
|
@onready var scene_player : AnimationPlayer = %SceneAnimationPlayer
|
||||||
@onready var card_board : CardBoard # Optional Board, if present - set by the board in its own _ready()
|
@onready var card_board : CardBoard # Optional Board, if present - set by the board in its own _ready()
|
||||||
|
|
||||||
var save_game:SaveGame = null
|
var save_game : SaveGame:
|
||||||
|
get: return State.save_game
|
||||||
|
|
||||||
signal proceed(next_scene_path: String)
|
signal proceed(next_scene_path: String)
|
||||||
|
|
||||||
|
|
@ -17,7 +18,6 @@ func _ready() -> void:
|
||||||
push_warning("Room initialised without a SaveGame. Creating proxy save.")
|
push_warning("Room initialised without a SaveGame. Creating proxy save.")
|
||||||
State.save_game = ResourceLoader.load("res://dev-util/debug_save.tres")
|
State.save_game = ResourceLoader.load("res://dev-util/debug_save.tres")
|
||||||
|
|
||||||
save_game = State.save_game
|
|
||||||
|
|
||||||
if not Main.normal_boot:
|
if not Main.normal_boot:
|
||||||
push_warning("------- DEBUG MODE --------")
|
push_warning("------- DEBUG MODE --------")
|
||||||
|
|
@ -26,10 +26,9 @@ func _ready() -> void:
|
||||||
|
|
||||||
func get_ready():
|
func get_ready():
|
||||||
prints("----------", "GET_READY", self.name, "--------------")
|
prints("----------", "GET_READY", self.name, "--------------")
|
||||||
pass
|
for i in range(20): await get_tree().process_frame
|
||||||
|
|
||||||
func play() -> String:
|
func play() -> String:
|
||||||
for i in range(20): await get_tree().process_frame
|
|
||||||
await get_ready()
|
await get_ready()
|
||||||
await start_room()
|
await start_room()
|
||||||
var next_room : StringName = await proceed
|
var next_room : StringName = await proceed
|
||||||
|
|
@ -43,9 +42,6 @@ func start_room():
|
||||||
|
|
||||||
|
|
||||||
func pull_save_state(_save: SaveGame) -> void:
|
func pull_save_state(_save: SaveGame) -> void:
|
||||||
# Interactions can this way load their correct prompts
|
|
||||||
get_tree().call_group("interactables", "pull_save_state")
|
|
||||||
|
|
||||||
# Override this function to load the state of the chapter from State.save_game
|
# Override this function to load the state of the chapter from State.save_game
|
||||||
restore_player_from_save(_save)
|
restore_player_from_save(_save)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -478,7 +478,7 @@ func initialise_from_save(savegame: SaveGame) -> void:
|
||||||
print(" Card '%s' at %s" % [card.name, card.position])
|
print(" Card '%s' at %s" % [card.name, card.position])
|
||||||
else:
|
else:
|
||||||
card.position = _generate_random_position()
|
card.position = _generate_random_position()
|
||||||
push_warning(" Card '%s' - no saved position, using random" % card.name)
|
print(" Card '%s' - no saved position, using random" % card.name)
|
||||||
|
|
||||||
# Attach sticky notes to cards or position them loose
|
# Attach sticky notes to cards or position them loose
|
||||||
for sticky: StickyNote in notes:
|
for sticky: StickyNote in notes:
|
||||||
|
|
@ -497,7 +497,7 @@ func initialise_from_save(savegame: SaveGame) -> void:
|
||||||
else:
|
else:
|
||||||
# Fallback to center of board
|
# Fallback to center of board
|
||||||
sticky.position = position + size / 2.0
|
sticky.position = position + size / 2.0
|
||||||
push_warning(" Sticky '%s' - no saved position, using center" % sticky.name)
|
print(" Sticky '%s' - no saved position, using center" % sticky.name)
|
||||||
|
|
||||||
|
|
||||||
# Re-sort by positions for correct z-ordering
|
# Re-sort by positions for correct z-ordering
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue