Class NPCSchedule
Modder-facing scheduling wrapper for an NPC. Exposes the underlying schedule manager to enable, disable, and manage scheduled actions and curfew modes. Schedule configuration must be done in ConfigurePrefab(NPCPrefabBuilder).
public sealed class NPCSchedule
- Inheritance
-
NPCSchedule
- Inherited Members
- Extension Methods
Remarks
Use this to control NPC movement patterns, building visits, and timed activities. Schedules are defined in ConfigurePrefab(NPCPrefabBuilder) using WithSchedule(Action<PrefabScheduleBuilder>) and managed at runtime via this wrapper.
Properties
CurfewModeEnabled
Whether the schedule is currently in curfew mode.
public bool CurfewModeEnabled { get; }
Property Value
IsEnabled
Whether the schedule is currently enabled.
public bool IsEnabled { get; }
Property Value
Methods
ClearActions(bool, bool)
Removes all actions under the schedule manager with optional filtering by action type.
public void ClearActions(bool includeSignals = true, bool includeEvents = true)
Parameters
includeSignalsboolWhether to remove signal-type actions (e.g., WalkTo, DriveToCarPark). Default is
true.includeEventsboolWhether to remove event-type actions (e.g., StayInBuilding, LocationDialogue). Default is
true.
Remarks
This method removes all schedule actions from the NPC's schedule manager. Actions are disabled and reset instead of being destroyed to maintain FishNet network component indices and avoid network synchronization issues.
After clearing actions, the schedule manager is re-initialized to update the action order and timing.
Use with caution as this will completely reset the NPC's scheduled behavior.
Disable()
Disables the NPC's schedule.
public void Disable()
Enable()
Enables the NPC's schedule.
public void Enable()
EnforceState()
Forces the manager to enforce state immediately (e.g., after toggles or time jumps).
public void EnforceState()
EnsureDealSignal()
Ensures that a deal-wait signal exists under the schedule manager for customer handover functionality.
public void EnsureDealSignal()
Remarks
This method ensures that a ScheduleOne.NPCs.Schedules.NPCSignal_WaitForDelivery component exists on the NPC's schedule manager. This signal is required for customer NPCs to properly handle deal interactions and handovers with the player.
If the signal already exists, it will be properly initialized and wired to the customer component. If it doesn't exist, a warning will be logged indicating that it should be added via ConfigurePrefab(NPCPrefabBuilder).
The deal signal allows the NPC to wait for deliveries and toggle customer handover states.
GetActionNames()
Returns the names of all currently configured actions, including inactive and disabled ones.
public IReadOnlyList<string> GetActionNames()
Returns
- IReadOnlyList<string>
A read-only list of action names. Returns an empty list if no schedule manager exists.
Remarks
This method retrieves the names of all schedule actions currently configured on the NPC, regardless of their active state. This can be useful for debugging or monitoring the NPC's schedule configuration.
The returned list includes both signal-type and event-type actions.
GetActiveActionName()
Returns the active action label, if any.
public string GetActiveActionName()
Returns
SetCurfewMode(bool)
Sets or clears curfew mode.
public void SetCurfewMode(bool enabled)
Parameters
enabledbool