EasyEcs

EasyEcs documentation

Start here. What EasyEcs is, how to install it, a first system in a dozen lines, and the order to read the guide in.

EasyEcs is an open-source, allocation-free archetype Entity Component System (ECS) for C# and .NET 10 servers. You write plain data and [ForEach] methods. A source generator turns them into inlined struct jobs, an analyzer catches design mistakes at compile time, and a full server tick of 100,000 entities takes 1.72 ms and allocates 0 B.

New to the pattern itself? Read What is an ECS? first.

Save 10,000 entities and load them back, vs DefaultEcs

30×faster
EasyEcs 146 μs, DefaultEcs 4.33 ms
  • EasyEcs146 μs
  • DefaultEcs4.33 ms

Head-to-head benchmarks it is faster in

24/ 37
against Friflo.Engine.ECS, Arch and DefaultEcs

One server tick

1.72ms
100,000 entities in one world

Allocated per tick

0B
after warm-up

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Install

dotnet add package EasyEcs

The package targets net10.0 and brings the source generator, the analyzer and its code fixes with it. There is nothing to register.

A first system

Program.cs
using EasyEcs;

using var world = new World();
world.AddSystem<MovementSystem>();
world.CreateEntity(new Position(0, 0), new Velocity(1, 0));
world.Update(); // Position is now (1, 0)

public record struct Position(float X, float Y) : IComponent;
public record struct Velocity(float X, float Y) : IComponent;

public class MovementSystem : EcsSystem
{
    [ForEach] 
    static void Move(ref Position p, in Velocity v) => p = new(p.X + v.X, p.Y + v.Y);
}

ref marks what the system writes and in what it only reads. The generator reads those two words to build the loop, to decide which systems may run in parallel, and to tell change tracking which rows were written.

Where to start

Reading order

What is an ECS?

Features

Getting started

ECS principles

Example

Guide

Reference

Performance

Architecture

Compare

Guide

The guide has one page per concept, in the order you need them.

The rest of the guide covers singletons, structural changes, ref and await, dynamic buffers, indexes and relations, hierarchies, groups, cleanup and disable, prefabs, bulk changes, snapshots, saves, migration and unloading, hosting, testing, debugging and diagnostics, troubleshooting, and every analyzer rule.

Compare

Coming from another ECS? See EasyEcs against Arch, Friflo, DefaultEcs and Unity Entities, and the migration pages for Arch, Friflo and DefaultEcs.

Reference

Why it is built this way: the design decisions; what comes next: the roadmap. Upgrading from an earlier version? The migration guide covers every step from v2 to v3, v3 to v4 and between the 4.x releases.

Edit on GitHub

Last updated on

How is this guide?

On this page