Table of Contents

Class CustomEffectBuilder

Namespace
S1API.Properties
Assembly
S1API.dll

Builder for composing a custom effect (drug property) at runtime. Configure the effect with fluent methods, then call Build() to register it.

public sealed class CustomEffectBuilder
Inheritance
CustomEffectBuilder
Inherited Members
Extension Methods

Remarks

A custom effect is a real game effect that can be imprinted onto products by a mixing ingredient. Its display metadata, value contribution, and mixing geometry are configurable. Optional behavior runs through the same effect-callback path S1API already uses for overriding vanilla effects.

Constructors

CustomEffectBuilder()

public CustomEffectBuilder()

Methods

Build()

Builds and registers the custom effect and returns a token usable anywhere a property is accepted.

public CustomEffect Build()

Returns

CustomEffect

A CustomEffect token for the created effect.

Exceptions

InvalidOperationException

Thrown if no ID was set.

ForDrugs(params DrugType[])

Restricts which drugs this effect participates in mixing for. Defaults to all mixable drugs.

public CustomEffectBuilder ForDrugs(params DrugType[] drugs)

Parameters

drugs DrugType[]

The drug types to register the effect for.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithAddictiveness(float)

Sets how addictive this effect makes a product (0 to 1).

public CustomEffectBuilder WithAddictiveness(float addictiveness)

Parameters

addictiveness float

Addictiveness from 0 to 1.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithBasicInfo(string, string, string)

Sets the effect's identity and display text.

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

Parameters

id string

Unique effect ID (e.g. "mymod_glow"). Must be unique across all effects.

name string

Display name shown on products.

description string

Description shown in tooltips.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithBehavior(Action<Player>)

Sets the behavior run when this effect is applied to the local player.

public CustomEffectBuilder WithBehavior(Action<Player> onApply)

Parameters

onApply Action<Player>

Callback invoked with the local player when the effect triggers.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithColors(Color, Color)

Sets the colors used for this effect on the product and its label.

public CustomEffectBuilder WithColors(Color productColor, Color labelColor)

Parameters

productColor Color

The color tint applied to the product.

labelColor Color

The color used for the effect label.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithMixGeometry(Vector2, float)

Sets the mixing geometry used when this effect is the one being mixed into a product.

public CustomEffectBuilder WithMixGeometry(Vector2 direction, float magnitude)

Parameters

direction Vector2

Direction on the mixing plane.

magnitude float

Magnitude of the mixing vector.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithMixMapPlacement(Vector2, float)

Overrides where this effect sits on each drug's mixing map. By default the effect is placed off to the side so it does not capture other mixes; set this to design deliberate reactions.

public CustomEffectBuilder WithMixMapPlacement(Vector2 position, float radius)

Parameters

position Vector2

Position on the mixing plane.

radius float

Radius of the effect's region.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithNpcBehavior(Action<NPC>)

Sets the behavior run when this effect is applied to an NPC.

public CustomEffectBuilder WithNpcBehavior(Action<NPC> onApply)

Parameters

onApply Action<NPC>

Callback invoked with the NPC when the effect triggers.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithTier(int)

Sets the effect tier (1-5), which affects its ordering and value contribution.

public CustomEffectBuilder WithTier(int tier)

Parameters

tier int

Tier from 1 to 5.

Returns

CustomEffectBuilder

The builder instance for fluent chaining.

WithValue(int, float, float)

Sets how this effect changes a product's value.

public CustomEffectBuilder WithValue(int valueChange, float valueMultiplier = 1, float addBaseValueMultiple = 0)

Parameters

valueChange int

Flat value added (-100 to 100).

valueMultiplier float

Multiplier applied to the product value (0 to 2).

addBaseValueMultiple float

Fraction of the base value added (-1 to 1).

Returns

CustomEffectBuilder

The builder instance for fluent chaining.