Table of Contents

Class QuestStage

Namespace
SkyrimForge.Quests
Assembly
SkyrimForge.dll

A stage of a quest, which SetAsync() sets once.

public sealed class QuestStage
Inheritance
QuestStage
Inherited Members

Remarks

Setting the stage completes ObjectivesToComplete, fails ObjectivesToFail, ends the other open objectives as OpenObjectivesOutcome states, displays ObjectivesToDisplay, writes the log entry as the quest's description, ends the quest as QuestOutcome states, starts ScenesToStart, and then runs SetCallback, in that order. Call SetAsync(), IsDone, and IsCurrent on the game's thread with a game loaded.

Constructors

QuestStage(ushort)

A stage of a quest, which SetAsync() sets once.

public QuestStage(ushort index)

Parameters

index ushort

The stage's index, unique among the quest's stages and the same in every version of the plugin. The saved state records it.

Remarks

Setting the stage completes ObjectivesToComplete, fails ObjectivesToFail, ends the other open objectives as OpenObjectivesOutcome states, displays ObjectivesToDisplay, writes the log entry as the quest's description, ends the quest as QuestOutcome states, starts ScenesToStart, and then runs SetCallback, in that order. Call SetAsync(), IsDone, and IsCurrent on the game's thread with a game loaded.

QuestStage(ushort, Func<string>)

Creates a stage whose log entry is computed each time it is set.

public QuestStage(ushort index, Func<string> logEntry)

Parameters

index ushort

The stage's index, unique among the quest's stages and the same in every version of the plugin.

logEntry Func<string>

Returns the paragraph the journal shows under the quest's name from this stage onward. Its alias tokens are replaced as QuestObjective describes.

Exceptions

ArgumentNullException

logEntry is null.

QuestStage(ushort, string)

Creates a stage with a fixed log entry.

public QuestStage(ushort index, string logEntry)

Parameters

index ushort

The stage's index, unique among the quest's stages and the same in every version of the plugin.

logEntry string

The paragraph the journal shows under the quest's name from this stage onward. Its alias tokens are replaced as the stage is set, as QuestObjective describes.

Exceptions

ArgumentNullException

logEntry is null.

Properties

Index

The stage's index.

public ushort Index { get; }

Property Value

ushort

IsCurrent

Whether the stage is the quest's CurrentStage in the loaded game.

public bool IsCurrent { get; }

Property Value

bool

Exceptions

InvalidOperationException

No quest declares the stage.

IsDone

Whether the stage is set in the loaded game.

public bool IsDone { get; }

Property Value

bool

Exceptions

InvalidOperationException

No quest declares the stage.

LogEntry

The fixed paragraph the journal shows under the quest's name from this stage on. It is null for a stage created with a computed log entry or with none. A stage with no log entry leaves the description unchanged.

public string? LogEntry { get; }

Property Value

string

ObjectivesToComplete

The objectives the stage completes. An objective that is not displayed, or is already completed or failed, is unchanged.

public IReadOnlyList<QuestObjective> ObjectivesToComplete { get; init; }

Property Value

IReadOnlyList<QuestObjective>

Exceptions

ArgumentNullException

The value is null.

ObjectivesToDisplay

The objectives the stage displays.

public IReadOnlyList<QuestObjective> ObjectivesToDisplay { get; init; }

Property Value

IReadOnlyList<QuestObjective>

Exceptions

ArgumentNullException

The value is null.

ObjectivesToFail

The objectives the stage fails. An objective that is not displayed, or is already completed or failed, is unchanged.

public IReadOnlyList<QuestObjective> ObjectivesToFail { get; init; }

Property Value

IReadOnlyList<QuestObjective>

Exceptions

ArgumentNullException

The value is null.

OpenObjectivesOutcome

The outcome the stage gives every open objective other than those it lists in ObjectivesToComplete, ObjectivesToFail, and ObjectivesToDisplay. Null means QuestOutcome, and leaves them open when that is null as well.

public QuestOutcome? OpenObjectivesOutcome { get; init; }

Property Value

QuestOutcome?

Quest

The quest the stage belongs to.

public IRuntimeQuest Quest { get; }

Property Value

IRuntimeQuest

Exceptions

InvalidOperationException

No quest that declares the stage has been created.

QuestOutcome

The outcome the stage gives the quest, and its open objectives unless OpenObjectivesOutcome is set. Null leaves the quest open.

public QuestOutcome? QuestOutcome { get; init; }

Property Value

QuestOutcome?

ScenesToStart

The scenes the stage starts.

public IReadOnlyList<QuestScene> ScenesToStart { get; init; }

Property Value

IReadOnlyList<QuestScene>

Remarks

A scene that does not start is logged, and the stage is set regardless.

Exceptions

ArgumentNullException

The value is null.

SetCallback

Runs on the thread that sets the stage, once it is set.

public Func<QuestStageContext, Task>? SetCallback { get; init; }

Property Value

Func<QuestStageContext, Task>

Remarks

It does not run again when a save is loaded. An exception it throws faults the task SetAsync() returns, with the stage set.

Methods

SetAsync()

Sets the stage on its quest. Setting a stage that is already set does nothing.

public Task<bool> SetAsync()

Returns

Task<bool>

A task whose result is whether this call set the stage. The stage is applied before this returns, and the task completes once SetCallback does. An exception a computed log entry throws faults the task and leaves the stage unset.

Exceptions

InvalidOperationException

No quest declares the stage. The exception is stored in the returned task instead, and nothing is changed, if the stage completes or fails the quest while the quest has displayed no objective and the stage displays none, or if the stage displays an objective with no text declared or set.