Crafting / Core / Context¶
Purpose¶
This folder defines the data context passed through the crafting pipeline.
Types in Context describe what a craft is and how it may be adjusted,
without knowing when or why those adjustments are applied.
These types are deliberately small, explicit, and side-effect free. They exist to make modifier and validator logic predictable and testable.
What lives here¶
CraftContext¶
CraftContext is an immutable snapshot describing a single craft decision.
It includes:
- the owning GameObject
- the RecipeCore being crafted
- the resolved default container name
- the station / bench tag (if any)
This context is passed to:
- ICraftingModifier.Apply
- ICraftingValidator.Validate
- output routing logic
CraftContext must be treated as read-only.
It is safe to inspect but never mutate.
CraftAdjustments¶
CraftAdjustments is a mutable bundle used to modify craft behaviour.
It allows modifiers to influence:
- duration (durationSeconds)
- currency cost (currencyMultiplier)
- output count (outputMultiplier)
- extra guaranteed outputs
- chance-based outputs
The crafting service: - creates the initial adjustment values - invokes modifiers in a defined order - clamps final values defensively before use
Modifiers should assume: - adjustments start from sane defaults - values may be clamped after modification - adjustments may be recomputed at delivery time
What does NOT belong here¶
- Business logic
- Validation rules
- Inventory or currency access
- Scheduling or timing decisions
- Persistence logic
This folder is data only. Behaviour belongs in the service or adapters.
Usage rules¶
For modifiers¶
- Read from
CraftContext - Mutate
CraftAdjustments - Do not:
- read or write inventory
- assume a specific execution time
- cache references to context data
Modifiers may be evaluated: - during preflight evaluation - at accept time - again at delivery time
They must be idempotent and side-effect free.
For validators¶
- Inspect
CraftContext - Inspect proposed
CraftCheck - Return a modified
CraftCheck - Never mutate context or global state
Validators must not: - consume inputs - debit currency - deliver outputs
They describe permission, not execution.
Public vs Internal¶
All types in this folder are part of the public, supported crafting API.
They are intentionally stable and safe to depend on from: - gameplay code - UI layers - Teachables - third-party extensions
Their structure and meaning are stable; the timing of when they are created or applied is owned by the crafting service.
Design notes¶
- Context types are small by design
- Mutability is explicit and limited
- No hidden coupling to adapters or systems
- Safe to pass through hostile consumers
If you need more information than CraftContext provides,
that data belongs in your own system — not here.