Table of Contents

Class StayInBuildingSpec

Namespace
S1API.Entities.Schedule
Assembly
S1API.dll

Specifies an action that makes an NPC remain inside a building for a specified duration.

public sealed class StayInBuildingSpec : IScheduleActionSpec
Inheritance
StayInBuildingSpec
Implements
Inherited Members
Extension Methods

Remarks

This action creates a ScheduleOne.NPCs.Schedules.NPCEvent_StayInBuilding that will keep the NPC inside the specified building for the given duration. The building can be identified by name-based lookup.

Constructors

StayInBuildingSpec()

public StayInBuildingSpec()

Properties

BuildingGUID

Gets or sets the GUID of the building where the NPC should stay.

public string BuildingGUID { get; set; }

Property Value

string

The building GUID, or null if using name-based lookup.

Remarks

The building GUID is typically generated at runtime and may not be stable across game sessions. For modder-facing APIs prefer using name-based lookup via Building.GetByName(string) or typed identifiers via Building.Get<T>(). Use the GUID only if you have a reliable runtime reference to the exact game object.

BuildingName

Gets or sets the name of the building where the NPC should stay.

public string BuildingName { get; set; }

Property Value

string

The building name, or null if using GUID-based lookup.

Remarks

The building name takes precedence over BuildingGUID and is the recommended identifier for mod developers. It should match a building registered in the S1API building registry (see Building.GetByName(string) and Building.Get<T>()). Names are stable across game sessions and preferred for persistence and prefab configuration.

DoorIndex

Gets or sets the optional door index to use when entering the building.

public int? DoorIndex { get; set; }

Property Value

int?

The door index, or null to use the default entrance.

Remarks

Some buildings have multiple entrances. This specifies which door the NPC should use when entering the building. If not specified, the default entrance is used.

DurationMinutes

Gets or sets the duration for which the NPC should remain in the building.

public int DurationMinutes { get; set; }

Property Value

int

The duration in minutes. Default is 60 minutes.

Remarks

The NPC will stay in the building for this duration starting from the start time. Must be at least 1 minute.

Name

Gets or sets the optional name for this action.

public string Name { get; set; }

Property Value

string

The action name, or null to use the default name "StayInBuilding".

StartTime

Gets or sets the time when this action should start, in minutes from midnight.

public int StartTime { get; set; }

Property Value

int

The start time in minutes (0-1439 for a 24-hour day).

Methods

ApplyTo(NPCSchedule)

Applies this action specification to the given NPC schedule.

public void ApplyTo(NPCSchedule schedule)

Parameters

schedule NPCSchedule

The NPC schedule to apply this action to.

Remarks

This method should create and configure the appropriate schedule action on the provided schedule instance. The implementation should handle any necessary object resolution, validation, and error handling.