Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ReflectionFunctionCaller

[14:7] extends: FxObj

Wraps FXGL's ReflectionFunctionCaller (com.almasb.fxgl.core.reflect.ReflectionFunctionCaller), a "call any registered method by string name" utility used by FXGL's dev console and dialogue function-call nodes. Useful for building in-game debug consoles in Aussom games.

Methods

  • ReflectionFunctionCaller ()

    Creates a new empty caller. Register methods with addFunctionCallTarget before invoking by name.

  • adopt (object Ajo)

    Wraps an existing ReflectionFunctionCaller AussomJavaObject.

    • @p Ajo is an AussomJavaObject around the caller.
    • @r A new wrapper.
  • addFunctionCallTarget (object TargetObj)

    Registers the public methods of the given object as callable targets.

    • @p TargetObj is an AussomJavaObject around the target.
    • @r this object
  • invokeMethod (string MethodName, list Args)

    Invokes a previously registered method by name with the supplied (string) arguments. Returns the method's return value (or null for void).

    • @p MethodName is the method name to invoke.
    • @p Args is a list of stringified arguments.
    • @r The method result.
  • removeFunctionCallTarget (object TargetObj)

    Removes a previously registered function call target.

  • exists (string MethodName, int ArgCount)

    Returns true when a method named MethodName with exactly ArgCount string arguments is registered.

  • getMethods ()

    Returns the live List of every registered method as a raw AJO. Useful for building a help / list-commands UI.

  • getDefaultFunctionHandler ()

    Returns the BiFunction<String, List, Object> handler invoked when call() is asked for a method that isn't registered. Null when no fallback is installed.

  • setDefaultFunctionHandler (callback Cb)

    Installs a fallback handler invoked when call() is asked for an unknown method. The handler receives (name, args) and returns the value to feed back to the caller.

    • @p Cb is a callback (name, args) -> any.