Skip to content

RevFramework – Pickups • Core • Bridges

Folder: Runtime/Systems/Pickups/Core/Bridges

The Bridges folder contains tiny, reflection-based adapters that allow pickup effects
to interact with optional external RevFramework systems without introducing compile-time dependencies.

Bridges preserve RevFramework’s modular architecture while still enabling rich cross-system behaviour.


🎯 Purpose

Bridges exist to:

  • Keep RevFramework modular and decoupled
  • Avoid hard references between systems (Health, Inventory, Currency, etc.)
  • Provide safe, one-way reflection fallbacks
  • Enable behaviour only when the corresponding module is installed
  • Fail silently in builds, warn only in the Editor

Everything in this folder is optional — the Pickups system functions correctly even when no external modules are present.


🔌 Current Bridge

TempShieldBridge

Allows pickup effects to apply temporary shield points when the Health module’s
TempHealthShield component is present.

TempShieldBridge.TryAddTemp(GameObject target, int amount);

🔍 Resolution Process (exact to code)

  1. Attempt to resolve the target type:
RevGaming.RevFramework.Health.Shields.TempHealthShield

via:

Type.GetType("FullTypeName, Assembly", false);

If this fails, the bridge performs a single domain scan across loaded assemblies.

  1. Search for either method:

  2. AddTemp(int)

  3. TryAddTemp(int)

Both public and non-public instance methods are acceptable.

  1. Attempt to compile a lightweight open-instance delegate:
Func<object, object[], object>

If this succeeds, subsequent calls avoid reflection entirely.

  1. If delegate compilation fails, fall back to:
MethodInfo.Invoke(...)

⚙️ Behaviour

  • Returns true when a shield is successfully applied
  • Returns false when:
  • the type is not present
  • the target lacks the component
  • no compatible method can be resolved
  • amount <= 0
  • Logs warnings only in the Editor (#if UNITY_EDITOR)
  • Never logs or throws in player builds

The bridge is 100% safe to ship, even when the Health module is not installed.


🧱 Key Properties

  • Zero compile-time references — Pickups never depends on Health
  • String-based type lookup — tolerant of refactors and assembly boundaries
  • No exceptions for missing modules — integration simply no-ops
  • Optimised — delegate caching avoids repeated reflection
  • Silent in builds — no log spam, no runtime penalties

This pattern allows RevFramework modules to remain loosely coupled yet interoperable.


To add additional bridges (Inventory, Currency, Status, etc.):

  1. Create a new static class under this folder
  2. Attempt Type.GetType("FullTypeName, Assembly") first
  3. Fall back to scanning loaded assemblies only if needed
  4. Cache Type, MethodInfo, or compiled delegates
  5. Log warnings only under #if UNITY_EDITOR
  6. Return boolean success/failure — never throw

Example Skeleton

public static class MyCustomBridge
{
    private static Type _type;
    private static MethodInfo _method;

    public static bool TryCall(GameObject target, int value)
    {
        if (!target || value <= 0) return false;

        // Resolve type once
        _type ??= Type.GetType("MyNamespace.MyTargetType, MyAssembly", false);
        if (_type == null) return false;

        var comp = target.GetComponent(_type);
        if (comp == null) return false;

        // Resolve method once
        _method ??= _type.GetMethod(
            "SomeMethod",
            BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
        );

        if (_method == null) return false;

        _method.Invoke(comp, new object[] { value });
        return true;
    }
}

🧠 Philosophy

Bridges are glue, not dependencies.

They:

  • Introduce zero compile-time coupling
  • Add optional behaviour only when systems exist
  • Never block effect execution when missing
  • Keep RevFramework clean, modular, and professional

If a target system isn’t installed, the pickup still behaves correctly —
it simply skips the unavailable integration.