PixelCrushers.DialogueSystem.ConversationModel Class Reference

Handles logic for the data model of a conversation. More...

Public Member Functions

 ConversationModel (DialogueDatabase database, string title, Transform actor, Transform conversant, bool allowLuaExceptions, IsDialogueEntryValidDelegate isDialogueEntryValid, int initialDialogueEntryID=-1, bool stopAtFirstValid=false, bool skipExecution=false)
 Initializes a new ConversationModel.
 
int GetConversationID (ConversationState state)
 
ConversationOverrideDisplaySettings GetConversationOverrideSettings (ConversationState state)
 
void InformParticipants (string message, bool informDialogueManager=false)
 Sends a message to the actor and conversant.
 
ConversationState GetState (DialogueEntry entry, bool includeLinks, bool stopAtFirstValid=false, bool skipExecution=false)
 "Follows" a dialogue entry and returns its full conversation state.
 
void ForceNextStateToLinkToEntry (DialogueEntry entry)
 Forces the next state to link to a specific dialogue entry instead of its designed links.
 
ConversationState GetState (DialogueEntry entry)
 "Follows" a dialogue entry and returns its full conversation state.
 
void UpdateResponses (ConversationState state)
 Updates the responses in the specified state.
 
void SetParticipants (Conversation conversation, Transform actor, Transform conversant)
 
void UpdateParticipantsOnLinkedConversation (int newConversationID)
 Call when linking to another conversation.
 
void OverrideCharacterInfo (int id, Transform character)
 Overrides the conversation model's cached info for a character.
 
CharacterInfo GetCharacterInfo (int id, Transform character)
 Gets the character info for a character given its actor ID and transform.
 
CharacterInfo GetCharacterInfo (int id)
 Gets the character info for a character given its actor ID.
 
void SetActorPortraitSprite (string actorName, Sprite sprite)
 Updates the actor portrait sprite for any cached character info.
 
string GetPCName ()
 Returns the name of the PC in this conversation.
 
Sprite GetPCSprite ()
 Returns the portrait sprite of the PC in this conversation.
 

Properties

string conversationTitle [get]
 Title of the conversation that started this ConversationModel.
 
ConversationState firstState [get]
 The first state in the conversation, which is the root of the dialogue tree.
 
CharacterInfo actorInfo [get]
 Info about the character that is specified as the actor in the conversation.
 
CharacterInfo conversantInfo [get]
 Info about the character that is specified as the conversant in the conversation.
 
bool hasValidEntry [get]
 Indicates whether the conversation has any responses linked from the start entry.
 
IsDialogueEntryValidDelegate isDialogueEntryValid [get, set]
 Gets or sets the IsDialogueEntryValid delegate.
 
bool allowLuaExceptions [get, set]
 
EntrytagFormat entrytagFormat [get, set]
 
EmTag emTagForOldResponses [get, set]
 
EmTag emTagForInvalidResponses [get, set]
 
bool includeInvalidEntries [get, set]
 

Detailed Description

Handles logic for the data model of a conversation.

This class retrieves dialogue entries and updates the data state, which includes the dialogue database and Lua environment. It does not keep track of state or handle the user interface. The ConversationController controls the current state of the conversation, and ConversationView handles the user interface.

Constructor & Destructor Documentation

◆ ConversationModel()

PixelCrushers.DialogueSystem.ConversationModel.ConversationModel ( DialogueDatabase  database,
string  title,
Transform  actor,
Transform  conversant,
bool  allowLuaExceptions,
IsDialogueEntryValidDelegate  isDialogueEntryValid,
int  initialDialogueEntryID = -1,
bool  stopAtFirstValid = false,
bool  skipExecution = false 
)
inline

Initializes a new ConversationModel.

Parameters
databaseThe database to use.
titleThe title of the conversation in the database.
actorActor.
conversantConversant.
allowLuaExceptionsIf set to true allow Lua exceptions.
isDialogueEntryValidIs dialogue entry valid.
initialDialogueEntryIDInitial dialogue entry ID (-1 to start at beginning).
stopAtFirstValidIf set to true stop at first valid link from the initial entry.
skipExecutionIF set to true, doesn't run the Lua Script or OnExecute event on the initial entry.

Member Function Documentation

◆ ForceNextStateToLinkToEntry()

void PixelCrushers.DialogueSystem.ConversationModel.ForceNextStateToLinkToEntry ( DialogueEntry  entry)
inline

Forces the next state to link to a specific dialogue entry instead of its designed links.

◆ GetCharacterInfo() [1/2]

CharacterInfo PixelCrushers.DialogueSystem.ConversationModel.GetCharacterInfo ( int  id)
inline

Gets the character info for a character given its actor ID.

Returns
The character info.
Parameters
idThe character's actor ID in the dialogue database.

◆ GetCharacterInfo() [2/2]

CharacterInfo PixelCrushers.DialogueSystem.ConversationModel.GetCharacterInfo ( int  id,
Transform  character 
)
inline

Gets the character info for a character given its actor ID and transform.

Returns
The character info.
Parameters
idThe character's actor ID in the dialogue database.
characterThe transform of the character's GameObject.

◆ GetConversationID()

int PixelCrushers.DialogueSystem.ConversationModel.GetConversationID ( ConversationState  state)
inline

◆ GetConversationOverrideSettings()

ConversationOverrideDisplaySettings PixelCrushers.DialogueSystem.ConversationModel.GetConversationOverrideSettings ( ConversationState  state)
inline

◆ GetPCName()

string PixelCrushers.DialogueSystem.ConversationModel.GetPCName ( )
inline

Returns the name of the PC in this conversation.

Returns
The PC name, or null if both are NPCs.

◆ GetPCSprite()

Sprite PixelCrushers.DialogueSystem.ConversationModel.GetPCSprite ( )
inline

Returns the portrait sprite of the PC in this conversation.

Returns
The PC sprite, or null if both are NPCs.

◆ GetState() [1/2]

ConversationState PixelCrushers.DialogueSystem.ConversationModel.GetState ( DialogueEntry  entry)
inline

"Follows" a dialogue entry and returns its full conversation state.

This method updates the Lua environment (marking the entry as visited) and evaluates all links from the dialogue entry and records valid links in the state.

Returns
The state representing the dialogue entry.
Parameters
entryThe dialogue entry to "follow."

◆ GetState() [2/2]

ConversationState PixelCrushers.DialogueSystem.ConversationModel.GetState ( DialogueEntry  entry,
bool  includeLinks,
bool  stopAtFirstValid = false,
bool  skipExecution = false 
)
inline

"Follows" a dialogue entry and returns its full conversation state.

This method updates the Lua environment (marking the entry as visited). If includeLinks is true, it evaluates all links from the dialogue entry and records valid links in the state.

Returns
The state.
Parameters
entryThe dialogue entry to "follow."
includeLinksIf set to true records all links from the dialogue entry whose conditions are true.
stopAtFirstValidIf set to true ,stops including at the first valid link.
skipExecutionIF set to true, doesn't run the Lua Script or OnExecute event.

◆ InformParticipants()

void PixelCrushers.DialogueSystem.ConversationModel.InformParticipants ( string  message,
bool  informDialogueManager = false 
)
inline

Sends a message to the actor and conversant.

Used to send OnConversationStart and OnConversationEnd messages.

Parameters
messageThe message (e.g., OnConversationStart or OnConversationEnd).

◆ OverrideCharacterInfo()

void PixelCrushers.DialogueSystem.ConversationModel.OverrideCharacterInfo ( int  id,
Transform  character 
)
inline

Overrides the conversation model's cached info for a character.

Parameters
idActor ID
characterCharacter's transform. Will use its Dialogue Actor info if present.

◆ SetActorPortraitSprite()

void PixelCrushers.DialogueSystem.ConversationModel.SetActorPortraitSprite ( string  actorName,
Sprite  sprite 
)
inline

Updates the actor portrait sprite for any cached character info.

Parameters
actorNameActor name.
spritePortrait sprite.

◆ SetParticipants()

void PixelCrushers.DialogueSystem.ConversationModel.SetParticipants ( Conversation  conversation,
Transform  actor,
Transform  conversant 
)
inline
Parameters
conversation
actor
conversant

◆ UpdateParticipantsOnLinkedConversation()

void PixelCrushers.DialogueSystem.ConversationModel.UpdateParticipantsOnLinkedConversation ( int  newConversationID)
inline

Call when linking to another conversation.

If the player actor has changed, this method updates the PC portrait name and image.

◆ UpdateResponses()

void PixelCrushers.DialogueSystem.ConversationModel.UpdateResponses ( ConversationState  state)
inline

Updates the responses in the specified state.

Parameters
stateState to check.

Property Documentation

◆ actorInfo

CharacterInfo PixelCrushers.DialogueSystem.ConversationModel.actorInfo
get

Info about the character that is specified as the actor in the conversation.

This is typically the character that initiates the conversation, such as the PC.

◆ allowLuaExceptions

bool PixelCrushers.DialogueSystem.ConversationModel.allowLuaExceptions
getset

◆ conversantInfo

CharacterInfo PixelCrushers.DialogueSystem.ConversationModel.conversantInfo
get

Info about the character that is specified as the conversant in the conversation.

This is the other character in the conversation (e.g., the NPC in a PC-NPC conversation).

◆ conversationTitle

string PixelCrushers.DialogueSystem.ConversationModel.conversationTitle
get

Title of the conversation that started this ConversationModel.

◆ emTagForInvalidResponses

EmTag PixelCrushers.DialogueSystem.ConversationModel.emTagForInvalidResponses
getset

◆ emTagForOldResponses

EmTag PixelCrushers.DialogueSystem.ConversationModel.emTagForOldResponses
getset

◆ entrytagFormat

EntrytagFormat PixelCrushers.DialogueSystem.ConversationModel.entrytagFormat
getset

◆ firstState

ConversationState PixelCrushers.DialogueSystem.ConversationModel.firstState
get

The first state in the conversation, which is the root of the dialogue tree.

The first state.

◆ hasValidEntry

bool PixelCrushers.DialogueSystem.ConversationModel.hasValidEntry
get

Indicates whether the conversation has any responses linked from the start entry.

true if the conversation has responses; otherwise, false.

◆ includeInvalidEntries

bool PixelCrushers.DialogueSystem.ConversationModel.includeInvalidEntries
getset

◆ isDialogueEntryValid

IsDialogueEntryValidDelegate PixelCrushers.DialogueSystem.ConversationModel.isDialogueEntryValid
getset

Gets or sets the IsDialogueEntryValid delegate.


The documentation for this class was generated from the following file: