CurrentObjectiveId está vacío
Es válido sin selección o en un estado terminal.
Programación
Consulta desde código externo el capítulo, el objetivo, sus estados y la situación de una transición con las comprobaciones necesarias.
ChapterManager.Instance es el punto público de consulta. Puede no existir aún, puede no haber Chapter seleccionado y puede no haber objetivo actual tras finalizar o fallar. Comprueba esas situaciones antes de acceder a objetos o mostrar ID.
Las propiedades ofrecen una lectura instantánea desde el hilo principal. No crean una suscripción ni vuelven a cargar el almacén.
| Propiedad | Si no existe | Uso |
|---|---|---|
| CurrentChapter / CurrentChapterId | null / string vacío | Identidad seleccionada |
| CurrentChapterState | nullable sin valor | Estado del Chapter |
| HasActiveChapter | false | Comprobación rápida |
| CurrentObjective / CurrentObjectiveId | null / string vacío | Fila actual |
| CurrentObjectiveState | nullable sin valor | Estado de la fila |
| HasActiveObjective | false | Chapter y fila activos |
| IsTransitioning | false | Evitar comandos incompatibles |
En Objective.OnCompleted el Chapter puede haber avanzado. Guarda el ID anterior o utiliza ObjectiveCompleted si lo necesitas.
Es válido sin selección o en un estado terminal.
La restauración no reproduce eventos; lee la fotografía tras Ready.
El evento local ocurre después de que el Chapter acepte y avance.
using System;
using System.Collections;
using System.Collections.Generic;
using OverFuture.ChapterObjectiveSystem.Chapters;
using OverFuture.ChapterObjectiveSystem.Events;
using OverFuture.ChapterObjectiveSystem.Objectives;
using OverFuture.ChapterObjectiveSystem.Persistence;
using OverFuture.ChapterObjectiveSystem.Progression;
using UnityEngine;
public sealed class CurrentProgressReaderExample : MonoBehaviour
{
public bool TryReadCurrentProgress(
out string chapterId,
out string objectiveId,
out ChapterObjective.ObjectiveState objectiveState)
{
chapterId = string.Empty;
objectiveId = string.Empty;
objectiveState = ChapterObjective.ObjectiveState.NotStarted;
ChapterManager manager = ChapterManager.Instance;
if (manager == null || !manager.HasActiveObjective ||
!manager.CurrentObjectiveState.HasValue)
{
return false;
}
chapterId = manager.CurrentChapterId;
objectiveId = manager.CurrentObjectiveId;
objectiveState = manager.CurrentObjectiveState.Value;
return true;
}
}