Define QuestService interface.

Implements

Constructors

Accessors

  • get isSystemReady(): boolean
  • Planned

    Whether the system is ready.

    Returns boolean

    // The quest system might not be ready when the script is loaded.
    if(questService.isSystemReady){
    console.log('Quest system is ready', questService.quests);
    } else {
    questService.on('system:ready', () => {
    console.log('Quest system is ready', questService.quests);
    });
    }
  • get quests(): null | Map<number, IQuest>
  • Planned

    The information of all quests.

    Returns null | Map<number, IQuest>

Methods

  • Planned

    Add a new quest.

    Parameters

    • name: string

      The name of the quest.

    • Optionaloptions: {
          description?: string;
          onCompleted?: (() => void);
      }

      Optional parameters.

      • Optionaldescription?: string

        The description of the quest.

      • OptionalonCompleted?: (() => void)

        Callback function triggered when the quest is completed.

          • (): void
          • Returns void

    Returns IQuest

    The quest object.

    const quest = questService.addQuest(
    'Quest 1',
    {
    description: 'This is a quest.',
    onCompleted: () => console.log('Quest 1 is completed.')
    }
    );
    quest.addCheckTask('Task 1: Move', {onCompleted: () => console.log('Task 1 is completed.')});
    quest.addProgressBarTask('Task 2: Jump 3 times', 3, {onCompleted: () => console.log('Task 2 is completed.')});
    quest.start();
  • Send a specific event.

    Type Parameters

    Parameters

    • event: T

      Event name

    • Rest...args: any[]

      Event parameters

    Returns EventHandler

  • Planned

    Get a quest by ID.

    Parameters

    • id: number

      Quest ID.

    Returns null | IQuest

    The quest object.

  • Planned

    Get a quest by name. If there are multiple quests with the same name, the first one is returned.

    Parameters

    • name: string

      Quest name.

    Returns null | IQuest

    The quest object.

  • Unsubscribe from a specific event.

    Type Parameters

    Parameters

    Returns EventHandler

  • Subscribe to a specific event.

    Type Parameters

    Parameters

    Returns EventHandle

  • Planned

    Reset all quests.

    Returns void