NPCSchedule

Manages an individual NPC's daily routine, danger state, and appointment history.

Constructor

new NPCSchedule(configopt)

Parameters:
NameTypeAttributesDefaultDescription
configObject<optional>
{}

Configuration options.

Properties
NameTypeAttributesDefaultDescription
idstring<optional>

Unique NPC identifier.

slotsArray<optional>
[]

Initial schedule slots.

defaultActivitystring<optional>
"idle"

Fallback activity when no slot matches.

initialHournumber | string<optional>
0

Initial game hour.

factionstring<optional>
"neutral"

NPC faction affiliation.

systemScheduleSystem<optional>
null

Reference to parent ScheduleSystem.

entityEntity<optional>
null

Neptune Entity this component attaches to.

Classes

NPCSchedule

Members

isInDanger

Whether NPC is currently in danger.

isSuspended

Whether schedule execution is currently suspended due to danger.

Methods

addSlot(slot) → {ScheduleSlot}

Adds a schedule slot to this NPC's routine.

Parameters:
NameTypeDescription
slotScheduleSlot | Object

Slot instance or config object.

Returns:

The added slot.

Type: 
ScheduleSlot

getSlotForHour(hour) → {ScheduleSlot|null}

Finds the matching slot for a given hour based on priority and time interval.

Parameters:
NameTypeDescription
hournumber | string

Game hour.

Returns:

Matching slot or null.

Type: 
ScheduleSlot | null

removeSlot(slotId) → {boolean}

Removes a slot by its identifier.

Parameters:
NameTypeDescription
slotIdstring

Identifier of slot to remove.

Returns:

True if removed.

Type: 
boolean

resolveDanger(optionsopt) → {string}

Resolves the danger condition and resumes scheduled activity. Evaluates current hour and seamlessly picks up the appropriate schedule slot.

Parameters:
NameTypeAttributesDefaultDescription
optionsObject<optional>
{}

Resumption options.

Returns:

Resumed activity.

Type: 
string

triggerDanger(dangerDataopt) → {NPCSchedule}

Suspends normal schedule execution in reaction to perceived danger.

Parameters:
NameTypeAttributesDefaultDescription
dangerDataObject<optional>
{}

Details of the perceived threat.

Returns:

This instance.

Type: 
NPCSchedule

update(time) → {string}

Updates the NPC schedule to the given hour. Handles slot transitions, danger suspension, and destination fallback.

Parameters:
NameTypeDescription
timenumber | string | Object

Current game hour or clock.

Returns:

Current activity.

Type: 
string