Easy Chapter Generator
EnglishEspañol

Practical guide: request failure from an authoritative defeat signal

Call ChapterManager.TryFailCurrentChapter(reason) once after the project decides defeat is final. Inspect ChapterFailureResult. Only Failed changes state and invokes listeners; ManagerNotReady, NoActiveChapter, ChapterNotActive, and TransitionInProgress are rejected without notifications.

Use a short diagnostic reason such as player_defeated. Do not put localized UI copy in the reason or rely on the legacy CanFail field; V1 failure is explicit and is not gated by that preserved value.

Practical guide: show a death screen after acceptance

  1. 1
    Subscribe a UI controller to the typed ChapterFailed event.
  2. 2
    In the callback, display the project death panel and record information.Chapter.Identifier if restart needs it.
  3. 3
    Apply input locking, cursor state, accessibility focus, and animation through project services.
  4. 4
    Unsubscribe the exact receiver when the UI controller disables or the scene unloads.

The serialized On Failure is sufficient for a parameterless panel activation. The typed event is preferable when UI or telemetry needs the reason or affected Objective.

Practical guide: choose one explicit recovery policy

Restart in place

Call TrySelectChapter(failedChapterId). This performs a fresh Chapter start and clears that Chapter's known persisted progress.

Reload the scene

Call ReloadCurrentScene(true) to transition with the current Chapter ID. Observe OnBeforeSceneLoad and handoff rules.

Return elsewhere

Call TransitionToScene with the destination scene and optional Chapter/Objective policy owned by the project.

Disable the Restart button while IsTransitioning is true and require the command result. Failure itself never performs these actions.

Acceptance tests

  • A valid defeat returns Failed, marks states before callbacks, and invokes typed failure before OnFailure.
  • Two defeat calls produce one accepted notification; the second is rejected because the Chapter is no longer Active.
  • A failure during transition returns TransitionInProgress and changes nothing.
  • Displaying the death screen does not reload or alter progress by itself.
  • The chosen restart path restores project-owned world and UI state, not only progression state.