# Quest

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
<span class="api-badge api-since">Added in 34.7.0</span>
</div>

<span id="T:Sansar.Simulation.Quest"></span>

The Quest is the interface for a user&#39;s progress in a Quest.

```csharp
public class Quest : Sansar.Script.InstanceInterface
```

## Remarks

Each instance of Quest is generated from a [`QuestDefinition`](/scripting/api/sansar.simulation/questdefinition) and is associated with a specific user, represented by a [`SessionId`](/scripting/api/sansar.script/sessionid). It can be used to offer the quest to that user, and to track and control their progress through the quest.

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [Agent](#agent) · [Definition](#definition) · [Objectives](#objectives) · [Ready](#ready) |
| **Methods** | [GetState](#getstate) · [Offer](#offer) · [SetState](#setstate) · [Subscribe](#subscribe) · [ToString](#tostring) · [Update](#update) |

## Properties

### Agent

<div class="api-card">
<span id="P:Sansar.Simulation.Quest.Agent"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public Sansar.Script.SessionId Agent { get; }
```

The session Id for the user on this quest.

</div>

### Definition

<div class="api-card">
<span id="P:Sansar.Simulation.Quest.Definition"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public QuestDefinition Definition { get; }
```

The [`QuestDefinition`](/scripting/api/sansar.simulation/questdefinition) for this quest.

</div>

### Objectives

<div class="api-card">
<span id="P:Sansar.Simulation.Quest.Objectives"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public Objective[] Objectives { get; }
```

Returns a list of the objectives for this quest.

</div>

### Ready

<div class="api-card">
<span id="P:Sansar.Simulation.Quest.Ready"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 36.7.0</span></div>

```csharp signature
public bool Ready { get; }
```

If the Quest data is ready.

<details class="api-remarks"><summary>Remarks</summary>

Returns false until the data has been fetched from the quest service. Once it returns true it will always return true.

</details>

</div>


## Methods

### GetState

<div class="api-card">
<span id="M:Sansar.Simulation.Quest.GetState"></span>
<span id="M:Sansar.Simulation.Quest.GetState()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public QuestState GetState()
```

The [`QuestState`](/scripting/api/sansar.simulation/queststate) representing the user&#39;s progress in the quest.

**Returns:** [QuestState](/scripting/api/sansar.simulation/queststate)

</div>

### Offer

<div class="api-card" id="offer-noargs">
<span id="M:Sansar.Simulation.Quest.Offer"></span>
<span id="M:Sansar.Simulation.Quest.Offer()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public void Offer()
```

Offer the quest to a user.

</div>

<div class="api-card" id="offer-action">
<span id="M:Sansar.Simulation.Quest.Offer(System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public void Offer(
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Offer the quest to a user.

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

</div>

### SetState

<div class="api-card" id="setstate-queststate">
<span id="M:Sansar.Simulation.Quest.SetState(Sansar.Simulation.QuestState)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public void SetState(QuestState state)
```

Set the state of the quest

| Parameter | Type | Description |
|---|---|---|
| `state` | [QuestState](/scripting/api/sansar.simulation/queststate) | The state to transition to. |

</div>

<div class="api-card" id="setstate-queststate-action">
<span id="M:Sansar.Simulation.Quest.SetState(Sansar.Simulation.QuestState,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public void SetState(
    QuestState state,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Set the state of the quest

| Parameter | Type | Description |
|---|---|---|
| `state` | [QuestState](/scripting/api/sansar.simulation/queststate) | The state to transition to. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

</div>

### Subscribe

<div class="api-card">
<span id="M:Sansar.Simulation.Quest.Subscribe(Sansar.Simulation.QuestState,System.Action{Sansar.Simulation.QuestData},System.Boolean)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public Sansar.Script.IEventSubscription Subscribe(
    QuestState State,
    Action<QuestData> callback,
    bool persistent
)
```

Subscribes to Quest Events.

| Parameter | Type | Description |
|---|---|---|
| `State` | [QuestState](/scripting/api/sansar.simulation/queststate) | The state of the quest |
| `callback` | [Action&lt;QuestData&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Callback which is executed when the event completes. |
| `persistent` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Optional, set to false to unsubscribe after one event. |

**Returns:** [Sansar.Script.IEventSubscription](/scripting/api/sansar.script/ieventsubscription) — An [`IEventSubscription`](/scripting/api/sansar.script/ieventsubscription) that can be used to cancel the subscription.

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.Quest.ToString"></span>
<span id="M:Sansar.Simulation.Quest.ToString()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.7.0</span></div>

```csharp signature
public override string ToString()
```

A string representation of this object.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — A string representation of this object.

<details class="api-remarks"><summary>Remarks</summary>

The format of this string may change between releases.

</details>

</div>

### Update

<div class="api-card" id="update-noargs">
<span id="M:Sansar.Simulation.Quest.Update"></span>
<span id="M:Sansar.Simulation.Quest.Update()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 36.7.0</span></div>

```csharp signature
public void Update()
```

Update the ObjectiveDefinition data.

<details class="api-remarks"><summary>Remarks</summary>

Use in a WaitFor to wait for the data for the QuestDefinition to be ready. Once data is retrieved and Ready is true it will never again be false.

</details>

</div>

<div class="api-card" id="update-action">
<span id="M:Sansar.Simulation.Quest.Update(System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 36.7.0</span></div>

```csharp signature
public void Update(
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Update the ObjectiveDefinition data.

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

Use in a WaitFor to wait for the data for the QuestDefinition to be ready. Once data is retrieved and Ready is true it will never again be false.

</details>

</div>


## Used in examples

- [QuestDebugExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/QuestDebugExample.cs)
- [ScriptLibrary/Quest/QuestCharacter.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestCharacter.cs)
- [ScriptLibrary/Quest/QuestGiver.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestGiver.cs)
- [ScriptLibrary/Quest/QuestGiverBase.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestGiverBase.cs)
- [ScriptLibrary/Quest/QuestGiverInteraction.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestGiverInteraction.cs)
- [ScriptLibrary/Quest/QuestGiverTrigger.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestGiverTrigger.cs)
- [ScriptLibrary/Quest/QuestObject.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestObject.cs)
- [ScriptLibrary/Quest/QuestObjectInteraction.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestObjectInteraction.cs)
- [ScriptLibrary/Quest/QuestObjectTrigger.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestObjectTrigger.cs)
- [ScriptLibrary/Quest/QuestVisibility.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestVisibility.cs)

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>