Skip to content

🧠 Crafting — UnityIntegration / Caching

📦 Folder Overview

This page documents the runtime caching layer used by Crafting.

Caching is handled by CraftingOwnerComponentCache.


🧩 What Lives Here

  • cache for ICraftingModifier lookups
  • cache for ICraftingValidator lookups
  • per-frame reuse of collected component lists

🎯 Purpose

The caching layer reduces repeated component traversal when collecting modifiers and validators from an owner and its parent hierarchy.

It helps:

  • reduce allocations
  • minimise traversal cost
  • keep results consistent within a frame

🧠 Usage Guidance

Behaviour

  • caching is scoped per frame
  • results are reused within the same frame
  • cache is refreshed on the next frame

Changes to components or hierarchy are reflected on the next frame.


Access Patterns

  • GetValidators(GameObject owner)
  • GetModifiers(GameObject owner)

Both return cached results when available, otherwise collect and store them.


⚠️ Important Notes

  • caching does not modify crafting behaviour
  • results should not be retained outside the current frame
  • behaviour depends on Unity frame updates

🚫 Not for Production Use

This layer does not perform:

  • crafting logic
  • job execution
  • persistence

It is an internal optimisation layer.


  • Crafting Modifiers (modifier behaviour)
  • Crafting Validators (validation behaviour)

🧠 Design Notes

  • per-frame caching avoids complex invalidation logic
  • list reuse reduces GC pressure

This layer improves runtime performance while remaining transparent to consumers.