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. More...
 
int GetConversationID (ConversationState state)
 
ConversationOverrideDisplaySettings GetConversationOverrideSettings (ConversationState state)
 
void InformParticipants (string message, bool informDialogueManager=false)
 Sends a message to the actor and conversant. More...
 
ConversationState GetState (DialogueEntry entry, bool includeLinks, bool stopAtFirstValid=false, bool skipExecution=false)
 "Follows" a dialogue entry and returns its full conversation state. More...
 
ConversationState GetState (DialogueEntry entry)
 "Follows" a dialogue entry and returns its full conversation state. More...
 
void UpdateResponses (ConversationState state)
 Updates the responses in the specified state. More...
 
CharacterInfo GetCharacterInfo (int id, Transform character)
 Gets the character info for a character given its actor ID and transform. More...
 
CharacterInfo GetCharacterInfo (int id)
 Gets the character info for a character given its actor ID. More...
 
void SetActorPortraitTexture (string actorName, Texture2D portraitTexture)
 Updates the actor portrait texture for any cached character info. More...
 
string GetPCName ()
 Returns the name of the PC in this conversation. More...
 
Texture2D GetPCTexture ()
 Returns the portrait texture of the PC in this conversation. More...
 

Properties

ConversationState FirstState [get]
 The first state in the conversation, which is the root of the dialogue tree. More...
 
CharacterInfo ActorInfo [get]
 Gets the actor info for this conversation. More...
 
CharacterInfo ConversantInfo [get]
 Gets the conversant info for this conversation. More...
 
bool HasValidEntry [get]
 Indicates whether the conversation has any responses linked from the start entry. More...
 
IsDialogueEntryValidDelegate IsDialogueEntryValid [get, set]
 Gets or sets the IsDialogueEntryValid delegate. More...
 

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 
)

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

◆ GetCharacterInfo() [1/2]

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

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 
)

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)

◆ GetConversationOverrideSettings()

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

◆ GetPCName()

string PixelCrushers.DialogueSystem.ConversationModel.GetPCName ( )

Returns the name of the PC in this conversation.

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

◆ GetPCTexture()

Texture2D PixelCrushers.DialogueSystem.ConversationModel.GetPCTexture ( )

Returns the portrait texture of the PC in this conversation.

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

◆ GetState() [1/2]

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

"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 
)

"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 
)

Sends a message to the actor and conversant.

Used to send OnConversationStart and OnConversationEnd messages.

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

◆ SetActorPortraitTexture()

void PixelCrushers.DialogueSystem.ConversationModel.SetActorPortraitTexture ( string  actorName,
Texture2D  portraitTexture 
)

Updates the actor portrait texture for any cached character info.

Parameters
actorNameActor name.
portraitTexturePortrait texture.

◆ UpdateResponses()

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

Updates the responses in the specified state.

Parameters
stateState to check.

Property Documentation

◆ ActorInfo

CharacterInfo PixelCrushers.DialogueSystem.ConversationModel.ActorInfo
get

Gets the actor info for this conversation.

The actor info.

◆ ConversantInfo

CharacterInfo PixelCrushers.DialogueSystem.ConversationModel.ConversantInfo
get

Gets the conversant info for this conversation.

The conversant info.

◆ 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.

◆ IsDialogueEntryValid

IsDialogueEntryValidDelegate PixelCrushers.DialogueSystem.ConversationModel.IsDialogueEntryValid
getset

Gets or sets the IsDialogueEntryValid delegate.


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