Easy Chapter Generator
EnglishEspañol

Purpose and correct use

Objective is the supported MonoBehaviour base for a scene mechanic that requests completion of one Ordered Objective. Use it directly when a UnityEvent only needs the parameterless CompleteFromEvent() entry point. Derive from it when the mechanic needs serialized fields, condition detection, local transient state, or reset behavior.

Do not use it as a second progression controller. It does not select Chapters, advance by index, persist state, or search for a similar title. Its only progression command is an exact request to the currently selected Chapter.

Inspector fields and runtime behavior

Field or propertyPurposeRule
Objective IDLinks the component to a serialized Ordered ObjectiveUse the assisted selector; exact ordinal match required
On CompletedScene response after the Chapter accepts completionNot invoked for rejected or repeated calls
IsCompletedLocal success state for this component runBecomes true only after Chapter acceptance
ObjectiveIdPublic read-only linked IDUseful for diagnostics, not mutation

TryComplete() first rejects a locally completed component. It resolves ChapterManager.Instance.CurrentChapter, calls Chapter.TryCompleteObjective(ObjectiveId), and only then marks the component complete and invokes OnCompleted. This ordering keeps the detector consistent with the authoritative ordered flow.

Completion API, idempotence, and reset

  • TryComplete() is public and returns whether the Chapter advanced.
  • CompleteFromEvent() is the UnityEvent-friendly void wrapper.
  • RequestObjectiveCompletion() is protected for subclasses and returns the same acceptance result.
  • ResetObjective() is public virtual and clears the base local completion flag.

Override Reset only when the subclass owns transient state. Call base.ResetObjective() before or after clearing that state. Do not invoke completion events from Reset and do not write directly to the Ordered Objective state.

Request completion from a subclass

Where to place it
Save this as LeverObjective.cs and attach it to the selected Objective container.
When to call it
Invoke NotifyLeverPulled from the lever's accepted interaction signal.
Behavior
RequestObjectiveCompletion accepts only the linked active Objective; a wrong ID, wrong Chapter or repeated request returns false.
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 LeverObjective : Objective
{
    public bool NotifyLeverPulled()
    {
        return RequestObjectiveCompletion();
    }
}