fix: room identification and save games were getting tangled up

This commit is contained in:
tiger tiger tiger 2026-01-21 15:09:59 +01:00
parent 3295c44ce9
commit c115e7b2d6
7 changed files with 17 additions and 19 deletions

View File

@ -4,8 +4,8 @@ class_name SubwaySequence
@export var all_stations: Dictionary[Station.id, Station]
@export var all_lines: Dictionary[TrainLine.id, TrainLine]
func _ready() -> void:
super._ready()
id = State.rooms.TRANSITION
super._ready()
func start_room():
@ -18,9 +18,7 @@ func start_room():
func pull_save_state(save: SaveGame) -> void:
#FIXME
save.sequences_enabled = Scenes.enabled_sequences
save.current_room = State.rooms.ADULTHOOD
save_game = save
# Call parent to restore player position

View File

@ -4,8 +4,8 @@ extends RoomTemplate
@onready var player: PlayerController = %PlayerController
func _ready():
super._ready()
id = State.rooms.ADULTHOOD
super._ready()
func get_ready() -> void:
@ -14,7 +14,6 @@ func get_ready() -> void:
Scenes.scene_finished.connect(_on_scene_finished)
card_picker.cards_picked.connect(card_board.populate_board)
save_game = State.save_game
save_game.current_room = State.rooms.ADULTHOOD
Scenes.completed_sequences = save_game.mementos_complete
Scenes.started_sequences = save_game.mementos_complete
Scenes.enabled_sequences = save_game.sequences_enabled

View File

@ -7,6 +7,11 @@ extends RoomTemplate
@onready var card_picker: CardPicker = %Picker
@onready var ui: Control = %UI
func _ready() -> void:
id = State.rooms.YOUTH
super._ready() # UwU, superclass _ready is not called by Godot automatically...
func start_room():
super.start_room()

View File

@ -19,7 +19,7 @@ func create_bug_report():
Current Focus: %s
Current Scene: %s
Mementos: %s
""" % [OS.get_name(), OS.get_video_adapter_driver_info(), Scenes.current_sequence, State.current_room, Scenes.completed_sequences]
""" % [OS.get_name(), OS.get_video_adapter_driver_info(), Scenes.current_sequence, State.room, Scenes.completed_sequences]
#debug_text = debug_text.replace(" ", "%20").replace("\n", "%0A").replace("\t", "")

View File

@ -12,24 +12,18 @@ signal proceed(next_scene_path: String)
func _ready() -> void:
State.room = self
State.current_room = id
if not State.save_game:
push_warning("Room initialised without a SaveGame. Creating proxy save.")
State.save_game = ResourceLoader.load("res://dev-util/debug_save.tres")
save_game = State.save_game
save_game.current_room = id
save_game.player_position = %PlayerController.global_position
if not Main.normal_boot:
push_warning("------- DEBUG MODE --------")
play.call_deferred()
func disable()-> void:
push_warning("Room disabling is deprecated / unter reconstruction")
func get_ready():
prints("----------", "GET_READY", self.name, "--------------")
pass

View File

@ -134,11 +134,15 @@ func save_to_file(screen_shot: Texture2D) -> void:
push_warning("SaveGame: DEBUG save skipped (intentional).")
return
if current_room == State.rooms.NULL:
push_warning("SaveGame: Not saving empty savegame.")
return
assert(State.room, "Trying to save while not in a room.")
assert(State.room.id != State.rooms.NULL, "Trying to save in a room that's not correctly initialized.")
print_debug("SaveGame: Saving to file: %s" % file_name)
# Save game can track the room it is in by itself;
# and we should never save before having successfully entered a room.
current_room = State.room.id
prints("-----------", "SAVE POINT", State.room, "-----------")
print("SaveGame: Saving to file: %s" % file_name)
# Capture current state
capture_player_state()
@ -184,7 +188,7 @@ func _validate_board_state() -> bool:
if not position is Vector2:
push_error("Save %s: Corrupted board positions" % unique_save_name)
return false
# Validate attachments (sticky must exist, card must exist)
for sticky_name in board_attachments.keys():
var card_name := board_attachments[sticky_name]

View File

@ -230,6 +230,4 @@ func pick_cards(id: Scenes.id):
await cards_picked
hide()
await get_tree().process_frame
State.room.save_room()