Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Util::RuntimeUtils Class Reference

Utility for detecting available scripting runtime bridges. More...

#include <RuntimeUtils.hpp>

Static Public Member Functions

static bool isRuntimeAvailable (Infinity::Data::ProceduralComponentRuntime runtime)
 Checks if a specific scripting runtime is available.
 

Detailed Description

Utility for detecting available scripting runtime bridges.

RuntimeUtils provides functionality to query which scripting language runtimes are available in the current Infinity Engine instance. This enables procedural components to determine whether they can execute scripts written in C#, Python, JavaScript, or other supported languages.

The Infinity Engine supports procedural components implemented in multiple languages through runtime bridges. These bridges allow components to be authored in high-level scripting languages while integrating seamlessly with the native C++ engine. Runtime availability depends on:

  • Whether the runtime bridge is compiled into the engine build
  • Whether required runtime libraries are installed on the system
  • Platform-specific runtime support

Common use cases:

  • Checking runtime availability before loading scripted components
  • Providing fallback behavior when preferred runtime is unavailable
  • Validating component requirements during registration
  • Displaying available runtimes in development tools
  • Conditional component loading based on runtime support
Note
Runtime availability is determined at engine initialization.
Availability may vary by platform and engine configuration.
Native C++ components are always available and don't require runtime checks.

Example usage:

using namespace Infinity::Data;
// Check if Python runtime is available
if (RuntimeUtils::isRuntimeAvailable(ProceduralComponentRuntime::Python)) {
// Load Python-based procedural component
auto pythonComponent = loadComponent("python_terrain_generator");
} else {
// Fall back to native implementation
auto nativeComponent = loadComponent("native_terrain_generator");
}
// Validate component requirements during registration
ProceduralComponentDescription desc = loadDescriptor(path);
if (!RuntimeUtils::isRuntimeAvailable(desc.data().runtime())) {
std::cerr << "Required runtime not available for component: "
<< desc.data().name() << std::endl;
return false;
}
// Display available runtimes in UI
std::vector<ProceduralComponentRuntime> availableRuntimes;
for (auto runtime : allRuntimes) {
availableRuntimes.push_back(runtime);
}
}
// Conditional feature enabling
bool enablePythonScripting = RuntimeUtils::isRuntimeAvailable(
ProceduralComponentRuntime::Python
);
bool enableCSharpScripting = RuntimeUtils::isRuntimeAvailable(
ProceduralComponentRuntime::CSharp
);
static bool isRuntimeAvailable(Infinity::Data::ProceduralComponentRuntime runtime)
Checks if a specific scripting runtime is available.

Member Function Documentation

◆ isRuntimeAvailable()

static bool Infinity::Util::RuntimeUtils::isRuntimeAvailable ( Infinity::Data::ProceduralComponentRuntime  runtime)
static

Checks if a specific scripting runtime is available.

Queries whether the specified runtime bridge is available in the current engine instance. Returns true if components using that runtime can be loaded and executed.

Parameters
runtimeThe runtime to check (from ProceduralComponentData schema).
Returns
True if the runtime is available, false otherwise.
Note
Native/C++ runtime is implicitly always available.
Availability is cached at engine startup and does not change at runtime.