Table of Contents

Class QuestScene

Namespace
SkyrimForge
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. Call its members on the game's thread with a game loaded, which subscribing to its events does not need.

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. The saved state records 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

ArgumentNullException

name or phases is null.

ArgumentException

phases is empty. Or 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 that set a link point one alias's link with one keyword at two aliases.

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

ArgumentNullException

The value is null.

ArgumentException

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

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, since the player performs a package only while AI-driven. A phase in which an actor's standing ends is complete once each action that ends in it has ended, which the quest reads every quarter second of unpaused time. A phase with an EndsWhen lasts until that returns true instead.

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 receives this scene and 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. The value is null where the scene is not playing or its first phase has not begun.

public int? CurrentPhaseIndex { get; }

Property Value

int?

Exceptions

InvalidOperationException

The scene belongs to no quest.

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 counts no disables, so enabling a control as the scene ends also enables one that another mod or the game disabled.

Events

The events of this scene alone.

public IQuestSceneEvents Events { get; }

Property Value

IQuestSceneEvents

Exceptions

InvalidOperationException

The scene belongs to no quest.

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 a scene of this plugin's quests stops this one first regardless.

IsPlaying

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

public bool IsPlaying { get; }

Property Value

bool

Exceptions

InvalidOperationException

The scene belongs to no quest.

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. The quest declares the stage. A null value sets no 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

The index in Phases of the phase the scene plays from.

Returns

QuestSceneStartResult

Started for a scene that started, and otherwise the reason it did not.

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 created no travel package for one that travels.

InvalidOperationException

The scene belongs to no quest.

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

The index in Phases of the phase the scene plays from.

Returns

Task<QuestSceneEndReason?>

The reason the scene ended. The result is null where 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 game has no form for the package record of a ScenePackage of the scene or for the keyword of its LinkedRefPackage, or created no travel package for one that travels.

InvalidOperationException

The scene belongs to no quest.

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. No event is raised and no stage set for the phases before it, an action begun before it that runs into it starts with it, and each repeat of a scene whose Repeats is true plays from the first phase.

Returns

QuestSceneStartResult

Started for a scene that started, and otherwise the reason it did not.

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 sharing 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 where the actor has not loaded by then. The scene also ends with that reason where the destination of a travel package still to run has no reference, or the alias the link of a ScenePackage action still to run points at is empty. A load of a save written while the scene plays plays the scene again from the start of 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 created no travel package for one that travels.

InvalidOperationException

The scene belongs to no quest.

Stop()

Stops the scene. A scene not playing is left as it is.

public void Stop()

Exceptions

InvalidOperationException

The scene belongs to no quest.