Easy Chapter Generator
EnglishEspañol

Goal and contract

This tutorial builds a relic detector that completes the active Objective after three pickup notifications. A Chapter may contain many Ordered Objectives, but it activates only the next eligible record. Your subclass detects game-specific evidence; Chapter still decides whether identity, state, and sequence position allow advancement.

Verified base class

The real public type is OverFuture.ChapterObjectiveSystem.Objectives.Objective. Its protected RequestObjectiveCompletion() returns true only when the Chapter accepts the request.

Implement the component

  1. 1
    Create CollectRelicObjective.cs in a game-owned scripts folder outside the asset folder.
  2. 2
    Add using OverFuture.ChapterObjectiveSystem.Objectives; and derive from Objective.
  3. 3
    Declare a serialized requiredRelics field and a private transient counter.
  4. 4
    In the pickup notification method, check IsCompleted, increment the counter, and call RequestObjectiveCompletion() at the threshold.
  5. 5
    Override ResetObjective(), call base.ResetObjective() first, then clear the counter.

Inspector and fallback CustomEditor

You do not need a CustomEditor to receive Objective Link, Completion, and common diagnostics. The supported fallback Editor applies to Objective subclasses and then draws their own serialized fields. Create a CustomEditor only for specialized controls; if you do, preserve the link surface and do not embed another Editor's Inspector inside it.

Alternative for a non-derived script

If an external system cannot derive from Objective, do not create a second progression hierarchy. Resolve ChapterManager.Instance, require HasActiveObjective, and call CurrentChapter.TryCompleteObjective(CurrentObjectiveId). This path fits dialogue, inventory, and middleware callbacks.

The call returns false when no Objective is active, the Chapter does not match, or a prior call was already accepted. See the compiled example under Complete and Control Progression.

When it does not complete

RequestObjectiveCompletion returns false

Check ObjectiveId, Linked status, and whether that record is active rather than merely present.

The counter survives a reset

The subclass did not override ResetObjective(), or omitted the base call.

On Completed repeats

Do not emit side effects before knowing the result. Run consequences only when RequestObjectiveCompletion() returns true.

Create a custom collectible Objective

Where to place it
Save this as CollectRelicObjective.cs and add it inside the generated Objective XX container.
When to call it
Call NotifyRelicCollected after the project confirms one relic pickup.
Behavior
The component counts only signals supplied by your game. Repeated signals after accepted completion return false, and ResetObjective clears the transient counter.
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 CollectRelicObjective : Objective
{
    [SerializeField, Min(1)]
    private int requiredRelics = 3;

    private int collectedRelics;

    public bool NotifyRelicCollected()
    {
        if (IsCompleted)
        {
            return false;
        }

        collectedRelics++;
        return collectedRelics >= Mathf.Max(1, requiredRelics) &&
               RequestObjectiveCompletion();
    }

    public override void ResetObjective()
    {
        base.ResetObjective();
        collectedRelics = 0;
    }
}