Choose a Script Backend
An embedding project selects its gameplay scripting backend when it configures the build: AngelScript (.fos modules) or Managed C# (.cs modules on embedded Mono). The choice changes toolchain prerequisites, sanitizer lanes, debugging, static analysis, test style and the server concurrency contract, and it is cheap to make before the first script and expensive to reverse afterwards. This page lists what each backend needs, where they differ, and how to set each one up; the owning guides carry the full contracts.
Source paths inspected
BuildTools/cmake/ProjectInterface.jsonBuildTools/cmake/stages/Init.cmakeBuildTools/cmake/stages/ProjectOptions.cmakeBuildTools/cmake/stages/Applications.cmakeBuildTools/cmake/stages/ScriptsAndBaking.cmakeBuildTools/cmake/stages/ThirdParty.cmakeBuildTools/buildtools.pyBuildTools/README.mdBuildTools/SupportMatrix.jsonSource/Common/Settings.incSource/Server/Server.cppSource/Server/EntitySync.cppSource/Tests/Test_ServerEngine.cppDocs/en/explanation/scripting-runtime/index.mdDocs/en/explanation/runtime/server.mdDocs/en/how-to/scripting/managed-csharp.mdDocs/en/how-to/scripting/style-and-refactoring.mdDocs/en/how-to/scripting/lifecycle-and-concurrency.mdDocs/en/how-to/build/generated-content.mdDocs/en/how-to/build/project-configuration.mdDocs/en/troubleshooting/debugging.mdDocs/en/reference/platforms/support-matrix.mdDocs/en/reference/script-api/settings.mdDocs/en/contributing/coding-contracts/nullability.mdExamples/MinimalProject/
Short answer
Both implemented backends share the same metadata, entity model, events, remote calls and native export surface, so a game design does not depend on the choice. Native scripting (FO_NATIVE_SCRIPTING) is only a reserved option: its source root contains a single placeholder file and its CMake description says no Native backend is implemented. Do not select it.
| If the project needs | Prefer | Why (source of the claim) |
|---|---|---|
| A maintained, runnable starting point | AngelScript | All five projects under Examples/ ship .fos modules and set FO_ANGELSCRIPT_SCRIPTING ON. The Engine ships no managed starter example yet: no .cs file is tracked under Examples/. |
| The smallest toolchain | AngelScript | Managed C# additionally needs a .NET SDK on the build host and builds an embedded Mono runtime from source on the first build. |
| MemorySanitizer or ThreadSanitizer lanes with scripts enabled | AngelScript | Init.cmake rejects San_Memory* and San_Thread when FO_MANAGED_SCRIPTING is on. |
| Live script stepping in an editor | AngelScript | The Engine ships an opt-in AngelScript debugger endpoint. It has no C# counterpart. |
| Compile-time proof of server entity-cover use | Managed C# | The Roslyn analyzer (FOSYNC diagnostics) is part of the managed build; AngelScript relies on runtime cover checks. |
Task/await, Roslyn tooling, NuGet analyzers, IDE navigation |
Managed C# | The baker generates a .gen.csproj/.gen.sln that IDEs open and the build treats warnings as errors. |
| Replacing a script method in a running process | Managed C# | Patch-point weaving and the live compiler exist only in the managed backend, and both are opt-in. |
If none of these rows decides the question, start with AngelScript, because the runnable examples, the support matrix’s compiler lanes and the debugger exist for it.
What each backend requires
| Item | AngelScript | Managed C# |
|---|---|---|
| CMake option | FO_ANGELSCRIPT_SCRIPTING |
FO_MANAGED_SCRIPTING |
| Source files | project .fos modules |
project top-level .cs files plus Engine CoreScripts |
| Extra build application | <DevName>_ASCompiler, built when FO_BUILD_ASCOMPILER is on; configuration fails if that option is on without AngelScript |
<DevName>_ManagedScriptBaker, built when the baker library is built (FO_BUILD_BAKER, FO_BUILD_MAPPER, FO_BUILD_ASCOMPILER or FO_UNIT_TESTS) |
| Build host additions | none beyond the normal C++ toolchain | a .NET SDK able to run ManagedScript.MsBuild (default dotnet msbuild) for ManagedScript.TargetFramework (default net10.0), and the Mono runtime build described below |
| Resource pack baker | Bakers = AngelScript |
Bakers = Managed |
| Project settings | AngelScript.* group |
ManagedScript.* group |
| Compile artifact | baked AngelScript bytecode | per-role assemblies (<Pack>.Server.dll, <Pack>.Client.dll, <Pack>.Mapper.dll) plus a runtime payload |
| Fast compile check | CompileAngelScript |
CompileManagedScripts |
The options are independent booleans. A production project enables exactly one; cross-backend invocation tests are the documented reason to enable more. Select them in the project CMakeLists.txt the way Examples/MinimalProject/CMakeLists.txt does:
SetOption(FO_ANGELSCRIPT_SCRIPTING ON)
SetOption(FO_NATIVE_SCRIPTING OFF)
SetOption(FO_MANAGED_SCRIPTING OFF)
A fully managed project inverts the first and third lines. SetOption only assigns a variable that is not yet defined and never checks the name against ProjectInterface.json, so a misspelled option passes silently; verify spelling against CMake Options.
Platform, sanitizer, debugging, analysis and tests
| Concern | AngelScript | Managed C# |
|---|---|---|
| Engine-gated lanes | The required desktop lanes of the support matrix build the AngelScript compiler (win64-ascompiler, linux-ascompiler). |
The only dedicated BuildTools validation names are managed-mac-client, managed-ios-simulator-client and managed-ios-device-client, run through the manual managed-apple workflow job; they link a client and execute nothing. |
| Platform reach | The vendored runtime has patched native-call paths for x64 GCC, x64 MSVC and ARM64; check any other target yourself. | Wired for Windows, Linux, Android, WebAssembly, macOS and iOS build paths. That is source capability, not a release claim: qualify every shipped target with your own pack, payload, startup and update route. |
| Host limits | none beyond the normal toolchain | The runtime for a Windows target cannot be built on a non-Windows host: configuration aborts unless FO_MANAGED_RUNTIME_PREBUILT (environment) points at a tree built on Windows. |
| Sanitizers | Clang adds San_Address, San_Memory, San_MemoryWithOrigins, San_Undefined, San_Thread, San_DataFlow and San_Address_Undefined. |
San_Memory* and San_Thread are not offered and abort configure when forced. AddressSanitizer and undefined-behavior lanes remain, and need your own managed runtime checks. |
| Live debugging | Opt-in endpoint: AngelScript.DebuggerEnabled = True, loopback bind by default, line breakpoints, stepping, read-only locals. Development configs only. |
No Engine editor adapter or launch profile. Use the generated solution for navigation, Roslyn diagnostics, runtime logs and focused tests; attach a native or managed debugger only after matching assemblies, payload and symbols. |
| Static analysis | Compiler rules for attributes, direct calls of dispatcher-owned functions, const-only globals and T? nullability. Declaration-parity checks beyond that are project-side. |
Nullable references, TreatWarningsAsErrors, checked arithmetic, ManagedScript.Analyzers/AnalyzerPackages, and the FOSYNC cover analyzer. |
| Formatting | Engine wrapper buildtools.py format-source requires clang-format 20 and repairs .fos syntax, but only formats Engine Source; the project wires its own .fos formatting. |
Project-owned formatter and style gate; the generated project enforces code style in the build. |
| Engine test coverage to read | Test_AngelScript*.cpp |
Test_ManagedScriptBaker.cpp, Test_ManagedScriptRuntime.cpp, BuildTools/tests/test_managed_*.py, analyzer and CoreScripts test projects |
| Project script tests | project-owned harness, run through the gameplay test runner | the same runner contract; the harness is C# and is project-owned |
Read the debugging guide before relying on an attach workflow, and the nullability contract for the T? rules both backends share.
Build and bake side by side
Both routes depend on ForceCodeGeneration, so script-visible metadata is current before any script compiles. The commands are the same in PowerShell and bash.
| Step | AngelScript | Managed C# |
|---|---|---|
| Prepare host | normal C++ toolchain only | install a .NET SDK; optionally pre-stage the pinned runtime source with py -3 Engine/BuildTools/buildtools.py prepare-workspace dotnet (Windows) or python3 Engine/BuildTools/buildtools.py prepare-workspace dotnet (Linux) |
| Configure | cmake --preset <your-preset> with AngelScript on |
the same, with FO_MANAGED_SCRIPTING on; the SetupManagedRuntime target, a dependency of the generated outputs, builds Mono from the revision pinned in ThirdParty/dotnet-runtime on the first build |
| Compile scripts | cmake --build <build-dir> --config RelWithDebInfo --target CompileAngelScript |
cmake --build <build-dir> --config RelWithDebInfo --target CompileManagedScripts |
| What it runs | <DevName>_ASCompiler -ApplyConfig <project .fomain> -ApplySubConfig NONE |
<DevName>_ManagedScriptBaker with the same arguments: generates the C# API, .gen.csproj and .gen.sln, then compiles assemblies |
| Bake | BakeResources / ForceBakeResources; the AngelScript baker writes bytecode into the pack |
the same targets; the Managed baker packs assemblies and ManagedRuntime/ |
| Failure signal | compiler diagnostics with script file and line | ManagedScriptBakerException for unsupported shapes, MSBuild/Roslyn diagnostics otherwise |
A bake is the only step that proves delivery. Compiling scripts proves syntax and metadata agreement; it does not prove that the resource pack, runtime payload or startup path works.
The .fomain carries the backend choice as a resource pack, so keep it consistent with the CMake option:
[ResourcePack]
Name = Scripts
InputDirs = Scripts
Bakers = AngelScript
ServerOnly = True
For Managed C#, select the pack and the generated-project settings together; the settings below are the documented defaults plus the analyzer path shown in the project-configuration guide:
ManagedScript.Assemblies = MyGame
ManagedScript.ProjectName = MyGame
ManagedScript.TargetFramework = net10.0
ManagedScript.MsBuild = dotnet msbuild
ManagedScript.Dirs = Engine/Source/Scripting/Managed/CoreScripts Scripts
ManagedScript.Analyzers = Engine/Source/Scripting/Managed/Analyzers/FOnline.Analyzers.csproj
[ResourcePack]
Name = ManagedScripts
InputDirs = Engine/Source/Scripting/Managed/CoreScripts Scripts
IncludePatterns = *
Bakers = Managed
See Project Configuration for all pack fields, Generated Content Workflow for the compile routes, and the ManagedScript settings table for every managed setting.
On Windows, dotnet/runtime paths sit close to MAX_PATH. The CMake stage documents FO_DOTNET_DIR as the override: set it, in CMake or the environment, to a short path before the first managed build.
Concurrency choice
Server scripts normally run on a worker pool, so every script entry must prove it holds the entities it touches. AngelScript uses runtime cover operations (Game.Sync, Game.Lock); Managed C# uses Sync helpers proved by the FOSYNC analyzer. See Script Lifecycle and Concurrency for the contract.
Server.SingleThreadedLogic is the opt-out. The setting is read-only after startup, server-scoped and false by default (see the settings reference). With it enabled:
- the server worker pool is created with one thread, and the setting takes precedence over
Server.WorkerThreads; - entity-access validation accepts every entity and the cover-acquisition calls acquire nothing, so
Game.SyncandGame.SyncReleasedo nothing; Game.LockandGame.Unlockstill take the engine singleton bucket, which is uncontended;- entity lifetime checks remain: a handle captured in one job may refer to an entity destroyed before a later job runs;
- the mode is read per engine instance, so differently configured servers can coexist in one process.
| Choose | When | Cost |
|---|---|---|
Default (false) |
The game needs logic to use several cores, or scripts will keep their synchronization calls for a later switch. | Every script entry must build a complete, correct cover; mistakes are contract errors, not benign races. |
Server.SingleThreadedLogic = True |
The game is small enough for one logic worker, or the project prefers serial semantics over parallelism. | All game logic shares one worker thread, so parallel scaling of logic is given up. The setting is fixed for a server run. |
Disabling the setting later restores the full cover contract without changing scripts that kept their ordinary synchronization calls, but scripts written only for serial mode may lack them. For Managed C#, the Roslyn analyzer sources contain no reference to the setting, so if you configure the analyzer, cover annotations still gate the build in either mode. The opt-out is backend-neutral and is pinned by ServerEngineSingleThreadedLogicRunsWithoutEntityCover in Source/Tests/Test_ServerEngine.cpp; the server runtime page owns the full description.
Migrating between backends
Moving a project from AngelScript to Managed C# is a port of declarations, lifecycle, callbacks, named calls, synchronization, tests, resource packs and packages, not a rename of files. Deleting .fos files without removing the AngelScript baker pack and adding the Managed pack leaves no active gameplay scripts. Keep public metadata names, remote-call declarations, property layouts and persisted identifiers unchanged unless the migration deliberately changes them, and do not ship two handlers for one event by accident. The mapping of attributes ([[ModuleInit]] to [ModuleInit], [[Async]]/Yield to Task/ScriptTask.Delay, runtime cover to [RequiresCover] and friends) is in the Managed C# migration section. The reverse direction has no Engine guide; treat it as the same checklist applied backwards.
Setup checklist: AngelScript
- Set
FO_ANGELSCRIPT_SCRIPTING ONandFO_MANAGED_SCRIPTING OFFin the projectCMakeLists.txt; enableFO_BUILD_ASCOMPILERin the preset or-Darguments. - Add a
[ResourcePack]withBakers = AngelScriptfor the script directory, asExamples/MinimalProject/FOnlineStarter.fomaindoes. - Decide
AngelScript.*project settings, for example the namespaces allowed to hold mutable globals; keep them minimal. - Wire a
.fosformatter that preserves nullable syntax, and pin clang-format 20 (formatter contract). - Compile every role the sources reach with
CompileAngelScript, then runBakeResources. - Decide
Server.SingleThreadedLogicand record it with the project’s other startup settings. - Add the project script tests and the process runner lane; use
AngelScript.DebuggerEnabledonly in development configs.
Setup checklist: Managed C#
- Install a .NET SDK that builds
ManagedScript.TargetFramework, and pin it in the project so every machine and CI runner uses the same one. - Set
FO_MANAGED_SCRIPTING ONandFO_ANGELSCRIPT_SCRIPTING OFF; enable the baker or another option that builds the baker library. - Optionally pre-stage the runtime source with
prepare-workspace dotnetand set a shortFO_DOTNET_DIRon Windows. - Add the
ManagedScript.*settings and aManagedresource pack that includes EngineCoreScriptsand the project directory. - Configure
ManagedScript.Analyzersand treat analyzer warnings as build failures. - Run
CompileManagedScripts, thenBakeResources; confirm the pack holdsAssemblies/Assemblies-<target>/andManagedRuntime/. - Decide
Server.SingleThreadedLogic, and banTask.Run,ConfigureAwait(false)and ThreadPool escapes statically. - Keep sanitizer lanes to AddressSanitizer or undefined-behavior configurations.
- Qualify each shipped platform with its own runtime payload; never reuse one target’s payload for another.
- Document the backend options, SDK pin, source roots, analyzers and exact commands in the project, as the project documentation boundary requires.
Validation checklist
- Exactly one of
FO_ANGELSCRIPT_SCRIPTINGandFO_MANAGED_SCRIPTINGis on;FO_NATIVE_SCRIPTINGis off. - The resource pack baker (
AngelScriptorManaged) matches the CMake option. - The compile target for the chosen backend passes for every role without warnings.
BakeResourcescompletes and the server starts from the baked output.Server.SingleThreadedLogicis set deliberately and documented.- Sanitizer lanes in CI exist only for configurations the backend allows.
- Platform claims are backed by project acceptance, not by Engine source capability.