Constructor
new ScheduleSystem(configopt)
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config | Object | <optional> | {} | System configuration. Properties
|
- Source
Classes
Methods
addSlot(slot, npcIdopt) → {ScheduleSlot}
Adds a schedule slot to the default or specified NPC routine.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
slot | Object | | Slot configuration. | ||
npcId | string | <optional> | "default" | Target NPC identifier. |
- Source
- Type:
- ScheduleSlot
advance(delta, unitopt) → {number}
Advances time by the given amount and updates all schedules.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
delta | number | Amount of time to advance. | ||
unit | string | <optional> | "hours" | "hours" or "minutes". |
- Source
New current hour.
- Type:
- number
clearMissedAppointments(npcIdopt)
Clears missed appointment history for an NPC.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
emit(event, data)
Emits a system event to registered listeners.
| Name | Type | Description |
|---|---|---|
event | string | Event name. |
data | Object | Payload data. |
- Source
getActivity(npcIdopt) → {string}
Gets the current activity of an NPC.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
- Type:
- string
getCurrentDestination(npcIdopt) → {Object|string|null}
Gets the current destination point for an NPC.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
- Type:
- Object |
string | null
getCurrentSlot(npcIdopt) → {ScheduleSlot|null}
Gets the active schedule slot for an NPC.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
- Type:
- ScheduleSlot |
null
getMissedAppointments(npcIdopt) → {Array}
Gets missed appointments recorded for an NPC.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
List of missed appointment records.
- Type:
- Array
getOccupant(point) → {string|null}
Gets the identifier of the NPC occupying a point.
| Name | Type | Description |
|---|---|---|
point | Object | | Activity point. |
- Source
Occupant NPC identifier or null.
- Type:
- string |
null
getSchedule(npcIdopt) → {NPCSchedule|null}
Gets the schedule instance for an NPC.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
- Type:
- NPCSchedule |
null
isInDanger(npcIdopt) → {boolean}
Alias for isSuspended.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
- Type:
- boolean
isPointOccupied(point, excludingNpcIdopt) → {boolean}
Checks if an activity point is currently occupied.
| Name | Type | Attributes | Description |
|---|---|---|---|
point | Object | | Activity point to check. | |
excludingNpcId | string | <optional> | Optional NPC identifier to ignore (e.g. self). |
- Source
True if occupied.
- Type:
- boolean
isSuspended(npcIdopt) → {boolean}
Checks whether an NPC schedule is currently suspended by danger.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
- Source
- Type:
- boolean
occupyPoint(point, npcId) → {boolean}
Claims an activity point for an NPC.
| Name | Type | Description |
|---|---|---|
point | Object | | Activity point to claim. |
npcId | string | Claiming NPC identifier. |
- Source
True if successfully claimed.
- Type:
- boolean
off(event, callback) → {ScheduleSystem}
Unsubscribes a listener from a system event.
| Name | Type | Description |
|---|---|---|
event | string | Event name. |
callback | function | Callback function. |
- Source
This instance.
- Type:
- ScheduleSystem
on(event, callback) → {ScheduleSystem}
Subscribes a listener to a system event.
| Name | Type | Description |
|---|---|---|
event | string | Event name. |
callback | function | Callback function. |
- Source
This instance.
- Type:
- ScheduleSystem
perceiveDanger(npcId, target, factionRegistry, dangerOverridesopt) → {boolean}
Evaluates a perceived target against a FactionRegistry and interrupts schedule if hostile.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | Observing NPC identifier. | ||
target | Object | Perceived target entity. | ||
factionRegistry | FactionRegistry | Faction registry to query. | ||
dangerOverrides | Object | <optional> | {} | Optional danger settings. |
- Source
True if hostile danger reaction was triggered.
- Type:
- boolean
registerNPC(npcId, config) → {NPCSchedule}
Registers an NPC routine with the schedule system.
| Name | Type | Description |
|---|---|---|
npcId | string | Unique identifier for the NPC. |
config | Object | | Schedule configuration or slots array. |
- Source
Registered schedule.
- Type:
- NPCSchedule
resolveDanger(npcIdopt, optionsopt) → {string}
Resolves danger reaction for an NPC, resuming normal schedule routine.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcId | string | <optional> | "default" | NPC identifier. |
options | Object | <optional> | {} | Options passed to resolveDanger. |
- Source
Resumed activity.
- Type:
- string
triggerDanger(npcIdOrDanger, maybeDangeropt) → {boolean}
Suspends an NPC's schedule with a danger reaction.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
npcIdOrDanger | string | | NPC identifier or danger data for default NPC. | ||
maybeDanger | Object | <optional> | {} | Danger configuration if npcId was provided. |
- Source
True if danger was triggered.
- Type:
- boolean
unregisterNPC(npcId) → {boolean}
Unregisters an NPC routine and frees its claimed points.
| Name | Type | Description |
|---|---|---|
npcId | string | NPC identifier. |
- Source
True if removed.
- Type:
- boolean
update(timeOrClockopt) → {number}
Updates time across all registered NPC schedules. Accepts a game hour float, time string, or GameClock instance.
| Name | Type | Attributes | Description |
|---|---|---|---|
timeOrClock | number | | <optional> | New time value or clock. |
- Source
Current hour after update.
- Type:
- number
vacateAllForNPC(npcId)
Vacates all activity points claimed by an NPC.
| Name | Type | Description |
|---|---|---|
npcId | string | NPC identifier. |
- Source
vacatePoint(point, npcIdopt) → {boolean}
Vacates a claimed activity point.
| Name | Type | Attributes | Description |
|---|---|---|---|
point | Object | | Point to vacate. | |
npcId | string | <optional> | Optional NPC identifier to ensure ownership. |
- Source
True if vacated.
- Type:
- boolean