Table of Contents

Class FurnitureDefinitionBuilder

Namespace
S1API.Items.Buildable
Assembly
S1API.dll

Composes a custom model into a native furniture definition, placement prefab, and inventory prefab.

public sealed class FurnitureDefinitionBuilder
Inheritance
FurnitureDefinitionBuilder
Inherited Members
Extension Methods

Methods

Build()

Creates and registers the complete native buildable definition. Call this after the game's item registry and vanilla furniture definitions are available. Every multiplayer peer must perform the same registration.

public BuildableItemDefinition Build()

Returns

BuildableItemDefinition

The registered custom furniture definition.

Exceptions

InvalidOperationException

Thrown when required identity or model configuration is missing, or a native donor is unavailable.

ConfigureModel(Action<GameObject>)

Configures the isolated visual owned by a builder returned from CloneFrom(string). Renderer materials are independent from the donor before this callback runs.

public FurnitureDefinitionBuilder ConfigureModel(Action<GameObject> configure)

Parameters

configure Action<GameObject>

A callback that modifies the builder-owned visual clone.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentNullException

Thrown when configure is null.

InvalidOperationException

Thrown when this builder was not created by CloneFrom, or the model was already configured.

WithBasicInfo(string, string, string)

Sets the stable registry ID and player-facing text.

public FurnitureDefinitionBuilder WithBasicInfo(string id, string name, string description)

Parameters

id string

The stable item ID shared by every multiplayer peer.

name string

The player-facing item name.

description string

The player-facing item description. An empty description is allowed.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

WithBuildSound(BuildSoundType)

Sets the sound family used when placement completes.

public FurnitureDefinitionBuilder WithBuildSound(BuildSoundType buildSound)

Parameters

buildSound BuildSoundType

The public sound family. Plastic uses the native metal sound because the game has no plastic family.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentOutOfRangeException

Thrown for an undefined sound family.

WithFootprint(int, int)

Sets the floor-grid footprint in 0.5 metre tiles.

public FurnitureDefinitionBuilder WithFootprint(int width, int depth)

Parameters

width int

The positive footprint width in grid tiles.

depth int

The positive footprint depth in grid tiles.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentOutOfRangeException

Thrown when either dimension is less than one.

WithGeneratedIcon(int)

Queues inventory-icon generation from the supplied model. The definition registers immediately, and S1API replaces its fallback icon when the gameplay rendering rig becomes available.

public FurnitureDefinitionBuilder WithGeneratedIcon(int resolution = 512)

Parameters

resolution int

The square icon resolution from 64 through 2048 pixels.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentOutOfRangeException

Thrown when resolution is outside the supported range.

WithIcon(Sprite)

Uses an existing inventory icon.

public FurnitureDefinitionBuilder WithIcon(Sprite icon)

Parameters

icon Sprite

The icon to assign without using the native render rig.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentNullException

Thrown when icon is null.

WithModel(GameObject)

Sets the model used for the placed object, placement ghost, stored item, and generated icon. The supplied object is cloned and is never modified by S1API.

public FurnitureDefinitionBuilder WithModel(GameObject model)

Parameters

model GameObject

The model root to clone. It must contain at least one mesh renderer.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentNullException

Thrown when model is null.

WithPlacement(FurniturePlacementMode)

Chooses the native placement family.

public FurnitureDefinitionBuilder WithPlacement(FurniturePlacementMode placementMode)

Parameters

placementMode FurniturePlacementMode

The grid or surface placement family to compose.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentOutOfRangeException

Thrown for an undefined placement mode.

WithPricing(float, float)

Sets the purchase and resale values.

public FurnitureDefinitionBuilder WithPricing(float basePurchasePrice, float resellMultiplier = 0.5)

Parameters

basePurchasePrice float

The non-negative base purchase price.

resellMultiplier float

The resale fraction, clamped between zero and one.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

WithStackLimit(int)

Sets the inventory stack limit.

public FurnitureDefinitionBuilder WithStackLimit(int stackLimit)

Parameters

stackLimit int

The stack limit, clamped between 1 and 999.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

WithSurfacePlacement(FurnitureSurfaceType, bool)

Configures valid surfaces and rotation for surface-placed furniture.

public FurnitureDefinitionBuilder WithSurfacePlacement(FurnitureSurfaceType surfaceTypes, bool allowRotation = true)

Parameters

surfaceTypes FurnitureSurfaceType

One or more supported wall or roof surface flags.

allowRotation bool

Whether the player can rotate the item during surface placement.

Returns

FurnitureDefinitionBuilder

This builder for fluent chaining.

Exceptions

ArgumentOutOfRangeException

Thrown when surfaceTypes is empty or contains an unknown flag.