A static class that manages a quest log. More...
Classes | |
class | QuestWatchItem |
The quest watch item class is used internally by the QuestLog class to manage Lua observers on quest states. More... | |
Public Member Functions | |
delegate void | QuestChangedDelegate (string questName, QuestState newState) |
Quest changed delegate. | |
Static Public Member Functions | |
static void | RegisterQuestLogFunctions () |
static void | AddQuest (string questName, string description, string successDescription, string failureDescription, QuestState state) |
Adds a quest to the Lua Item[] table. | |
static void | AddQuest (string questName, string description, QuestState state) |
Adds a quest to the Lua Item[] table. | |
static void | AddQuest (string questName, string description) |
Adds a quest to the Lua Item[] table, and sets the state to Unassigned. | |
static void | DeleteQuest (string questName) |
Deletes a quest from the Lua Item[] table. | |
static QuestState | GetQuestState (string questName) |
Gets the quest state. | |
static string | CurrentQuestState (string questName) |
Gets the quest state. | |
static string | DefaultCurrentQuestState (string questName) |
Default built-in version of CurrentQuestState. | |
static void | SetQuestState (string questName, QuestState state) |
Sets the quest state. | |
static void | SetQuestState (string questName, string state) |
Sets the quest state, using the override delegate if assigned; otherwise using the default method DefaultSetQuestState. | |
static void | DefaultSetQuestState (string questName, string state) |
Default built-in method to set quest state. | |
static void | InformQuestStateChange (string questName) |
static void | InformQuestEntryStateChange (string questName, int entryNumber) |
static bool | IsQuestUnassigned (string questName) |
Reports whether a quest is unassigned. | |
static bool | IsQuestActive (string questName) |
Reports whether a quest is active. | |
static bool | IsQuestSuccessful (string questName) |
Reports whether a quest was successfully completed. | |
static bool | IsQuestFailed (string questName) |
Reports whether a quest ended in failure. | |
static bool | IsQuestAbandoned (string questName) |
Reports whether a quest was abandoned (i.e., in the Abandoned state). | |
static bool | IsQuestDone (string questName) |
Reports whether a quest is done, either successful or failed. | |
static bool | IsQuestInStateMask (string questName, QuestState stateMask) |
Reports whether a quest's current state is one of the states marked in a state bit mask. | |
static bool | IsQuestEntryInStateMask (string questName, int entryNumber, QuestState stateMask) |
Reports whether a quest entry's current state is one of the states marked in a state bit mask. | |
static void | StartQuest (string questName) |
Starts a quest by setting its state to active. | |
static void | CompleteQuest (string questName) |
Marks a quest successful. | |
static void | FailQuest (string questName) |
Marks a quest as failed. | |
static void | AbandonQuest (string questName) |
Marks a quest as abandoned (i.e., in the Abandoned state). | |
static QuestState | DefaultStringToState (string s) |
Converts a string representation into a state enum value. | |
static string | DefaultStateToString (QuestState state) |
static string | GetQuestTitle (string questName) |
Gets the localized quest display name. | |
static string | GetQuestDescription (string questName) |
Gets a quest description, based on the current state of the quest (i.e., SuccessDescription, FailureDescription, or just Description). | |
static string | GetQuestDescription (string questName, QuestState state) |
Gets the localized quest description for a specific state. | |
static void | SetQuestDescription (string questName, QuestState state, string description) |
Sets the quest description for a specified state. | |
static string | GetQuestAbandonSequence (string questName) |
Gets the quest abandon sequence. | |
static void | SetQuestAbandonSequence (string questName, string sequence) |
Sets the quest abandon sequence. | |
static int | GetQuestEntryCount (string questName) |
Gets the quest entry count. | |
static void | AddQuestEntry (string questName, string description) |
Adds a quest entry to a quest. | |
static string | GetQuestEntry (string questName, int entryNumber) |
Gets the localized quest entry description. | |
static void | SetQuestEntry (string questName, int entryNumber, string description) |
Sets the localized quest entry description. | |
static QuestState | GetQuestEntryState (string questName, int entryNumber) |
Gets the state of the quest entry. | |
static string | CurrentQuestEntryState (string questName, double entryNumber) |
Gets the state of the quest entry. | |
static string | DefaultCurrentQuestEntryState (string questName, int entryNumber) |
Default built-in implementation of CurrentQuestEntryState. | |
static void | SetQuestEntryState (string questName, int entryNumber, QuestState state) |
Sets the state of the quest entry. | |
static void | SetQuestEntryState (string questName, double entryNumber, string state) |
Sets the state of a quest entry. | |
static void | DefaultSetQuestEntryState (string questName, int entryNumber, string state) |
Default built-in method to set quest entry state. | |
static string | GetEntryFieldName (int entryNumber) |
static string | GetEntryStateFieldName (int entryNumber) |
static bool | IsQuestTrackingAvailable (string questName) |
Determines if quest tracking is available (that is, if the quest has a "Trackable" field). | |
static void | SetQuestTrackingAvailable (string questName, bool value) |
Specifies whether quest tracking is available (that is, if the quest has a "Trackable" field). | |
static bool | IsQuestTrackingEnabled (string questName) |
Determines if tracking is enabled for a quest. | |
static void | SetQuestTracking (string questName, bool value) |
Sets quest tracking on or off (by setting the Track field). | |
static bool | IsQuestAbandonable (string questName) |
Determines if a quest is abandonable (that is, is has a field named "Abandonable" that's true.) | |
static bool | IsQuestVisible (string questName) |
Returns true if quest has a field named "Visible" that is currently true or doesn't have the field. | |
static void | SetQuestVisibility (string questName) |
Sets a quest's Visible field true or false. | |
static bool | WasQuestViewed (string questName) |
Returns true if quest has a field named "Viewed" that is currently true. | |
static void | MarkQuestViewed (string questName) |
Marks a quest as viewed (i.e., in the quest log window). | |
static string | GetQuestGroup (string questName) |
Gets the group that a quest belongs to. | |
static string | GetQuestGroupDisplayName (string questName) |
static string[] | GetAllGroups () |
Gets all quest group names. | |
static string[] | GetAllGroups (QuestState flags) |
Gets all quest group names. | |
static string[] | GetAllGroups (QuestState flags, bool sortByGroupName) |
Gets all quest group names. | |
static string[] | GetAllQuests () |
Gets an array of all active quests. | |
static string[] | GetAllQuests (QuestState flags) |
Gets an array of all quests matching the specified state bitmask. | |
static string[] | GetAllQuests (QuestState flags, bool sortByName) |
Gets an array of all quests matching the specified state bitmask. | |
static string[] | GetAllQuests (QuestState flags, bool sortByName, string group) |
Gets an array of all quests matching the specified state bitmask and in the specified group. | |
static QuestGroupRecord[] | GetAllGroupsAndQuests (QuestState flags, bool sort=true) |
Gets all quests (including their group names) in a specified state. | |
static void | AddQuestStateObserver (string questName, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) |
Adds a quest state observer. | |
static void | AddQuestStateObserver (string questName, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) |
Adds a quest state observer. | |
static void | RemoveQuestStateObserver (string questName, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) |
Removes a quest state observer. | |
static void | RemoveQuestStateObserver (string questName, int entryNumber, LuaWatchFrequency frequency, QuestChangedDelegate questChangedHandler) |
Removes a quest state observer. | |
static void | RemoveAllQuestStateObservers () |
Removes all quest state observers. | |
static void | UpdateQuestIndicators (string questName) |
Updates all quest state listeners who are listening for questName. | |
Static Public Attributes | |
const string | UnassignedStateString = "unassigned" |
Constant state string for unassigned quests. | |
const string | ActiveStateString = "active" |
Constant state string for active quests. | |
const string | SuccessStateString = "success" |
Constant state string for successfully-completed quests. | |
const string | FailureStateString = "failure" |
Constant state string for quests ending in failure. | |
const string | AbandonedStateString = "abandoned" |
Constant state string for quests that were abandoned. | |
const string | GrantableStateString = "grantable" |
Constant state string for quests that are grantable. | |
const string | ReturnToNPCStateString = "returnToNPC" |
Constant state string for quests that are waiting to return to NPC. | |
const string | DoneStateString = "done" |
Constant state string for quests that are done, if you want to track done instead of success/failure. | |
static StringToQuestStateDelegate | StringToState = DefaultStringToState |
You can reassign this delegate method to override the default conversion of strings to QuestStates. | |
static QuestStateToStringDelegate | StateToString = DefaultStateToString |
static CurrentQuestStateDelegate | CurrentQuestStateOverride = null |
You can assign a method to override the default CurrentQuestState. | |
static SetQuestStateDelegate | SetQuestStateOverride = null |
You can assign a method to override the default SetQuestState. | |
static CurrentQuestEntryStateDelegate | CurrentQuestEntryStateOverride = null |
You can assign a method to override the default CurrentQuestEntryState. | |
static SetQuestEntryStateDelegate | SetQuestEntryStateOverride = null |
You can assign a method to override the default SetQuestEntryState. | |
static bool | trackOneQuestAtATime = false |
Set true to allow only one quest to be tracked at a time. | |
A static class that manages a quest log.
It uses the Lua "Item[]" table, where each item in the table whose 'Is Item' field is false represents a quest. This makes it easy to manage quests in Chat Mapper by adding, removing, and modifying items in the built-in Item[] table. The name of the item is the title of the quest. (Note that the Chat Mapper simulator doesn't have a quest system, so it treats elements of the Item[] table as items.)
This class uses the following fields in the Item[] table, which is also aliased as Quest[]:
unassigned
, active
, success
, failure
, or done
Note: done
is essentially equivalent to success. In the remainder of the Dialogue System's documentation, either done
or success
may be used in examples, but when using the QuestLog class, they both correspond to the same enum state, QuestState.Success.
As an example, you might define a simple quest like this:
This class provides methods to add and delete quests, get and set their state, and get their descriptions.
Note that quest states are usually updated during conversations. In most cases, you will probably set quest states in Lua code during conversations, so you may never need to use many of the methods in this class.
The UnityQuestLogWindow provides a quest log window using Unity GUI. You can use it as-is or use it as a template for implementing your own quest log window in another GUI system such as NGUI.
|
inlinestatic |
Marks a quest as abandoned (i.e., in the Abandoned state).
questName | Name of the quest. |
|
inlinestatic |
Adds a quest to the Lua Item[] table, and sets the state to Unassigned.
questName | Name of the quest. |
description | Description of the quest. |
QuestLog.AddQuest("Kill 5 Rats", "The baker asked me to bring 5 rat corpses.");
|
inlinestatic |
Adds a quest to the Lua Item[] table.
questName | Name of the quest. |
description | Description of the quest. |
state | Quest state. |
QuestLog.AddQuest("Kill 5 Rats", "The baker asked me to bring 5 rat corpses.", QuestState.Unassigned);
|
inlinestatic |
Adds a quest to the Lua Item[] table.
questName | Name of the quest. |
description | Description of the quest when active. |
successDescription | Description of the quest when successfully completed. |
failureDescription | Description of the quest when completed in failure. |
state | Quest state. |
QuestLog.AddQuest("Kill 5 Rats", "The baker asked me to bring 5 rat corpses.", QuestState.Unassigned);
|
inlinestatic |
Adds a quest entry to a quest.
questName | Name of the quest. |
entryNumber | Entry number. |
description | The quest entry description. |
|
inlinestatic |
Adds a quest state observer.
questName | Name of the quest. |
entryNumber | The entry number (1...Entry Count) in the quest. |
frequency | Frequency to check the quest state. |
questChangedHandler | Delegate to call when the quest state changes. This should be in the form: QuestState Quest state is a bit-flag enum that indicates the state of a quest. Definition QuestState.cs:12 |
|
inlinestatic |
Adds a quest state observer.
questName | Name of the quest. |
frequency | Frequency to check the quest state. |
questChangedHandler | Delegate to call when the quest state changes. This should be in the form: |
|
inlinestatic |
Marks a quest successful.
questName | Name of the quest. |
|
inlinestatic |
Gets the state of the quest entry.
questName | Name of the quest. |
entryNumber | Entry number. |
|
inlinestatic |
Gets the quest state.
questName | Name of the quest. |
|
inlinestatic |
Default built-in implementation of CurrentQuestEntryState.
|
inlinestatic |
Default built-in version of CurrentQuestState.
|
inlinestatic |
Default built-in method to set quest entry state.
|
inlinestatic |
Default built-in method to set quest state.
|
inlinestatic |
|
inlinestatic |
Converts a string representation into a state enum value.
QuestState.Active
). s | The string representation (e.g., "active"). |
|
inlinestatic |
Deletes a quest from the Lua Item[] table.
Use this method if you want to remove a quest entirely. If you just want to set the state of a quest, use SetQuestState.
questName | Name of the quest. |
QuestLog.RemoveQuest("Kill 5 Rats");
|
inlinestatic |
Marks a quest as failed.
questName | Name of the quest. |
|
inlinestatic |
Gets all quest group names.
|
inlinestatic |
Gets all quest group names.
flags | Flags for the quest states to filter. |
|
inlinestatic |
Gets all quest group names.
flags | Flags for the quest states to filter. |
sortByGroupName | If set to true sort by group name. |
|
inlinestatic |
Gets all quests (including their group names) in a specified state.
flags | A bitmask of QuestState values. |
flags | Sort by group and name. |
|
inlinestatic |
Gets an array of all active quests.
string[] activeQuests = QuestLog.GetAllQuests();
|
inlinestatic |
Gets an array of all quests matching the specified state bitmask.
flags | A bitmask of QuestState values. |
string[] completedQuests = QuestLog.GetAllQuests( QuestState.Success | QuestState.Failure );
|
inlinestatic |
Gets an array of all quests matching the specified state bitmask.
flags | A bitmask of QuestState values. |
sortByName | If true , sorts the names by name. |
string[] completedQuests = QuestLog.GetAllQuests( QuestState.Success | QuestState.Failure, true );
|
inlinestatic |
Gets an array of all quests matching the specified state bitmask and in the specified group.
flags | A bitmask of QuestState values. |
sortByName | If true , sorts the names by name. |
group | If not null, return only quests in the specified group. |
string[] completedQuests = QuestLog.GetAllQuests( QuestState.Success | QuestState.Failure, true );
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Gets the quest abandon sequence.
The QuestLogWindow plays this sequence when the player abandons a quest.
questName | Quest name. |
|
inlinestatic |
Gets a quest description, based on the current state of the quest (i.e., SuccessDescription, FailureDescription, or just Description).
questName | Name of the quest. |
GUILayout.Label("Objective: " + QuestLog.GetQuestDescription("Kill 5 Rats"));
|
inlinestatic |
Gets the localized quest description for a specific state.
questName | Name of the quest. |
state | State to check. |
|
inlinestatic |
Gets the localized quest entry description.
questName | Name of the quest. |
entryNumber | Entry number. |
|
inlinestatic |
Gets the quest entry count.
questName | Name of the quest. |
|
inlinestatic |
Gets the state of the quest entry.
questName | Name of the quest. |
entryNumber | Entry number. |
|
inlinestatic |
Gets the group that a quest belongs to.
questName | Quest name. |
|
inlinestatic |
|
inlinestatic |
Gets the quest state.
questName | Name of the quest. |
if (QuestLog.QuestState("Kill 5 Rats") == QuestState.Active) { Smith.Say("Killing rats, eh? Here, take this hammer."); }
|
inlinestatic |
Gets the localized quest display name.
questName | Name of the quest. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Determines if a quest is abandonable (that is, is has a field named "Abandonable" that's true.)
true
if the quest is abandonable; otherwise, false
.questName | Quest name. |
|
inlinestatic |
Reports whether a quest was abandoned (i.e., in the Abandoned state).
true
if the quest was abandoned; otherwise, false
.questName | Name of the quest. |
|
inlinestatic |
Reports whether a quest is active.
true
if the quest is active; otherwise, false
. questName | Name of the quest. |
|
inlinestatic |
Reports whether a quest is done, either successful or failed.
true
if the quest is done; otherwise, false
. questName | Name of the quest. |
|
inlinestatic |
Reports whether a quest entry's current state is one of the states marked in a state bit mask.
true
if the quest entry's current state is in the state bit mask. questName | Name of the quest. |
entryNumber | Quest entry number. |
stateMask | A QuestState bit mask (e.g., QuestState.Success | QuestState.Failure ). |
|
inlinestatic |
Reports whether a quest ended in failure.
true
if the quest ended in failure; otherwise, false
. questName | Name of the quest. |
|
inlinestatic |
Reports whether a quest's current state is one of the states marked in a state bit mask.
true
if the quest's current state is in the state bit mask. questName | Name of the quest. |
stateMask | A QuestState bit mask (e.g., QuestState.Success | QuestState.Failure ). |
|
inlinestatic |
Reports whether a quest was successfully completed.
true
if the quest was successfully completed; otherwise, false
. questName | Name of the quest. |
|
inlinestatic |
Determines if quest tracking is available (that is, if the quest has a "Trackable" field).
true
if quest tracking is available; otherwise, false
.questName | Quest name. |
|
inlinestatic |
Determines if tracking is enabled for a quest.
true
if tracking enabled on the specified quest; otherwise, false
.questName | Quest name. |
|
inlinestatic |
Reports whether a quest is unassigned.
true
if the quest is unassigned; otherwise, false
. questName | Name of the quest. |
|
inlinestatic |
Returns true if quest has a field named "Visible" that is currently true or doesn't have the field.
|
inlinestatic |
Marks a quest as viewed (i.e., in the quest log window).
Generally only set/used when QuestLogWindow.newQuestText is not blank.
questName |
delegate void PixelCrushers.DialogueSystem.QuestLog.QuestChangedDelegate | ( | string | questName, |
QuestState | newState | ||
) |
Quest changed delegate.
|
inlinestatic |
|
inlinestatic |
Removes all quest state observers.
|
inlinestatic |
Removes a quest state observer.
To be removed, the questName, frequency, and delegate must all match.
questName | Name of the quest. |
entryNumber | The entry number (1...Entry Count) in the quest. |
frequency | Frequency that the quest state is being checked. |
questChangedHandler | Quest changed handler delegate. |
|
inlinestatic |
Removes a quest state observer.
To be removed, the questName, frequency, and delegate must all match.
questName | Name of the quest. |
frequency | Frequency that the quest state is being checked. |
questChangedHandler | Quest changed handler delegate. |
|
inlinestatic |
Sets the quest abandon sequence.
The QuestLogWindow plays this sequence when the player abandons a quest.
questName | Quest name. |
sequence | Sequence to play when the quest is abandoned. |
|
inlinestatic |
Sets the quest description for a specified state.
questName | Name of the quest. |
state | Set the description for this state (i.e., regular, success, or failure). |
description | The description. |
|
inlinestatic |
Sets the localized quest entry description.
questName | Name of the quest. |
entryNumber | Entry number. |
description | The quest entry description. |
|
inlinestatic |
Sets the state of a quest entry.
questName | Name of the quest. |
entryNumber | Entry number. |
state | State. |
|
inlinestatic |
Sets the state of the quest entry.
questName | Name of the quest. |
entryNumber | Entry number. |
state | State. |
|
inlinestatic |
Sets the quest state.
questName | Name of the quest. |
state | New state. |
if (PiedPiperIsFree) { QuestLog.SetQuestState("Kill 5 Rats", QuestState.Failure); }
|
inlinestatic |
Sets the quest state, using the override delegate if assigned; otherwise using the default method DefaultSetQuestState.
questName | Name of the quest. |
state | New state. |
|
inlinestatic |
Sets quest tracking on or off (by setting the Track field).
If turning on tracking and tracking is currently not available (Trackable field is false), this also sets the Trackable field true.
questName | Quest name. |
value | If set to true , tracking is enabled. |
|
inlinestatic |
Specifies whether quest tracking is available (that is, if the quest has a "Trackable" field).
questName | Quest name. |
value | Trackable or not. |
|
inlinestatic |
Sets a quest's Visible field true or false.
|
inlinestatic |
Starts a quest by setting its state to active.
questName | Name of the quest. |
StartQuest("Kill 5 Rats");
|
inlinestatic |
Updates all quest state listeners who are listening for questName.
|
inlinestatic |
Returns true if quest has a field named "Viewed" that is currently true.
Used if QuestLogWindow.newQuestText is not blank.
|
static |
Constant state string for quests that were abandoned.
|
static |
Constant state string for active quests.
|
static |
You can assign a method to override the default CurrentQuestEntryState.
|
static |
You can assign a method to override the default CurrentQuestState.
|
static |
Constant state string for quests that are done, if you want to track done instead of success/failure.
This is essentially the same as success, and corresponds to the same enum value, QuestState.Success
|
static |
Constant state string for quests ending in failure.
|
static |
Constant state string for quests that are grantable.
This state isn't used by the Dialogue System, but it's made available for those who want to use it.
|
static |
Constant state string for quests that are waiting to return to NPC.
This state isn't used by the Dialogue System, but it's made available for those who want to use it.
|
static |
You can assign a method to override the default SetQuestEntryState.
|
static |
You can assign a method to override the default SetQuestState.
|
static |
|
static |
You can reassign this delegate method to override the default conversion of strings to QuestStates.
|
static |
Constant state string for successfully-completed quests.
|
static |
Set true to allow only one quest to be tracked at a time.
|
static |
Constant state string for unassigned quests.