Coldwave Read the docs

Fusion: C# on the web#

Note. The command is ven in today's builds and becomes frost at launch, and so do the names built from it.

Fusion is how you put C# gameplay in a browser. A game in C# plays on the desktop under .NET, and exports to the desktop compiled ahead of time, but a browser runs no .NET. So Fusion is a subset of C# that the engine compiles itself into one WebAssembly module, which the web player loads beside the game. See C# for C# in general.

What Fusion is#

A C# script whose Step classes are all marked [Fifth] can be exported to the web. (The compiler is now called Fusion; the attribute is still spelled [Fifth] in this release.) Such a class walks columns of the world, numbers and booleans, with plain arithmetic:

  • It reads and writes the columns its Step takes (TransformColumns, your own components' columns), the entity indices it is lent, and fields it keeps between steps.
  • A checked index or an arithmetic failure stops the game with the script's name and C# line.

What it cannot do: spawn things, read input, play sound, set text, load scenes or call the engine's random source (World.Random). Heap arrays, the [Engine] maths routines and uint kept state are outside it too. A game that needs those gives that part to a Luau script beside the C# one, which prepares columns for it to read. Luau scripts run first; C# scripts run after them, in the project's order, on every host.

The example#

The engine's Bunnymark demo has a version with its motion in Fusion: motion.cs moves every bunny with the original double arithmetic, and setup.luau reads input, spawns bunnies and prepares their seeded floor kicks. Its positions, velocities and random state match the Luau Bunnymark at every recorded step. The engine also tests Fusion on a 60-step recorded run: every step's world is the same under .NET and under the exported module played by Node.

Exporting#

Fusion needs frost with C# (the -csharp download) and the .NET SDK, version 10 or later, on the machine you export from. The browser downloads no .NET.

Shell
frost export web game.toml --out web
frost play web --port 8081

The export runs the same C# generator and checks the desktop does, then the engine's own emitter, and writes one game/compiled.wasm; each exported .cs file is replaced by a description of the script, and your sources stay the source of truth. The browser downloads no .NET runtime. A C# Step that is not marked [Fifth] is refused for the web, with Fusion named as the way.

While you work#

frost dev and headless runs on the desktop go on running the marked class under .NET, so debugging and live reload work as for any C# script. The web build is an export: after changing a C# source, export again and reload the page.

Measured#

The engine's own measurements: at 100,000 bunnies the Fusion module alone took a median 0.257 ms a step under Node, against 90.6 ms for the Luau scalar step and 39.8 ms for C# on .NET, one run each on a busy machine. They time different things (the Node column has no world, scheduler or Luau boundary), so do not divide them into an end-to-end speed-up; browser timing is not measured yet.