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)¶
- 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.
-
Search for either method:
-
AddTemp(int) TryAddTemp(int)
Both public and non-public instance methods are acceptable.
- Attempt to compile a lightweight open-instance delegate:
Func<object, object[], object>
If this succeeds, subsequent calls avoid reflection entirely.
- If delegate compilation fails, fall back to:
MethodInfo.Invoke(...)
⚙️ Behaviour¶
- Returns
truewhen a shield is successfully applied - Returns
falsewhen: - 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.
🧪 Extending Bridges (recommended pattern)¶
To add additional bridges (Inventory, Currency, Status, etc.):
- Create a new static class under this folder
- Attempt
Type.GetType("FullTypeName, Assembly")first - Fall back to scanning loaded assemblies only if needed
- Cache
Type,MethodInfo, or compiled delegates - Log warnings only under
#if UNITY_EDITOR - 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.