Table of Contents

Class PrefabScheduleBuilder

Namespace
S1API.Entities.Schedule
Assembly
S1API.dll

Plan-time schedule builder used during prefab composition. Collects IScheduleActionSpec entries without requiring a live NPC instance.

public sealed class PrefabScheduleBuilder
Inheritance
PrefabScheduleBuilder
Inherited Members
Extension Methods

Remarks

IMPORTANT: Avoid scheduling multiple actions at start time 0 (midnight). The game's action sorting comparator has a bug that can cause inconsistent sort results when multiple non-signal actions share the same start time. This issue is most commonly encountered at time 0 when using EnsureDealSignal() which creates a signal at time 0.

To avoid this issue, schedule your first action at time 1 or later (e.g., 10 minutes = 0:10 AM).

Constructors

PrefabScheduleBuilder()

public PrefabScheduleBuilder()

Methods

Add(IScheduleActionSpec)

Adds a custom schedule action using an S1API action specification.

public PrefabScheduleBuilder Add(IScheduleActionSpec spec)

Parameters

spec IScheduleActionSpec

The action specification to add to the prefab schedule.

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method allows adding custom schedule actions using the IScheduleActionSpec interface. The specification will be stored and applied when the prefab is configured.

If the specification is null, this method does nothing and returns the builder unchanged.

DriveToCarPark(ParkingLotWrapper, LandVehicle, int, ParkingAlignment?, bool?, string)

Adds a "Drive to Car Park" action that makes the NPC drive a vehicle to a parking lot using wrapper objects.

public PrefabScheduleBuilder DriveToCarPark(ParkingLotWrapper lot, LandVehicle vehicle, int startTime, ParkingAlignment? alignment = null, bool? overrideParkingType = null, string name = null)

Parameters

lot ParkingLotWrapper

The parking lot wrapper where the vehicle should be parked.

vehicle LandVehicle

The vehicle wrapper that should be driven to the parking lot.

startTime int

The time when this action should start, in minutes from midnight (0-1439).

alignment ParkingAlignment?

The optional parking alignment to use when parking the vehicle.

overrideParkingType bool?

Whether to override the default parking type behavior.

name string

The optional name for this action. If null, uses "DriveToCarPark".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a DriveToCarParkSpec that will be applied when the prefab is configured. The specification will create a ScheduleOne.NPCs.Schedules.NPCSignal_DriveToCarPark action that makes the NPC drive the specified vehicle to the designated parking lot and park it.

DriveToCarPark(string, string, int, ParkingAlignment?, bool?, string)

Adds a "Drive to Car Park" action that makes the NPC drive a vehicle to a parking lot using GUIDs.

public PrefabScheduleBuilder DriveToCarPark(string parkingLotGUID, string vehicleGUID, int startTime, ParkingAlignment? alignment = null, bool? overrideParkingType = null, string name = null)

Parameters

parkingLotGUID string

The GUID of the parking lot where the vehicle should be parked.

vehicleGUID string

The GUID of the vehicle that should be driven to the parking lot.

startTime int

The time when this action should start, in minutes from midnight (0-1439).

alignment ParkingAlignment?

The optional parking alignment to use when parking the vehicle.

overrideParkingType bool?

Whether to override the default parking type behavior.

name string

The optional name for this action. If null, uses "DriveToCarPark".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a DriveToCarParkSpec that will be applied when the prefab is configured. The specification will create a ScheduleOne.NPCs.Schedules.NPCSignal_DriveToCarPark action that makes the NPC drive the specified vehicle to the designated parking lot and park it. The GUIDs will be resolved to their corresponding objects at runtime.

DriveToCarParkByName(string, string, int, ParkingAlignment?, bool?, string)

Adds a "Drive to Car Park" action using GameObject names for runtime resolution. More reliable than GUIDs for modders as names are more predictable across different players.

public PrefabScheduleBuilder DriveToCarParkByName(string parkingLotName, string vehicleName, int startTime, ParkingAlignment? alignment = null, bool? overrideParkingType = null, string name = null)

Parameters

parkingLotName string

The GameObject name of the parking lot where the vehicle should be parked.

vehicleName string

The GameObject name of the vehicle that should be driven.

startTime int

The time when this action should start, in minutes from midnight (0-1439).

alignment ParkingAlignment?

The optional parking alignment to use when parking the vehicle.

overrideParkingType bool?

Whether to override the default parking type behavior.

name string

The optional name for this action. If null, uses "DriveToCarPark".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a DriveToCarParkSpec that uses name-based resolution. The parking lot and vehicle will be found by GameObject name at runtime, which is more reliable than GUID-based lookup for mods that need to work across different players.

DriveToCarParkWithCreateVehicle(string, string, int, Vector3, Quaternion?, ParkingAlignment?, bool?, string)

Adds a "Drive to Car Park" action that creates a vehicle using a vehicle code. Useful when you don't have an existing vehicle to reference.

public PrefabScheduleBuilder DriveToCarParkWithCreateVehicle(string parkingLotName, string vehicleCode, int startTime, Vector3 vehicleSpawnPosition, Quaternion? vehicleSpawnRotation = null, ParkingAlignment? alignment = null, bool? overrideParkingType = null, string name = null)

Parameters

parkingLotName string

The GameObject name of the parking lot where the vehicle should be parked.

vehicleCode string

The vehicle code to create (e.g., "Sedan", "SUV", etc.).

startTime int

The time when this action should start, in minutes from midnight (0-1439).

vehicleSpawnPosition Vector3

The world position where the vehicle should spawn.

vehicleSpawnRotation Quaternion?

The optional rotation for the vehicle spawn. If not specified, uses identity rotation.

alignment ParkingAlignment?

The optional parking alignment to use when parking the vehicle.

overrideParkingType bool?

Whether to override the default parking type behavior.

name string

The optional name for this action. If null, uses "DriveToCarPark".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a DriveToCarParkSpec that will create a new vehicle instance at runtime using the provided vehicle code. This is useful when you don't have an existing vehicle to reference but need the NPC to drive somewhere.

The vehicle will be spawned at the specified vehicleSpawnPosition and rotation when the schedule action executes.

EnsureDealSignal()

Ensures that a customer deal signal exists under the schedule for handling deal interactions.

public PrefabScheduleBuilder EnsureDealSignal()

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates an EnsureDealSignalSpec that will be applied when the prefab is configured. The specification ensures that a ScheduleOne.NPCs.Schedules.NPCSignal_WaitForDelivery component exists on the NPC's schedule manager for proper customer deal handling.

HandleDeal(int, string)

Adds a handle-deal action for dealer-type NPCs.

[Obsolete("HandleDeal is no longer needed as of game version 0.4.2f4. Deal handling is now automatic through DealerAttendDealBehaviour.")]
public PrefabScheduleBuilder HandleDeal(int startTime, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

name string

Optional custom name for this action; defaults to "HandleDeal".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

As of v0.4.2f4, deal handling is now automatic through the DealerAttendDealBehaviour system. This method is kept for backwards compatibility but is a no-op. Dealer NPCs set up with EnsureDealer() will automatically handle deals when contracts are assigned.

LocationBased(Vector3, int, int)

Starts building a location-based action that moves to a destination, then triggers a typed arrive behavior.

public LocationBasedActionSpecBuilder LocationBased(Vector3 destination, int startTime, int durationMinutes = 60)

Parameters

destination Vector3

The world position where the NPC should walk to.

startTime int

The time when this action should start, in minutes from midnight (0-1439).

durationMinutes int

The duration for this action in minutes. Default is 60.

Returns

LocationBasedActionSpecBuilder

A fluent sub-builder used to configure and finalize the action.

Remarks

Use the returned LocationBasedActionSpecBuilder to configure optional values such as destination threshold and warp behavior, then call a terminal method like OnArriveSmokeBreak() to finalize and add the spec.

LocationDialogue(Vector3, int, bool, float, bool, int, int, string)

Adds a location-dialogue action that moves to a destination and enables dialogue.

public PrefabScheduleBuilder LocationDialogue(Vector3 destination, int startTime, bool faceDestinationDir = true, float within = 1, bool warpIfSkipped = false, int greetingOverrideToEnable = -1, int choiceToEnable = -1, string name = null)

Parameters

destination Vector3

The world position where the NPC should walk to.

startTime int

The time when this action should start, in minutes from midnight (0-1439).

faceDestinationDir bool

Whether the NPC should face the destination direction when walking. Default is true.

within float

The distance threshold (in world units) within which the NPC is considered to have arrived. Default is 1.0f.

warpIfSkipped bool

Whether to warp the NPC to the destination if the action is skipped. Default is false.

greetingOverrideToEnable int

Greeting override index to enable upon arrival; use -1 to disable. Default is -1.

choiceToEnable int

Choice index to enable upon arrival; use -1 to disable. Default is -1.

name string

Optional custom name for this action; defaults to "LocationDialogue".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

Creates a LocationDialogueSpec that, when applied, configures a ScheduleOne.NPCs.Schedules.NPCEvent_LocationDialogue. The NPC walks to the destination and then sets dialogue-related overrides for player interaction.

SitAtSeatSet(string, int, int, bool, string, string)

Adds a seating action that moves the NPC to an available seat within the specified seat set.

public PrefabScheduleBuilder SitAtSeatSet(string seatSetName, int startTime, int durationMinutes = 60, bool warpIfSkipped = false, string name = null, string seatSetPath = null)

Parameters

seatSetName string

The GameObject name of the AvatarSeatSet to use. Can be null if seatSetPath is provided.

startTime int

The time when this action should start, in 24-hour HHMM format (e.g. 830 for 8:30 AM, 1400 for 2:00 PM).

durationMinutes int

Duration of the sit action in minutes. Defaults to 60. Must be positive for the action to trigger.

warpIfSkipped bool

Whether the NPC should be warped to the seat if the action is skipped. Default is false.

name string

Optional custom name for this action; defaults to "Sit".

seatSetPath string

Optional full hierarchy path to the seat set GameObject (e.g. "Map/Hyland Point/Region_Docks/WaterFront/OutdoorBench (1)"). Use this when multiple seat sets share the same name to target a specific one.

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a SitSpec that resolves a seat set by name, path, or both. When multiple seat sets share the same name (e.g. "outdoorbench"), use seatSetPath to target a specific one. The path is matched case-insensitively against the full transform hierarchy.

Example — by name:

plan.SitAtSeatSet("Fast Food Booth", 900, durationMinutes: 60)

Example — by path (when name is ambiguous):

plan.SitAtSeatSet(null, 1650, durationMinutes: 130, seatSetPath: "Map/Hyland Point/Region_Docks/WaterFront/OutdoorBench (1)")

If the seat set cannot be resolved at runtime, the action is disabled and a warning is logged. This prevents a NullReferenceException that would permanently break the NPC's schedule.

StayInBuilding(Building, int, int, int?, string)

Adds a "Stay in Building" action that makes the NPC remain inside a building for a specified duration.

public PrefabScheduleBuilder StayInBuilding(Building building, int startTime, int durationMinutes = 60, int? doorIndex = null, string name = null)

Parameters

building Building

The building wrapper where the NPC should stay.

startTime int

The time when this action should start, in minutes from midnight (0-1439). Avoid using 0 to prevent sort comparison issues.

durationMinutes int

The duration for which the NPC should remain in the building. Default is 60 minutes.

doorIndex int?

The optional door index to use when entering the building.

name string

The optional name for this action. If null, uses "StayInBuilding".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a StayInBuildingSpec that will be applied when the prefab is configured. The specification will create a ScheduleOne.NPCs.Schedules.NPCEvent_StayInBuilding action that keeps the NPC inside the specified building for the given duration.

If the building is null, this method does nothing and returns the builder unchanged.

UseATM(int, string, string)

Adds an ATM usage action at the specified time.

public PrefabScheduleBuilder UseATM(int startTime, string atmGUID = null, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

atmGUID string

Optional GUID of a specific ATM to use; if null, the ATM should be resolved by gameplay systems.

name string

Optional custom name for this action; defaults to "UseATM".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

Creates a UseATMSpec that, when applied, configures a ScheduleOne.NPCs.Schedules.NPCSignal_UseATM under the NPC's schedule manager.

UseSlotMachine(int, Vector3, int, GamblingSessionMode, float, string)

Adds a slot machine usage action at the specified time.

public PrefabScheduleBuilder UseSlotMachine(int startTime, Vector3 machinePosition, int betAmount = 10, GamblingSessionMode sessionMode = GamblingSessionMode.SingleSpin, float maxSearchDistance = 5, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

machinePosition Vector3

The world position of the slot machine to use.

betAmount int

The amount to bet in dollars (default: 10).

sessionMode GamblingSessionMode

The gambling session mode (default: single spin).

maxSearchDistance float

Maximum distance to search for a slot machine from the position (default: 5.0).

name string

Optional custom name for this action; defaults to "UseSlotMachine".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

Creates a UseSlotMachineSpec that makes the NPC walk to the slot machine location and play it according to the session mode. The NPC must have sufficient cash in their inventory to place bets.

UseSlotMachineMultipleTimes(int, Vector3, int, int, float, float, string)

Adds a slot machine usage action that plays multiple spins.

public PrefabScheduleBuilder UseSlotMachineMultipleTimes(int startTime, Vector3 machinePosition, int spinCount, int betAmount = 10, float timeBetweenSpins = 10, float maxSearchDistance = 5, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

machinePosition Vector3

The world position of the slot machine to use.

spinCount int

The number of spins to play.

betAmount int

The amount to bet per spin in dollars (default: 10).

timeBetweenSpins float

Time to wait between spins in seconds (default: 10.0).

maxSearchDistance float

Maximum distance to search for a slot machine from the position (default: 5.0).

name string

Optional custom name for this action; defaults to "UseSlotMachine".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

The NPC will play the specified number of spins, waiting between each one. If the NPC runs out of cash before completing all spins, the session will end early.

UseSlotMachineUntilBroke(int, Vector3, int, float, float, string)

Adds a slot machine usage action that plays until the NPC runs out of cash.

public PrefabScheduleBuilder UseSlotMachineUntilBroke(int startTime, Vector3 machinePosition, int betAmount = 10, float timeBetweenSpins = 10, float maxSearchDistance = 5, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

machinePosition Vector3

The world position of the slot machine to use.

betAmount int

The amount to bet per spin in dollars (default: 10).

timeBetweenSpins float

Time to wait between spins in seconds (default: 10.0).

maxSearchDistance float

Maximum distance to search for a slot machine from the position (default: 5.0).

name string

Optional custom name for this action; defaults to "UseSlotMachine".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

The NPC will gamble continuously until they no longer have enough cash for another bet. This can result in the NPC gambling away all their money, so ensure they have a reasonable amount of cash or use time-based limits instead.

UseSlotMachineUntilTime(int, int, Vector3, int, float, bool, float, Building, string)

Adds a slot machine usage action that plays until a specific time.

public PrefabScheduleBuilder UseSlotMachineUntilTime(int startTime, int endTime, Vector3 machinePosition, int betAmount = 10, float timeBetweenSpins = 10, bool stopIfBroke = true, float maxSearchDistance = 5, Building building = null, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

endTime int

The time when gambling should stop, in minutes from midnight (0-1439).

machinePosition Vector3

The world position of the slot machine to use.

betAmount int

The amount to bet per spin in dollars (default: 10).

timeBetweenSpins float

Time to wait between spins in seconds (default: 10.0).

stopIfBroke bool

If true, stops gambling when out of cash; if false, only stops at end time (default: true).

maxSearchDistance float

Maximum distance to search for a slot machine from the position (default: 5.0).

building Building
name string

Optional custom name for this action; defaults to "UseSlotMachine".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

The NPC will gamble continuously until the end time is reached. If stopIfBroke is true, the session will also end if the NPC runs out of cash.

UseVendingMachine(int, string, string)

Adds a vending machine usage action at the specified time.

public PrefabScheduleBuilder UseVendingMachine(int startTime, string machineGUID = null, string name = null)

Parameters

startTime int

The time when this action should start, in minutes from midnight (0-1439).

machineGUID string

Optional GUID of a specific vending machine to use; if null, the nearest reachable machine will be used.

name string

Optional custom name for this action; defaults to "UseVending".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

Creates a UseVendingMachineSpec that, when applied, configures a ScheduleOne.NPCs.Schedules.NPCSignal_UseVendingMachine under the NPC's schedule manager.

WalkTo(Vector3, int, bool, float, bool, Vector3?, string)

Adds a walk-to action that moves the NPC to a specific world position at the given start time.

public PrefabScheduleBuilder WalkTo(Vector3 destination, int startTime, bool faceDestinationDir = true, float within = 1, bool warpIfSkipped = false, Vector3? forward = null, string name = null)

Parameters

destination Vector3

The world position where the NPC should walk to.

startTime int

The time when this action should start, in minutes from midnight (0-1439). Avoid using 0 to prevent sort comparison issues.

faceDestinationDir bool

Whether the NPC should face the destination direction when walking. Default is true.

within float

The distance threshold within which the NPC is considered to have arrived. Default is 1.0f.

warpIfSkipped bool

Whether the NPC should be warped to the destination if the action is skipped. Default is false.

forward Vector3?

The optional forward direction vector for the destination marker. If null, the direction will be calculated from the NPC's position to the destination.

name string

The optional name for this action. If null, uses "WalkTo".

Returns

PrefabScheduleBuilder

This builder instance for method chaining.

Remarks

This method creates a WalkToSpec that will be applied when the prefab is configured. The specification is stored and will create a ScheduleOne.NPCs.Schedules.NPCSignal_WalkToLocation action when applied to the actual NPC schedule.

If forward is specified, it will be used to orient the destination marker. Otherwise, the direction will be automatically calculated from the NPC's current position to the destination.