Class QuestObjective
- Namespace
- SkyrimForge.Quests
- Assembly
- SkyrimForge.dll
An objective that a QuestStage displays, completes, or fails.
public sealed class QuestObjective
- Inheritance
-
QuestObjective
- Inherited Members
Remarks
A token <Alias=Name> in the text is replaced, as the objective is displayed, with the name of the reference or location that fills that alias.
An alias converts to its token in an interpolated string: $"Bring {friend} a sweetroll".
Call Display(), Complete(), Fail(), SetText(string), and SetTargetReferences<TReference>(params IEnumerable<FormId<TReference>>) on the game's thread with a game loaded.
Constructors
QuestObjective()
Creates an objective whose text SetText(string) sets before a stage displays it.
public QuestObjective()
QuestObjective(Func<string>)
Creates an objective with a computed text.
public QuestObjective(Func<string> text)
Parameters
textFunc<string>Returns the text the journal shows. It is called each time a stage displays the objective.
Exceptions
- ArgumentNullException
textisnull.
QuestObjective(string)
Creates an objective with a fixed text.
public QuestObjective(string text)
Parameters
textstring
Exceptions
- ArgumentNullException
textisnull.
Properties
Index
The objective's index, unique among the quest's objectives and the same in every version of the plugin. The saved state records it. Null means the lowest index of the stages that display it.
public ushort? Index { get; init; }
Property Value
LocationTargets
The location aliases whose locations' world location markers the objective's markers point at while it is neither completed nor failed.
public IReadOnlyList<QuestLocationAlias> LocationTargets { get; init; }
Property Value
Remarks
A location with no world location marker shows no marker and is logged.
Exceptions
- ArgumentNullException
The value is
null.
Quest
The quest the objective belongs to.
public IRuntimeQuest Quest { get; }
Property Value
Exceptions
- InvalidOperationException
No quest whose stages display, complete, or fail the objective has been created.
Targets
The aliases the objective's markers point at while it is neither completed nor failed.
public IReadOnlyList<QuestReferenceAlias> Targets { get; init; }
Property Value
Exceptions
- ArgumentNullException
The value is
null.
Methods
Complete()
Marks the objective completed, replacing a failure.
public void Complete()
Exceptions
- InvalidOperationException
No quest declares the objective, or the quest has not displayed it.
Display()
Displays the objective in the journal, and starts the quest if the quest has displayed no objective.
public void Display()
Remarks
Displaying an objective again leaves it completed or failed if it was.
Exceptions
- InvalidOperationException
No quest declares the objective, or it has no text declared or set.
Fail()
Marks the objective failed, replacing a completion.
public void Fail()
Exceptions
- InvalidOperationException
No quest declares the objective, or the quest has not displayed it.
SetTargetReferences<TReference>(params IEnumerable<FormId<TReference>>)
Sets the references the objective's markers point at besides the aliases in Targets, replacing those set before. An empty list removes them.
public void SetTargetReferences<TReference>(params IEnumerable<FormId<TReference>> referenceIds) where TReference : struct, IObjectReference
Parameters
referenceIdsIEnumerable<FormId<TReference>>
Type Parameters
TReference
Remarks
The references are saved with the quest's progress. A reference the loaded game does not have shows no marker, and the log identifies it.
Exceptions
- ArgumentNullException
referenceIdsisnull.- InvalidOperationException
No quest declares the objective.
SetText(string)
Sets the text the objective displays, replacing its declared text.
public void SetText(string text)
Parameters
textstring
Remarks
The text is saved with the quest's progress, and a stage that displays the objective later displays that text.
Exceptions
- ArgumentNullException
textisnull.- InvalidOperationException
No quest declares the objective.