Table of Contents

Class QuestScene

Namespace
SkyrimForge.Quests
Assembly
SkyrimForge.dll

A scene of a runtime quest, made of phases played in order.

public sealed class QuestScene
Inheritance
QuestScene
Inherited Members

Remarks

A scene belongs to the quest created with it or with a stage that starts it. Members that use the quest throw InvalidOperationException until that quest is created. Call its members on the game's thread with a game loaded, except when subscribing to its events.

Constructors

QuestScene(string, params IEnumerable<ScenePhase>)

Creates a scene.

public QuestScene(string name, params IEnumerable<ScenePhase> phases)

Parameters

name string

The scene's name, unique among the quest's scenes. Saves record a playing scene by it, so it must not change between plugin versions.

phases IEnumerable<ScenePhase>

The phases, played in order. A SceneAction converts to a phase of that action alone.

Exceptions

ArgumentException

phases is empty, a phase has no action and no EndsWhen, or no action is performed by an actor. Or an action's EndPhaseIndex is before its own phase or past the last phase, or a SceneConversation's is a later phase. Or two ScenePackage actions point one alias's link with one keyword at two aliases.

ArgumentNullException

name or phases is null.

Properties

ActorSettings

The settings of the scene's actors, at most one for each alias.

public IReadOnlyList<SceneActorSettings> ActorSettings { get; init; }

Property Value

IReadOnlyList<SceneActorSettings>

Exceptions

ArgumentException

Two settings specify one alias, or one specifies an alias that is no actor of the scene's actions.

ArgumentNullException

The value is null.

ActorsStayInPlace

Whether each actor that says a line or runs a package of the scene stands in place through the phases in which it runs no package of the scene. False by default.

public bool ActorsStayInPlace { get; init; }

Property Value

bool

Remarks

The player does not stand in place.

Condition

Returns whether the scene may start. A null condition always permits the start.

public Func<QuestScene, bool>? Condition { get; init; }

Property Value

Func<QuestScene, bool>

Remarks

It runs on the thread that starts the scene. An exception from it is logged and counts as false.

CurrentPhaseIndex

The index in Phases of the phase the scene plays, or null if the scene is not playing or its first phase has not begun.

public int? CurrentPhaseIndex { get; }

Property Value

int?

DisabledPlayerControls

The player controls disabled from the frame the scene begins to play until it ends. None by default.

public ScenePlayerControls DisabledPlayerControls { get; init; }

Property Value

ScenePlayerControls

Remarks

The controls are enabled between two repeats of a scene whose Repeats is true. The game does not count disables, so the scene's end also enables a control that another mod or the game disabled.

Events

The events of this scene alone.

public IQuestSceneEvents Events { get; }

Property Value

IQuestSceneEvents

IsInterruptible

Whether a scene that starts later with one of this scene's actors takes the actor and ends this one. True by default.

public bool IsInterruptible { get; init; }

Property Value

bool

Remarks

Start(int) of another scene of this plugin's quests that shares an actor stops this one regardless.

IsPlaying

Whether the scene is playing, from Start(int) until OnEnd is raised for it.

public bool IsPlaying { get; }

Property Value

bool

Name

The scene's name.

public string Name { get; }

Property Value

string

Phases

The phases, in the order played.

public IReadOnlyList<ScenePhase> Phases { get; }

Property Value

IReadOnlyList<ScenePhase>

Quest

The quest the scene belongs to.

public IRuntimeQuest Quest { get; }

Property Value

IRuntimeQuest

Exceptions

InvalidOperationException

No quest has been created with the scene or with a stage that starts it.

Repeats

Whether the scene starts again each time it ends with Completed, until Condition returns false or the scene is stopped.

public bool Repeats { get; init; }

Property Value

bool

StageSetWhenCompleted

The stage the quest sets when the scene ends with Completed, or null for none. The quest must declare the stage.

public QuestStage? StageSetWhenCompleted { get; init; }

Property Value

QuestStage

Methods

ForceStart(int)

Starts the scene as Start(int) does, except that an actor playing in a scene that is not interruptible is removed from that scene, which ends.

public QuestSceneStartResult ForceStart(int firstPhaseIndex = 0)

Parameters

firstPhaseIndex int

Returns

QuestSceneStartResult

Remarks

Each repeat of a scene whose Repeats is true starts as Start(int) does.

Exceptions

ArgumentOutOfRangeException

firstPhaseIndex is no index in the scene's phases.

InvalidOperationException

The game has no form for the package record of a ScenePackage of the scene or for the keyword of its LinkedRefPackage, or the game created no travel package for one that travels.

PlayAsync(int)

Starts the scene as Start(int) does, and returns a task that completes on the game's thread as the scene ends.

public Task<QuestSceneEndReason?> PlayAsync(int firstPhaseIndex = 0)

Parameters

firstPhaseIndex int

Returns

Task<QuestSceneEndReason?>

The reason the scene ended, or null if Start(int) would not return Started.

Remarks

The task completes at the first end of a scene whose Repeats is true, and the scene plays on. A load beginning completes it with NewGameOrSaveLoading, and the code after the await then runs during the load.

Exceptions

ArgumentOutOfRangeException

firstPhaseIndex is no index in the scene's phases.

InvalidOperationException

The scene belongs to no quest. The other failures of Start(int) are stored in the returned task.

Start(int)

Starts the scene. A scene already playing plays on, and one whose Condition returns false does not start.

public QuestSceneStartResult Start(int firstPhaseIndex = 0)

Parameters

firstPhaseIndex int

The index in Phases of the phase the scene plays from. Earlier phases raise no event and set no stage. An action begun earlier that runs into this phase starts with it. Each repeat plays from phase 0.

Returns

QuestSceneStartResult

Remarks

Starting the scene does not start the quest it belongs to. Each other scene of this plugin's quests playing with an actor of this one is stopped first, and this one starts two seconds after they have stopped playing. A scene that shares an actor alias with a scene of its quest that ended less than two seconds of unpaused time earlier starts two seconds after that end. The game ends a scene of its own that an actor of this one plays in. A start waits up to one second for an actor that is not loaded, and the scene ends with ActorUnavailable if the actor has not loaded by then. Loading a save written while the scene plays restarts the phase it was in.

Exceptions

ArgumentOutOfRangeException

firstPhaseIndex is no index in the scene's phases.

InvalidOperationException

The game has no form for the package record of a ScenePackage of the scene or for the keyword of its LinkedRefPackage, or the game created no travel package for one that travels.

Stop()

Stops the scene if it is playing.

public void Stop()