World Builder

WorldBuilder is used to construct a World from Engines, Renderers, and an initial state of Entities, Components, and Messages.

The WorldBuilder enforces certain rules about Engine structure. It is forbidden to have messages create cycles between Engines, and no Component may be mutated by more than one Engine without declaring a priority.

The WorldBuilder uses Engines and their Message read/send information to determine a valid ordering of the Engines, which is given to the World.

Here is an example usage with FNA:

using Encompass;
using Microsoft.Xna.Framework;

public class MyGame : Game
    private World world;


    protected override void LoadContent()
        var worldBuilder = new WorldBuilder();

        worldBuilder.AddEngine(new MotionEngine());
        worldBuilder.AddRenderer(new TextureRenderer());

        var entity = worldBuilder.CreateEntity();

        SetComponent(entity, new PositionComponent(0, 0));
        SetComponent(entity, new VelocityComponent(20, 0));

        SetComponent(entity, new TextureComponent(

        world = worldBuilder.Build();


Now our game will initialize with a ball that moves horizontally across the screen!

Be extra careful that you remember to actually add Engines to the WorldBuilder when you define them. Otherwise nothing will happen, which can be very embarrassing.