Puzzle Solver Manager

The PuzzleSolverManager drives the Braid-style demo scene by spawning, configuring, and persisting every timeline clone created while a player iterates on multi-step puzzles. It implements IPuzzleSolverCloneManager, which lets the Remember Me save system restore unlimited rewind attempts alongside the underlying Time Machine timelines.


Core Responsibilities

  • Scene bootstrapping – Verifies that the GameObjectTimeMachine singleton is running, finds the player's TimeMachineRecorder, applies the Puzzle Solver preset, and wires up demo UI controls so the session starts recording immediately.

  • Clone lifecycle management – Tracks each rewind attempt, captures its duration and accumulated start time, instantiates a ghost clone, and resets the live player for the next attempt.

  • Ghost playback configuration – Builds per-clone timeline branches, copies snapshots for the correct time range, and seeds GhostPlayer fields (branch name, offsets, lap time, looping) before playback begins.

  • Save/Load integration – Bridges clone creation, bulk registration, teardown, and restoration through RememberPuzzleSolver, so save files preserve the full roster of ghosts, their timelines, and playback positions.

Purpose in one sentence: PuzzleSolverManager is the orchestration layer that keeps unlimited timeline ghosts in sync with the Time Machine recorder, the puzzle scene UI, and the Remember Me persistence pipeline.


Relationship to IPuzzleSolverCloneManager

IPuzzleSolverCloneManager defines the contract that Remember Me uses to persist clone state. PuzzleSolverManager fulfills every callback so that clone data flows seamlessly between gameplay and serialization.

Interface Method
PuzzleSolverManager Implementation

RegisterSingleCloneWithSaveSystem

Immediately forwards each newly spawned clone (branch name, duration, start time, color, looping) to RememberPuzzleSolver so that save data stays incrementally up to date.【F:Assets/Plugins/CrystalSave/Modules/TimeMachine/Runtime/PuzzleSolver/PuzzleSolverManager.cs†L695-L708】

RegisterClonesWithSaveSystem

Supports bulk registration when reconstructing multiple ghosts in one pass.【F:Assets/Plugins/CrystalSave/Modules/TimeMachine/Runtime/PuzzleSolver/PuzzleSolverManager.cs†L711-L721】

UnregisterClonesFromSaveSystem

Clears Remember Me tracking when clones are destroyed, preventing stale references in future saves.【F:Assets/Plugins/CrystalSave/Modules/TimeMachine/Runtime/PuzzleSolver/PuzzleSolverManager.cs†L724-L734】

RestoreClones

Rebuilds every ghost after load: instantiates prefabs, reapplies transparency, reconnects to existing ghost branches, and seeks playback to the remembered timestamp.【F:Assets/Plugins/CrystalSave/Modules/TimeMachine/Runtime/PuzzleSolver/PuzzleSolverManager.cs†L737-L813】

Because the manager owns all of these hooks, adding custom puzzle logic rarely requires touching Remember Me serialization—just keep using the interface methods when you spawn or clean up ghosts.


Save System Collaboration

RememberPuzzleSolver discovers any IPuzzleSolverCloneManager in the scene, mirrors clone metadata for serialization, and coordinates with RememberTimeMachine to ensure the associated timeline branches are loaded before ghosts resume playback. PuzzleSolverManager expects this component on the player object and logs warnings if it is missing, so clone playback can still occur but will not survive a save/load cycle.

During serialization, RememberPuzzleSolver stores clone counts, branch names, durations, accumulated start times, color indices, looping flags, and real-time playback positions. On load it calls RestoreClones, ensuring PuzzleSolverManager reinstantiates the ghosts before the player resumes control.


Configuring the Time Machine Preset

The Puzzle Solver workflow relies on the dedicated preset that tunes Time Machine for accumulative branching and unlimited clones. You can apply it in two complementary ways:

  1. At runtime – PuzzleSolverManager calls TimeMachinePresets.ApplyPreset(TimeMachinePresetType.PuzzleSolver) in Start(), guaranteeing the correct settings whenever the scene boots.

  2. In the editor – Open Tools ▸ Crystal Save ▸ Settings ▸ Crystal Save Settings to launch the Settings Window, then set Configuration Preset to 🧩 Puzzle Solver under TimeMachine Configuration. Selecting a preset auto-applies the tuned recording, branching, and ghost playback options to your SaveSettings asset.

Tip: After choosing the preset in the Remember Me Settings window, the editor logs a confirmation and rewrites the SaveSettings asset, so your build inherits the same Puzzle Solver behavior without needing runtime overrides.


Bringing PuzzleSolverManager into Your Project

  1. Attach the components – Place PuzzleSolverManager on a scene controller object, reference your player, UI, ghost prefab/container, and puzzle elements. Ensure the player hosts both TimeMachineRecorder and RememberPuzzleSolver components.

  2. Opt into the preset – Apply the Puzzle Solver configuration through the settings window (recommended) and allow the manager's runtime call to enforce it during play sessions.

  3. Use the interface methods – Whenever custom logic spawns or removes clones, route the events through RegisterSingleCloneWithSaveSystem or UnregisterClonesFromSaveSystem so Remember Me keeps pace with gameplay changes.

  4. Test save/load – With clones active, create a save and reload it. RestoreClones should recreate ghosts, reassign ghost branches, and resume playback at the captured timestamps.

Following these steps ensures your Puzzle Solver scenes maintain a consistent clone roster, respect Time Machine's accumulative branching model, and serialize cleanly across sessions.

Last updated