Skip to content

RevFramework – Pickups • Decorators • Creators

Folder: Runtime/Systems/Pickups/Decorators/Creators

The Creators folder contains the builder classes that construct decorators
from DecoratorDefinition records inside a PickupEffectDefinitionBase.

✔ Each creator maps a DecoratorType → concrete PickupEffectDecorator
✔ Factory builds decorator chains deterministically
✔ Supports custom extension with zero reflection


🎯 Purpose

Creators exist to:

  • Separate authoring data (definitions) from runtime instances (decorators)
  • Provide a clean, registry‑based creation model
  • Allow projects to add, replace, or override decorator types safely

Creators are pure construction logic — they contain no runtime gameplay behaviour.


🧩 Core Interface

IPickupDecoratorCreator

All decorator creators implement this interface:

public interface IPickupDecoratorCreator
{
    bool CanHandle(DecoratorType type);
    PickupEffect Create(PickupEffect baseEffect, PickupEffectDefinitionBase def);
}

Responsibilities

A creator must:

  • Declare which DecoratorType it can build
  • Instantiate the correct PickupEffectDecorator
  • Copy configuration values from the definition (def)
  • Assign the incoming baseEffect to wrappedEffect
  • Return the newly wrapped decorator instance

Creators should never:

  • Execute gameplay logic
  • Perform reflection
  • Query scene state

🏭 Factory Workflow

The decorator construction pipeline is fully deterministic:

  1. A PickupEffectDefinitionBase lists DecoratorDefinition entries
  2. PickupEffectFactory sorts them by priority (ascending)
  3. For each decorator entry:
  4. The registry is queried for a matching creator
  5. The creator constructs a decorator wrapping the current effect
  6. The result is a fully chained decorated effect

This guarantees:

  • Stable ordering
  • No hidden behaviour
  • No reflection or runtime discovery

📦 Default Creators

The following creators ship with RevFramework:

Creator Class Decorator Type Description
VFXDecoratorCreator VFX Spawns one‑shot visual effects
PersistentVFXDecoratorCreator PersistentVFX Attaches or times a persistent visual effect
SoundDecoratorCreator Sound Plays audio via AudioSFXChannel or fallback AudioSource
ConditionalDecoratorCreator Conditional Gates execution by health %, tag, or random chance
DebugLogDecoratorCreator DebugLog Logs execution in the console (Editor‑safe)

These are registered automatically by DefaultPickupDecoratorRegistry.


📚 Registry

DefaultPickupDecoratorRegistry

Handles lookup and lifetime of all decorator creators:

public sealed class DefaultPickupDecoratorRegistry : IPickupDecoratorRegistry
{
    void Register(IPickupDecoratorCreator creator);
    void Unregister(IPickupDecoratorCreator creator);
    IPickupDecoratorCreator Find(DecoratorType type);
}

Important Notes

  • Built‑in creators are registered during registry construction
  • Duplicate creator types are ignored (prevents undefined behaviour)
  • The active registry can be replaced entirely:
PickupEffectFactory.SetRegistry(customRegistry);

This allows complete control over decorator availability if required.


➕ Extending the System

To add a custom decorator type:

  1. Create the decorator class
    Subclass PickupEffectDecorator and implement your behaviour.

  2. Create a matching creator
    Implement IPickupDecoratorCreator and map your DecoratorType.

  3. Register the creator

PickupEffectFactory.RegisterCreator(new MyCustomDecoratorCreator());
  1. (Optional) Extend DecoratorType with your new enum value and reference it from your definition asset.

This keeps custom behaviour fully compatible with the factory pipeline and ordering guarantees.


📘 See Also

  • Decorators Overview../
  • Core Factory Pipeline../../Core/README.md
  • Effect Definitions../../Definitions/README.md