🎛️ Crafting — Modifiers¶
📦 Folder Overview¶
This folder contains runtime components that implement ICraftingModifier.
These components can be attached to GameObjects (typically the crafter or a parent) to influence crafting behaviour at runtime.
Modifiers operate on CraftAdjustments, not on recipe data.
🧩 What Lives Here¶
- Component-based implementations of
ICraftingModifier - Runtime behaviour adjustments applied during crafting evaluation
🎯 Purpose¶
Modifiers provide a way to adjust crafting behaviour at runtime, including:
- duration (
durationSeconds) - currency scaling (
currencyMultiplier) - output scaling (
outputMultiplier) - additional outputs (deterministic or chance-based)
They allow behaviour changes without modifying recipe data or core logic.
🧠 Usage Guidance¶
When Modifiers Run¶
When enabled on the service, modifiers are evaluated:
- during preflight evaluation
- during accept/enqueue
- again at delivery time
Modifiers may be invoked multiple times and should be idempotent.
Writing a Modifier¶
public interface ICraftingModifier
{
void Apply(ref CraftContext ctx, ref CraftAdjustments adj);
}
Example:
public sealed class DiscountModifier : MonoBehaviour, ICraftingModifier
{
[Range(0f, 1f)] public float discount = 0.5f;
public void Apply(ref CraftContext ctx, ref CraftAdjustments adj)
{
adj.currencyMultiplier *= Mathf.Clamp01(discount);
}
}
⚙️ Modifier Pipeline¶
Modifiers are applied in two layers:
Component Modifiers¶
- resolved from the owner and its parent hierarchy
- discovered using Unity component traversal
- evaluated in a service-defined order
Internal Hooks¶
The service may also apply internally registered modifier hooks.
These are not part of the public extension surface.
⚠️ Important Notes¶
- modifiers do not change recipe inputs
- currency is adjusted through multipliers only
- values are clamped by the service after modification
- behaviour depends on service configuration
🚫 Not for Production Use¶
This folder does not include:
- recipe mutation
- inventory or currency access
- scheduling or execution logic
🔗 Related Documentation¶
- Crafting Context (data passed to modifiers)
- Crafting Core (execution and evaluation flow)
🧱 Included Modifiers¶
AddChanceOutputModifier— probabilistic extra outputSimpleStationBonus— station-based duration and output adjustment
🧠 Design Notes¶
- modifiers operate on data, not systems
- designed for composability and reuse
- may be evaluated multiple times per craft
If additional behaviour is required, it should be implemented through modifiers or other supported extension seams.