Raymond Maarloeve
Loading...
Searching...
No Matches
NPC Class Reference

Represents a Non-Player Character (NPC) in the game world. Handles decision making, vision, memory, and interaction logic for the NPC. More...

Public Member Functions

void Awake ()
 Initializes the NPC, sets up the entity ID, animator, and subscribes to the NPC event bus.
 
void Setup (IDecisionSystem decisionSystem, string modelId, CharacterDTO characterDTO)
 Sets up the NPC's decision system, model, name, and system prompt. Initializes default memories.
 
IDecisionSystem GetDecisionSystem ()
 Gets the decision system used by the NPC.
 
void LookAt (Transform targetTransform)
 Makes the NPC look at a specified target transform. Updates the NPC's rotation to face the target. If the target is null, resets the rotation to the previous value. Logs the action for debugging purposes.
 
List< CurrentEnvironmentGetCurrentEnvironment ()
 Returns a list of possible environment descriptions for the NPC.
 
void OnDestroy ()
 Unsubscribes from the NPC event bus when the NPC is destroyed.
 
void StartChatting (IChattable otherChatter)
 Called when Player starts interacting with NPC, see PlayerController::StartInteraction NPC will look at Player and StoppedDecision will be set to CurrentDecision
 
void Chat (string message)
 Chat function implementation for .
 
void FinishChatting ()
 Chat finish function implementation for .
 
void InterruptDecision (IDecision decision)
 Sets and starts new decision.
 
void SetCurrentDecision (IDecision decision)
 Finishes current decision and starts up new one.
 
void StartChatting (IChattable otherChatter)
 
void FinishChatting ()
 
void Chat (string message)
 

Public Attributes

IDecision StoppedDecision
 Interrupted Decision, see OnInteraction
 
NavMeshAgent agent
 The NavMeshAgent component for navigation.
 
GameObject HisBuilding = null
 The building associated with this NPC.
 
float Hunger = 0f
 The hunger level of the NPC.
 
float Thirst = 0f
 The thirst level of the NPC.
 
float speed = 3f
 The movement speed of the NPC.
 
bool DecisionEmojiVisibility = false
 

Properties

IDecision CurrentDecision [get]
 The current decision being executed by the NPC.
 
CharacterDTO CharacterData [get]
 The Character data generated by Narrator.
 
string SystemPrompt = null [get, set]
 The system prompt used for LLM-based decision making.
 
string ModelID = null [get]
 The model ID used for LLM-based decision making.
 
string Name = null [get]
 The name of the NPC.
 
List< ObtainedMemoryObtainedMemories = new() [get]
 The list of memories obtained by the NPC.
 
int EntityID [get]
 The unique entity ID of the NPC.
 
bool AvailableToChat [get]
 Whether the NPC is available to chat with other chatters, see .
 
Transform LookTarget [get]
 The look target for .
 
- Properties inherited from IChattable
Transform LookTarget [get]
 
string Name [get]
 
bool AvailableToChat [get]
 

Detailed Description

Represents a Non-Player Character (NPC) in the game world. Handles decision making, vision, memory, and interaction logic for the NPC.

Member Function Documentation

◆ Awake()

void NPC.Awake ( )

Initializes the NPC, sets up the entity ID, animator, and subscribes to the NPC event bus.

◆ Chat()

void NPC.Chat ( string  message)

Chat function implementation for .

Implements IChattable.

◆ FinishChatting()

void NPC.FinishChatting ( )

Chat finish function implementation for .

Implements IChattable.

◆ GetCurrentEnvironment()

List< CurrentEnvironment > NPC.GetCurrentEnvironment ( )

Returns a list of possible environment descriptions for the NPC.

Returns
List of CurrentEnvironment objects describing the environment.

◆ GetDecisionSystem()

IDecisionSystem NPC.GetDecisionSystem ( )

Gets the decision system used by the NPC.

Returns
The decision system.

◆ InterruptDecision()

void NPC.InterruptDecision ( IDecision  decision)

◆ LookAt()

void NPC.LookAt ( Transform  targetTransform)

Makes the NPC look at a specified target transform. Updates the NPC's rotation to face the target. If the target is null, resets the rotation to the previous value. Logs the action for debugging purposes.

Parameters
targetTransformThe transform of the target to look at. If null, the NPC resets its rotation.

◆ OnDestroy()

void NPC.OnDestroy ( )

Unsubscribes from the NPC event bus when the NPC is destroyed.

◆ SetCurrentDecision()

void NPC.SetCurrentDecision ( IDecision  decision)

Finishes current decision and starts up new one.

◆ Setup()

void NPC.Setup ( IDecisionSystem  decisionSystem,
string  modelId,
CharacterDTO  characterDTO 
)

Sets up the NPC's decision system, model, name, and system prompt. Initializes default memories.

Parameters
decisionSystemThe decision system to use.
modelIdThe model ID for LLM-based decision making.
characterDTOCharacter data

◆ StartChatting()

void NPC.StartChatting ( IChattable  otherChatter)

Called when Player starts interacting with NPC, see PlayerController::StartInteraction NPC will look at Player and StoppedDecision will be set to CurrentDecision

Implements IChattable.

Member Data Documentation

◆ agent

NavMeshAgent NPC.agent

The NavMeshAgent component for navigation.

◆ DecisionEmojiVisibility

bool NPC.DecisionEmojiVisibility = false

◆ HisBuilding

GameObject NPC.HisBuilding = null

The building associated with this NPC.

◆ Hunger

float NPC.Hunger = 0f

The hunger level of the NPC.

◆ speed

float NPC.speed = 3f

The movement speed of the NPC.

◆ StoppedDecision

IDecision NPC.StoppedDecision

Interrupted Decision, see OnInteraction

◆ Thirst

float NPC.Thirst = 0f

The thirst level of the NPC.

Property Documentation

◆ AvailableToChat

bool NPC.AvailableToChat
get

Whether the NPC is available to chat with other chatters, see .

Implements IChattable.

◆ CharacterData

CharacterDTO NPC.CharacterData
get

The Character data generated by Narrator.

◆ CurrentDecision

IDecision NPC.CurrentDecision
get

The current decision being executed by the NPC.

◆ EntityID

int NPC.EntityID
get

The unique entity ID of the NPC.

◆ LookTarget

Transform NPC.LookTarget
get

The look target for .

Implements IChattable.

◆ ModelID

string NPC.ModelID = null
get

The model ID used for LLM-based decision making.

◆ Name

string NPC.Name = null
get

The name of the NPC.

Implements IChattable.

◆ ObtainedMemories

List<ObtainedMemory> NPC.ObtainedMemories = new()
get

The list of memories obtained by the NPC.

◆ SystemPrompt

string NPC.SystemPrompt = null
getset

The system prompt used for LLM-based decision making.


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