reckfellENGINE

Callable

A C# value representing a method or .NET delegate for engine API calls.

On this page
struct CallableReckfellSharpInherits ValueType

A C# struct representing a method or delegate. Callable.From(...) creates a .NET-delegate representation; Callable(target, method) stores an object and method name. Call(...) passes Variant arguments, so their count and types must match the target method.

Representations differ: a delegate can populate Delegate while Target is null, and an object-method representation can populate Target and Method while Delegate is null. One field is not a universal callability check. Constructing the value does not prove method existence or target lifetime.

Callable has no C# conversion to bool. default(Callable) is not a null reference either. Use normal C# event syntax for ordinary event subscriptions; use Callable where the API requires this type.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

CallableConstructor
# Callable
C#
public Callable(ReckfellObject target, StringName method);

Stores target and method without invoking the method. Construction neither verifies method existence nor guarantees the native object’s lifetime. Use Callable.From for a delegate or lambda. The name is stored as the same managed StringName wrapper: do not dispose it while the Callable is in use.

Parameters
NameTypeDefault
targetReckfellObject—
methodStringName—
target

Live object whose method will be invoked. Callable does not replace object lifetime management.

method

Exact registered method name; case-sensitive. Use nameof or an available MethodName constant for a C# method.

Properties4

DelegateProperty
# Delegate
C#
public Delegate Delegate { get; }

Returns the stored .NET delegate for From/CreateWithUnsafeTrampoline. Object/method representations and default(Callable) return null. A delegate does not validate captured native-object lifetimes; absence of a delegate does not invalidate an object/method Callable.

MethodProperty
# Method
C#
public StringName Method { get; }

Returns the stored method-name wrapper for an object/method representation. Callable.From and default(Callable) can yield null. This is not a name derived from Delegate.Method. The returned reference is borrowed: do not dispose it separately while the Callable is in use.

TargetProperty
# Target
C#
public ReckfellObject Target { get; }

For Callable(target, method), returns the stored object. For a delegate, returns Delegate.Target only when it is a ReckfellObject; a static delegate or ordinary managed closure can yield null. This is neither a universal callability check nor a native lifetime guarantee. Reading does not transfer object ownership.

TrampolineProperty
# Trampoline
C#
public unsafe delegate*<object, Reckfell.NativeInterop.NativeVariantPtrArgs, out Reckfell.NativeInterop.reckfell_variant, void> Trampoline { get; }

Low-level managed function pointer that invokes the stored Delegate through native Variant arguments. From supplies an SDK trampoline; CreateWithUnsafeTrampoline uses the caller’s pointer. Use Call for ordinary invocation. An object/method representation has a null pointer; this property is not a universal validity check.

Methods25

Call2 overloads
# Call · 1/2
C#
public Variant Call(params Variant[] args);

Synchronously invokes the stored method or delegate. Arguments pass as Variant values and the SDK converts them to the expected types; this is not an ordinary compiler-checked C# call signature. Ensure the argument count, supported types and live target beforehand.

Action returns Variant.Type.Nil; Func results are converted to Variant. Nil does not prove success: call errors or delegate exceptions can be logged. The current bridge does not guarantee that every such exception is rethrown to the calling C# code.

In the example, Twice(21) returns 42. The local argument and returned Variant have separate using lifetimes.

C#
using System.Threading.Tasks;
using Reckfell;

public static class CallableSignalExamples
{
    public static int Twice(int value)
    {
        var callback = Callable.From<int, int>(static number => number * 2);
        using var argument = Variant.From(value);
        using var result = callback.Call(argument);
        return result.AsInt32();
    }

    public static void SetLabelLater(Label label, string text)
    {
        var callback = Callable.From<string>(value =>
        {
            if (ReckfellObject.IsInstanceValid(label)) label.Text = value;
        });
        using var argument = Variant.From(text);
        callback.CallDeferred(argument);
    }

    public static async Task WaitNextProcess(EntityTree tree)
    {
        Variant[] arguments = await new Signal(tree, EntityTree.SignalName.ProcessFrame);
        foreach (var argument in arguments) argument.Dispose();
    }
}
Parameters
NameTypeDefault
argsVariant[]—
args

Arguments in method or delegate parameter order. Callable.From requires exactly the Action/Func input count; an empty set is appropriate for a zero-argument function.

Returns Variant

Result as a caller-owned Variant; dispose after reading. Void/Action yields Nil, but Nil can also accompany an error.

# Call · 2/2
C#
public Variant Call(ReadOnlySpan<Variant> args);

Synchronously invokes the stored method or delegate. Arguments pass as Variant values and the SDK converts them to the expected types; this is not an ordinary compiler-checked C# call signature. Ensure the argument count, supported types and live target beforehand.

Action returns Variant.Type.Nil; Func results are converted to Variant. Nil does not prove success: call errors or delegate exceptions can be logged. The current bridge does not guarantee that every such exception is rethrown to the calling C# code.

In the example, Twice(21) returns 42. The local argument and returned Variant have separate using lifetimes.

C#
using System.Threading.Tasks;
using Reckfell;

public static class CallableSignalExamples
{
    public static int Twice(int value)
    {
        var callback = Callable.From<int, int>(static number => number * 2);
        using var argument = Variant.From(value);
        using var result = callback.Call(argument);
        return result.AsInt32();
    }

    public static void SetLabelLater(Label label, string text)
    {
        var callback = Callable.From<string>(value =>
        {
            if (ReckfellObject.IsInstanceValid(label)) label.Text = value;
        });
        using var argument = Variant.From(text);
        callback.CallDeferred(argument);
    }

    public static async Task WaitNextProcess(EntityTree tree)
    {
        Variant[] arguments = await new Signal(tree, EntityTree.SignalName.ProcessFrame);
        foreach (var argument in arguments) argument.Dispose();
    }
}
Parameters
NameTypeDefault
argsReadOnlySpan<Variant>—
args

Arguments in method or delegate parameter order. Callable.From requires exactly the Action/Func input count; an empty set is appropriate for a zero-argument function.

Returns Variant

Result as a caller-owned Variant; dispose after reading. Void/Action yields Nil, but Nil can also accompany an error.

CallDeferred2 overloads
# CallDeferred · 1/2
C#
public void CallDeferred(params Variant[] args);

Queues the call for deferred execution and returns immediately. Arguments are copied into the queue; local Variant arguments can be disposed after queuing. The method’s result cannot be obtained here.

The queue is processed during idle/flush, not after a guaranteed frame count or as a timer. Avoid an endless chain in which each deferred call queues itself again. The target can be freed before execution: SetLabelLater in the Call example checks IsInstanceValid before changing the Label.

Parameters
NameTypeDefault
argsVariant[]—
args

Arguments for the future call in parameter order. Validate count and type convertibility beforehand.

# CallDeferred · 2/2
C#
public void CallDeferred(ReadOnlySpan<Variant> args);

Queues the call for deferred execution and returns immediately. Arguments are copied into the queue; local Variant arguments can be disposed after queuing. The method’s result cannot be obtained here.

The queue is processed during idle/flush, not after a guaranteed frame count or as a timer. Avoid an endless chain in which each deferred call queues itself again. The target can be freed before execution: SetLabelLater in the Call example checks IsInstanceValid before changing the Label.

Parameters
NameTypeDefault
argsReadOnlySpan<Variant>—
args

Arguments for the future call in parameter order. Validate count and type convertibility beforehand.

CreateWithUnsafeTrampolineCallable
# CreateWithUnsafeTrampoline
C#
public static unsafe Callable CreateWithUnsafeTrampoline(Delegate @delegate, delegate*<object, Reckfell.NativeInterop.NativeVariantPtrArgs, out Reckfell.NativeInterop.reckfell_variant, void> trampoline);

Low-level Callable creation for a custom managed trampoline. Use From for ordinary Action/Func callbacks: it checks argument count and performs Variant conversions.

The trampoline receives the delegate as object, a native argument view and an out reckfell_variant result. It must validate inputs, cast the delegate to its concrete type and initialize the result on every branch; use default for no result. Ownership of the returned native value transfers to the bridge. The managed function pointer must exactly match the SDK signature, including out; it is not an unmanaged-ABI pointer.

Parameters
NameTypeDefault
delegateDelegate—
trampolinedelegate*<object, Reckfell.NativeInterop.NativeVariantPtrArgs, out Reckfell.NativeInterop.reckfell_variant, void>—
delegate

Non-null delegate the trampoline knows how to cast and invoke.

trampoline

Valid managed function pointer with the exact SDK signature; the third parameter is out reckfell_variant.

Returns Callable

Callable value storing the delegate and pointer. Construction does not establish the custom trampoline’s safety.

From20 overloads
# From · 1/20
C#
public static Callable From(Action action);

Creates a Callable from Action with 0 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 2/20
C#
public static Callable From<T0>(Action<T0> action);

Creates a Callable from Action with 1 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 3/20
C#
public static Callable From<TResult>(Func<TResult> func);

Creates a Callable from Func with 0 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 4/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult> func);

Creates a Callable from Func with 9 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 5/20
C#
public static Callable From<T0, T1>(Action<T0, T1> action);

Creates a Callable from Action with 2 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 6/20
C#
public static Callable From<T0, TResult>(Func<T0, TResult> func);

Creates a Callable from Func with 1 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 7/20
C#
public static Callable From<T0, T1, T2>(Action<T0, T1, T2> action);

Creates a Callable from Action with 3 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 8/20
C#
public static Callable From<T0, T1, TResult>(Func<T0, T1, TResult> func);

Creates a Callable from Func with 2 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 9/20
C#
public static Callable From<T0, T1, T2, T3>(Action<T0, T1, T2, T3> action);

Creates a Callable from Action with 4 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2, T3>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 10/20
C#
public static Callable From<T0, T1, T2, TResult>(Func<T0, T1, T2, TResult> func);

Creates a Callable from Func with 3 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 11/20
C#
public static Callable From<T0, T1, T2, T3, T4>(Action<T0, T1, T2, T3, T4> action);

Creates a Callable from Action with 5 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2, T3, T4>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 12/20
C#
public static Callable From<T0, T1, T2, T3, TResult>(Func<T0, T1, T2, T3, TResult> func);

Creates a Callable from Func with 4 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, T3, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 13/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5>(Action<T0, T1, T2, T3, T4, T5> action);

Creates a Callable from Action with 6 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2, T3, T4, T5>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 14/20
C#
public static Callable From<T0, T1, T2, T3, T4, TResult>(Func<T0, T1, T2, T3, T4, TResult> func);

Creates a Callable from Func with 5 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, T3, T4, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 15/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, T6>(Action<T0, T1, T2, T3, T4, T5, T6> action);

Creates a Callable from Action with 7 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2, T3, T4, T5, T6>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 16/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, TResult>(Func<T0, T1, T2, T3, T4, T5, TResult> func);

Creates a Callable from Func with 6 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, T3, T4, T5, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 17/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7>(Action<T0, T1, T2, T3, T4, T5, T6, T7> action);

Creates a Callable from Action with 8 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2, T3, T4, T5, T6, T7>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 18/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, T6, TResult>(Func<T0, T1, T2, T3, T4, T5, T6, TResult> func);

Creates a Callable from Func with 7 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, T3, T4, T5, T6, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 19/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7, T8>(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> action);

Creates a Callable from Action with 9 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
actionAction<T0, T1, T2, T3, T4, T5, T6, T7, T8>—
action

Non-null delegate with the stated inputs and no return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

# From · 20/20
C#
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T0, T1, T2, T3, T4, T5, T6, T7, TResult> func);

Creates a Callable from Func with 8 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.

This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.

Parameters
NameTypeDefault
funcFunc<T0, T1, T2, T3, T4, T5, T6, T7, TResult>—
func

Non-null delegate with the stated inputs and TResult return value.

Returns Callable

Callable value storing the delegate and a trampoline for the stated signature.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.