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
drugsDrugType[]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
addictivenessfloatAddictiveness 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
idstringUnique effect ID (e.g. "mymod_glow"). Must be unique across all effects.
namestringDisplay name shown on products.
descriptionstringDescription 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
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
productColorColorThe color tint applied to the product.
labelColorColorThe 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
directionVector2Direction on the mixing plane.
magnitudefloatMagnitude 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
positionVector2Position on the mixing plane.
radiusfloatRadius 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
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
tierintTier 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
valueChangeintFlat value added (-100 to 100).
valueMultiplierfloatMultiplier applied to the product value (0 to 2).
addBaseValueMultiplefloatFraction of the base value added (-1 to 1).
Returns
- CustomEffectBuilder
The builder instance for fluent chaining.